Raised This Month: $32 Target: $400
 8% 

Database statistics


Post New Thread Reply   
 
Thread Tools Display Modes
Author
mad_hamster
Member
Join Date: Nov 2009
Plugin ID:
1420
Plugin Version:
1.0
Plugin Category:
Statistical
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Logs server statistics and cvars to a MySql database.
    Old 01-21-2010 , 14:37   Database statistics
    Reply With Quote #1

    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.
    Attached Files
    File Type: sp Get Plugin or Get Source (dbstats.sp - 1653 views - 15.4 KB)
    File Type: txt dbstats.sql.txt (3.1 KB, 700 views)

    Last edited by mad_hamster; 01-21-2010 at 18:23.
    mad_hamster is offline
    HiJacker
    Senior Member
    Join Date: Jul 2008
    Location: Slovakia
    Old 01-23-2010 , 13:26   Re: Database statistics
    Reply With Quote #2

    Looks interesting, but I have a question, how would it work if I set it on my servers (and it will collect data into one db) ? (16)
    __________________
    Before you talk to me, I should warn you : Im kind of strange.
    HiJacker is offline
    Send a message via ICQ to HiJacker
    blissend
    Member
    Join Date: Mar 2008
    Old 02-10-2010 , 12:44   Re: Database statistics
    Reply With Quote #3

    Cool. I've only just begun a similar project on my own servers but it doesn't gather nearly as much data as yours. It does however use a different method. Instead of a sourcemod I use php cronjob to get data via ssh/rcon (php classes) which updates some graphs every minute. Anyway I'm going to give this mod a whirl. If I make it draw some graphs for a web frontend I'll be sure to share.
    blissend is offline
    HiJacker
    Senior Member
    Join Date: Jul 2008
    Location: Slovakia
    Old 02-13-2010 , 08:24   Re: Database statistics
    Reply With Quote #4

    Interesting, When I first started my servers, i had idea to remake Psychostats Overview page to make it like Network Usage, Total Players etc. graphs, but after time I gave it up because I had no time.
    __________________
    Before you talk to me, I should warn you : Im kind of strange.
    HiJacker is offline
    Send a message via ICQ to HiJacker
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 21:54.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode