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:
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 rrdcreatenext, create a file called
RRDUpdate.php in your
modules directory.
<?
$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:
#!/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
all standard disclaimers apply as usual, your mileage may vary.