csserverstat 0.1
www.amateur-hour.net/csserverstat
kendokan@amateur-hour.net

The latest version of this document can always be found at http://www.amateur-hour.net/csserverstat.

History:

0.2	- fixed null char from truncating EOL in cslog.pl (thanks Captain Pizza)
	- fixed QStat path and display problems
	- minor cosmetic fixes to HTML output
	- fixed map name from showing as "default" when it couldn't find an image
	- clarified documentation (hopefully) and added to FAQ section

0.1 - initial beta release
	- it *mostly* worked
	- the documentation was even worse than this

Summary:

csserverstat is a Perl script that will show your Half-Life Counter-Strike server status on a web page.

Features:

- written in Perl, works under Windows and *nix
- your web server does not need to be on the same machine as your game server
- shows current server map, with picture
- shows current players, their frag count and their time connected to the server
- shows current server settings, such as mp_friendlyfire
- shows interesting events from the server's log file as they occur
	- connects and disconnects
	- team wins
	- kills
	- hostage touches and rescues
	- bomb plants, explosions, and defusals
	- vip escapes and assassinations
	- live and dead player chats (does NOT show team chats)

Requirements:

- Perl5 or ActivePerl. Perl5 comes with most popular *nix distributions. If you run a Windows server you will need to download and install ActivePerl (http://www.activestate.com/Products/ActivePerl).
- A web server capable of handling Perl and CGI scripts. Apache and IIS are known to work, just about any other web server should too.
- A Half-Life Counter-Strike game server.
- QStat, available for both *nix and Windows (http://www.activesw.com/people/steve/qstat.html)
- hlmaps_images (http://sourceforge.net/projects/hlmaps)

Installation:

- Make a directory for your map and csserverstat images. Copy the pictures from hlmaps_images into this directory.
- Copy csserverstat.cgi into your web server's cgi-bin directory, or equivelant.
- Copy cslog.pl into a working directory on your web server. It does not need to be, and probably shouldn't be, a directory users can access via a web page.
- Copy everything from the csserverstat images directory to your images directory.

Configuration (cslog.pl):

- Edit cslog.pl and follow the directions in the comments (#). You'll need to input the IP address of your game server, the port you want cslog.pl to listen to the game server log with, and the directory where you want cslog.pl to write the log file.
- If you are using Windows, ensure you use forward slashes (/) and not back-slashes (\). For example, if you would normally put "c:\web\log", instead put "c:/web/log". This is true for any Windows path you put into either cslog.pl or csserverstat.cgi.
- The log file's name will be the IP address of you game server.
- If it isn't already there, add "log on" to your Counter-Strike server's autoexec.cfg file.
- Add "logaddress x.x.x.x zzzz" to your Counter-Strike server's server.cfg file, where x.x.x.x is the IP address of your web server and zzzz is the port you configured cslog.pl to listen with.
- If you want to show chat messages, add "mp_logmessages 1" to your Counter-Strike server's server.cfg file.
- Make sure to either restart your Counter-Strike server, change the map, or exec server.cfg for the changes take effect.
- Run cslog.pl. For *nix this should be as simple as "./cslog.pl", and for Windows "perl cslog.pl". cslog.pl should run all the time or it will not receive log files.
- Verify that a log file matching the IP address of your game server has been created in the directory you specified. Please note that the log file will not be created until the game server sends at least one log entry.

Configuration (csserverstat.cgi):

- Edit csserverstat.cgi and follow the directions in the comments (#). I'll list the stuff you need to or can change here as well:
	- $defrefresh is the default amount of time web users must wait before the page will automatically refresh. The lower the value, the higher the load on your web server.
	- $minrefresh is the minimum amount of time web users must wait before the page will automatically refresh. The lower the value, the higher the load on your web server.
	- $defevents is the default number of server log events that will be shown to a web user. The higher the number, the higher the load on your web server.
	- $maxevents is the maximum number of server log events that will be shown to a web user. The higher the number, the higher the load on your web server.
	- $textcl is the color of normal text
	- $rtextcl is the color of reversed text
	- $linkcl is the color of web links
	- $hlinkcl is the color of web links when the mouse is hovering over them (MSIE only)
	- $bordercl is the color of the borders at the top and bottom of the tables
	- $pagebg is the background color of the web page
	- $infobg is the background for the areas that display the map picture, current player list and server settings
	- $chatbg is the background color for chat messages
	- $killbg is the background color for kill messages
	- $eventbg_s is the background color for server events (connects/disconnects)
	- $eventbg_t is the background color for Terrorist activities (bomb plants, wins, etc.)
	- $eventbg_ct is the background color for Counter-Terrorist activities (hostage rescues, wins, etc.)
	- $serverip is the ip address and port of your game server
	- $cgiloc is the URL to where csserverstat is located
	- $qstatpath is the directory where you installed QStat
	- $logdir is the path to where you told cslog.pl to put your log files
	- $logfile is the name of the log file cslog.pl will write. This should be the same as your game server's IP address
	- $imagepath is the complete path to the directory you created for the map and csserverstat images
	- $imageurl is the URL to that same path directory
	- If you are using Windows, comment out (#) the first line that start with $now, and uncomment the seconds line that starts with $now
	- $debug, if set to 1, will show the raw messages from your servers log. It's good for troubleshooting problems.
- Don't modify anything else unless you Know What You Are Doing.

FAQ:

First of all, I like cheese. Beer is also good.

csserverstat will *only* show things I have specifically *told* it to look for. Those things are listed above under Features. It will *not* show things like rcon commands, hlds_ld messages, Admin mod messages, etc.

The reason it doesn't show team chats is to prevent people from cheating by looking at the web page on one system while playing on another, giving them an unfair advantage by knowing what the other team is planning. It might seem silly, but as you probably already know, people will go to any lengths to gain any advantage they can.

I realized I didn't really describe the process very well, so here goes.

1. Your Half-Life server sends every log entry to the IP address and port specified in the "logaddress" command.
2. Listening on that IP and port address is cslog.pl. All it does is receive the log entries and put them into a file. You can run multiple instances of cslog.pl as long as they listen on different ports.
3. When a user loads csserverstat.cgi into their web browser, csserverstat.cgi executes and does a few things. First, it runs QStat to get the server name, current map, current players and current server settings. Then, it parses the log file output by cslog.pl and gets interesting events. Last, it formats all this for HTML and displays it to the end user.

/---------\     /--------\     /--------\     /----------------\     /--------\
|hl server| -=> |cslog.pl| -=> |log file| <=- |csserverstat.cgi| -=> |web user|
\---------/     \--------/     \--------/     \----------------/     \--------/
     |                           /-----\              |
     \----------------- <=- ---- |qstat| ---- <=- ----/
                                 \-----/

Support:

As long as you've read through and understand this document I'll support your installation as much as I can. Please limit your questions to cslog.pl or csserverstat.cgi. I can't support Perl, ActivePerl, QStat, hlmaps_images, Apache, Microsoft IIS or anything else, mostly due to lack of knowledge and otherwise due to lack of time. I can be reached by email at  kendokan@amateur-hour.net. I also frequent #ah on gamesnet.net.

NOTE: My mail server won't accept email from Hotmail due to excessive spam from those rat-bastards, so if you want to email me make sure you do not send it from a Hotmail account.

Credits:

Thanks to [taCo]GrinGo and MadMatt for writing cslog.pl, and Unit for not only alpha-testing everything under Windows but actually making it work. Thanks, guys.
