DBStats
This plugin logs server statistics and configuration data to a MySql database. It is meant to be used in conjunction with some web interface that can render pretty graphs. I currently do not provide such a web interface, but may do in the future.
Database tables:
gameplay: holds basic gameplay data.
Fields: ip (index), port (index), time (index), # clients, # in-game clients, # bots, # kills (for all clients), # bot_kills (for bots), # deaths, total connected minutes (for human clients).
teams: holds similar data as gameplay partitioned into teams, and adds team-specific columns.
Fields: ip (index), port (index), time (index), team id (index), team name, team score, # in-game clients, # bots, # kills (for all clients), # bot_kills (for bots), # deaths, total connected minutes (for human clients).
network: holds server network statistics and averages for human clients.
Fields: ip (index), port (index), time (index), total bytes in/out per second, avg. client dataflow in/out + standard deviation, avg. client packets in/out + standard deviation, avg. client latency in/out + standard deviation, avg. client loss in/out + standard deviation, choke.
settings: holds the value of cvars that are being monitored, as well as some important server properties that are written when the plugin loads and/or a map changes (currently "hostname", "game_folder" and "current_map").
Fields: ip (index), port (index), time (index), property (index), value.
CVars:
dbstats (default: 1). Enable/disable DBStats plugin.
dbstats_cvars (default: "hostname, sv_cheats"). List of CVars to monitor and log whenever their value changes.
dbstats_gameplay (default: 600). Enable logging server gameplay data (# of clients, kills, deaths, etc). 0=off, anything else is the number of seconds between samples.
dbstats_teams (default: 600). Enable logging server gameplay data per team (team score, # of clients, # of bots, etc). 0=off, anything else is the number of seconds between samples.
dbstats_network (default: 600). Enable logging server network data (avg ping to clients, packet loss, choke, etc). 0=off, anything else is the number of seconds between samples.
dbstats_log_empty (default: 0). Enable/disable logging when the server has 0 human players (to save space).
Installation:
- Create a database and a user that can access it.
- Using phpMyAdmin or a similar tool, execute the attached dbstats.sql.txt SQL file; it will create the necessary tables.
- Edit addons/sourcemod/configs/databases.cfg, add an entry with your database details, e.g.:
"dbstats"
{
"driver" "mysql"
"host" "localhost"
"database" "dbstats"
"user" "dbstats"
"pass" "dbstats"
}
- Put the plugin in your addons/sourcemod/plugins directory
Notes:
- Using the default settings, and assuming your server is active half of the day, you should get less than 50mb worth of data per server per year.
- Writes to the database are performed asynchronously and should hopefully not affect server performance, even if the database resides on a distant machine.
- Tested under CS:S, but should work on all games.
Todo:
(I will probably never get around to doing all of these, if someone's willing to contribute please let me know).
- Provide web interface
- Try to measure low-level gameplay "fluidity" (server tick/fps jitter); needed to detect when a server seems to function ok in terms of tick rate & choke, but in practice players complain about not being able to hit and a general choppy feeling, which may be caused by too many server processes sharing a limited number of CPU cores/memory bandwidth, or when a server wasn't restarted for too long (requires writing a sourcemod extension).
- Measure OS-level performance (swapping, disk I/O, RAM usage, CPU cores usage), to correlate problems in servers with the machine "health". Requires an external service that gathers data and writes it directly to the database.
- Enable triggering high-frequency sampling based on rules (e.g. if packet loss > 2% then sample network data every second for 1 minute, then return to normal for another hour). This can be used to analyse exceptional events at a higher granularity.
- Auto-erase olds records.