collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: graphing number of online members with rrdtool  (Read 6088 times)

0 Members and 1 Guest are viewing this topic.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
graphing number of online members with rrdtool
« on: November 27, 2005, 06:04:34 pm »
here's a quick and dirty way to graph the number of members online with rrdtool.

assuming you have rrdtool installed on the system, we shall proceed directly to the preparations..

first, create the RRD:
Code: [Select]

shell$ cd /home/bebot (or wherever your bot is kept)
shell$ rrdtool create online.rrd DS:num:GAUGE:300:0:U RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797


this creates the round-robin database online.rrd in your bot directory. if you want to know what all this means, read man rrdcreate

next, create a file called RRDUpdate.php in your modules directory.
Code: [Select]

<?

  $rrdupdate = new RRDUpdate($bot);

  $cron["1min"]["rrdupdate"] = &$rrdupdate;

  class RRDUpdate
  {
    var $bot;
    var $numon;
    var $timerightnow;

    function RRDUpdate (&$bot)
    {
      $this -> bot = &$bot;
    }

    function cron()
    {
      foreach($this -> bot -> commands["tell"]["online"] -> guild as $player) $nick[$player[0]] = 1;
      ksort($nick);
      $numon = count($nick);
      $timerightnow = time();
      system("/usr/local/bin/rrdtool update /home/bebot/online.rrd \"$timerightnow:$numon\"");
      echo "RRDUpdate: $numon\n"; //debug
    }
  }

?>


the bot is now ready to restart.

after the first few updates, you can graph your data with a script like this:
Code: [Select]

#!/bin/bash

PATH=/usr/local/bin:/usr/bin

rrdtool graph /home/bebot/onlinegraph/day.png -a PNG -h 180 -w 520 -s -1day -v "# users" -t "members online" --no-minor DEF:num=/home/bebot/online.rrd:num:MAX AREA:num#000000:"num" COMMENT:"\\c" GPRINT:num:MAX:"Max\\: %.lf" GPRINT:num:AVERAGE:"Average\\: %.lf" GPRINT:num:LAST:"Current\\: %.lf\\c" COMMENT:"All times are EST\\s" COMMENT:"\\c"

rrdtool graph /home/bebot/onlinegraph/week.png -a PNG -h 180 -w 520 -s -1week -v "# users" -t "members online" --no-minor DEF:num=/home/bebot/online.rrd:num:MAX AREA:num#000000:"num" COMMENT:"\\c" GPRINT:num:MAX:"Max\\: %.lf" GPRINT:num:AVERAGE:"Average\\: %.lf" GPRINT:num:LAST:"Current\\: %.lf\\c"

rrdtool graph /home/bebot/onlinegraph/month.png -a PNG -h 180 -w 520 -s -1month -v "# users" -t "members online" --no-minor DEF:num=/home/bebot/online.rrd:num:MAX AREA:num#000000:"num" COMMENT:"\\c" GPRINT:num:MAX:"Max\\: %.lf" GPRINT:num:AVERAGE:"Average\\: %.lf" GPRINT:num:LAST:"Current\\: %.lf\\c"

rrdtool graph /home/bebot/onlinegraph/year.png -a PNG -h 180 -w 520 -s -1year -v "# users" -t "members online" --no-minor DEF:num=/home/bebot/online.rrd:num:MAX AREA:num#000000:"num" COMMENT:"\\c" GPRINT:num:MAX:"Max\\: %.lf" GPRINT:num:AVERAGE:"Average\\: %.lf" GPRINT:num:LAST:"Current\\: %.lf\\c"



the above script will create graphs that look something like this. edit: yeah, my old IGN bot did this too. hence the little gap where i was setting up bebot ;)

man rrdgraph, rrdgraph_graph and rrdgraph_examples for more details on graphing with rrds.

you could also break this down by TL or level-range, graph each one as a different color, stack them, and get really really pretty graphs, but i saw no need for that :P

all standard disclaimers apply as usual, your mileage may vary.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 445
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal