== Munin plugin to get statistics from Half-Life 2 based servers == === Author === Ghost 1.0 2007-06-26 Original release 1.1 2008-03-30 Documentation and install instructions 2.0 2008-04-16 Wildcard version Website: http://css.setti.info/code/munin-srcds/ === Overview === These srcds_* plugins graph general server information from Half-Life 2 based servers. The plugins can be used with any gametype, which work under Valve's Source engine (ie. srcds). Some of the supported gametypes are Team Fortress 2, Counter-Strike: Source, Day of Defeat: Source and all mods based on these games. == Package contains these files == === Plugin files === * srcds_fps_: Find out game server's FPS (frames per second) performance * srcds_inout_: Find out game servers's network traffic (in / out) * srcds_players_: Find out number of players on the game server * srcds_uptime_: Find out game server's uptime === Additional files === * hl2rcon.c: [ASY]Zyrain's RCON tool code to query the server * rcon: Pre-compiled hl2rcon.c. This may or may not work on your system. === Links to Munin Exchange and hl2rcon.c files === Munin Exchange offers previews for the graphs, and chance to leave comments about the plugins. * http://muninexchange.projects.linpro.no/?search&cid=14&pid=119 * http://muninexchange.projects.linpro.no/?search&cid=14&pid=120 * http://muninexchange.projects.linpro.no/?search&cid=14&pid=121 * http://muninexchange.projects.linpro.no/?search&cid=14&pid=122 * http://trog.qgl.org/browse/docs/code/hl2rcon.c == Installation == These instructions assume that you have working Munin installation. Munin installation instructions are not provided here. Refer to munin installation instructions in a case you haven't got working Munin installation yet. Munin installation is relatively easy, and it's widely supported by the biggest Linux distributions. These plugins have been tested to be working with Munin version 1.2.5. === Quick Install === These instructions are mainly for Debian Linux. The instructions should work for other Linux distributions also. ==== Copy files ==== gcc -o rcon hl2rcon.c chmod a+x rcon cp rcon /usr/local/bin/ cp srcds_* /usr/share/munin/plugins/ chmod 755 /usr/share/munin/plugins/srcds_* ==== Configure ==== Edit /etc/munin/plugin-conf.d/munin-node [srcds_*] env.srcdspass password ==== Setup statistics for the game servers ==== cd /etc/munin/plugins/ ln -s /usr/share/munin/plugins/srcds_fps_ srcds_fps_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_inout_ srcds_inout_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_players_ srcds_players_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_uptime_ srcds_uptime_127.0.0.1_27015 ==== Restart ==== /etc/init.d/munin restart === 1. Install the rcon tool === [ASY]Zyrain's RCON tool is required for the srcds_* plugins to work. First compile the hl2rcon.c and install the binary to your system bin directory. You have to be root when copying the file. gcc -o rcon hl2rcon.c chmod a+x rcon cp rcon /usr/local/bin/ After installing the rcon tool, verify that you can use it to connect to your server. For example run the following command, but replace the values with those that match your server. Note that there's no space between the parameters and the values. rcon -Ppassword -a1.2.3.4 -p27015 stats The result should be similar to this output: CPU In Out Uptime Users FPS Players 57.00 71924.48 202992.86 497 16 488.04 23 L 03/30/2008 - 16:17:29: rcon from "1.2.3.4:51663": command "stats" === 2. Install the scripts === Copy the srcds_* scripts to Munin's plugin directory. The plugin directory is usually /usr/share/munin/plugins/. The plugins must be executable, so their access rights must be set properly. cp srcds_* /usr/share/munin/plugins/ chmod 755 /usr/share/munin/plugins/srcds_* Then edit or create the Munin node config file. The config file can be in different places depending on the Munin version. The configuration file can be /etc/munin/plugin-conf.d/munin-node. Write following lines to the config: [srcds_*] env.srcdspass password If you have multiple servers with different password, you can write separate entry for each server. Such as: [srcds_fps_127.0.0.1_27015] env.srcdspass password1 [srcds_fps_127.0.0.1_27016] env.srcdspass password2 The above example sets the password only for srcds_fps_ plugin. You'll need to write corresponding line for each plugin and server. Other configuration parameters can be read from the srcds_* plugin files. For example it's possible to define number of samples (srcdssamples) for srcds_fps_ plugin. See the parameters in the corresponding files for more information. === 3. Setup Munin to activate the scripts === Link the plugins from the Munin plugin directory to the activated plugins directory. The activated Munin plugins are usually at /etc/munin/plugins/. Replace 127.0.0.1 with your server real IP address and 27015 with the server port. Note that there's underscore "_" between the IP address and the port. cd /etc/munin/plugins/ ln -s /usr/share/munin/plugins/srcds_fps_ srcds_fps_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_inout_ srcds_inout_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_players_ srcds_players_127.0.0.1_27015 ln -s /usr/share/munin/plugins/srcds_uptime_ srcds_uptime_127.0.0.1_27015 Run munin-node-configure to see whether Munin correctly activated the scripts. The munin-node-configure program can be in different places depending on the installation. You can use "locate munin-node-configure" to find the real path for your installation. munin-node-configure Output of the command should list status for all Munin's plugins. There should be also the srcds_* plugins' status. Plugin | Used | Extra information ------ | ---- | ----------------- ... srcds_fps_ | yes | 127.0.0.1_27015 srcds_inout_ | yes | 127.0.0.1_27015 srcds_players_ | yes | 127.0.0.1_27015 srcds_uptime_ | yes | 127.0.0.1_27015 ... You can verify that Munin can also correctly get results from the server by using command "munin-run". For example get FPS statistics by running following command: munin-run srcds_fps_127.0.0.1_27015 The output should be similar to this: fps.value 328 In a case that munin-run fails or there's error, it's possible to test the plugins without munin too. First set envinronment variables srcdspass and srcdshost according to your server. In Linux you can write to command line: export srcdspass=password /etc/munin/plugins/srcds_fps_127.0.0.1_27015 This will run srcds_fps_ as a separate program without Munin. If this doesn't work, then Munin won't work either. The output should be similar to what it is above. === 4. Restart munin-node === Restart Munin. Usually the command for restarting Munin is following: /etc/init.d/munin restart Munin should restart quickly and it should start gathering statistics for the server defined in the configuration files. You can also just kill process named "munin-node" and restart it, which does just the same. === 5. See the results === Wait about 15 minutes for Munin to get the graphs going. Munin should create new section named "Sourceds" (Source Dedicated Server) for the server statistics in the statistics page. Make sure your 1000 fps server truly is 1000 fps - never seen one ;) Enjoy. -- Ghost