/* * graph.c * (C) Peter Salanki 2002 * This program is copyright, and covered by the Gnu Public License. * The Natasha bot. * sorcer@linux.se */ #include #include #include #include #include #include #include #include "../../settings.h" #include "../../globals.h" #include "../../bottypes.h" #include "settings.h" #define NAME "Graph" #define VERSION 1.00 void graphmain(void); MODULE_INIT _module_init(MODULE m); MODULE_DESTROY _module_destroy(MODULE m); int nextrrd; MODULE_INIT _module_init(MODULE m) { strncpy(m->name, NAME, 20); strncpy(m->compiledate, __DATE__ " " __TIME__, 30); m->version = VERSION; nextrrd = 0; } MODULE_DESTROY _module_destroy(MODULE m) { } void graphmain(void) { char query[MAX_QUERY]; int nowtime; struct generalinfo ginfo; if(time(NULL) >= nextrrd) { nowtime = time(NULL); nextrrd = time(NULL) + 300; ginfo = GetGeneralInfo(1, 1, 1, 0, 1, 0, 1); /* Make botsgraphs */ sprintf(query, "rrdtool update natasha-link.rrd %i:%i:%i", nowtime, ginfo.arms, ginfo.connectedarms); system(query); if(!htm) { sprintf(query, "rrdtool graph %sbots1.gif --title=\"ARMs/Online (60 mins)\" --start %i --end %i DEF:Bots=natasha-link.rrd:Bots:LAST LINE1:Bots#FF0000 DEF:Linked=natasha-link.rrd:Linked:LAST LINE1:Linked#0000FF &", RRD_PATH, nowtime - RRD_GRAPH1_START, nowtime); system(query); sprintf(query, "rrdtool graph %sbots2.gif --title=\"ARMs/Online (24 hours)\" --start %i --end %i DEF:Bots=natasha-link.rrd:Bots:LAST LINE1:Bots#FF0000 DEF:Linked=natasha-link.rrd:Linked:LAST LINE2:Linked#0000FF &", RRD_PATH, nowtime - RRD_GRAPH2_START, nowtime); system(query); sprintf(query, "rrdtool graph %sbots3.gif --title=\"ARMs/Online (30 days)\" --start %i --end %i DEF:Bots=natasha-link.rrd:Bots:LAST LINE1:Bots#FF0000 DEF:Linked=natasha-link.rrd:Linked:LAST LINE2:Linked#0000FF &", RRD_PATH, nowtime - RRD_GRAPH3_START, nowtime); system(query); sprintf(query, "rrdtool graph %sbots4.gif --title=\"ARMs/Online (365 days)\" --start %i --end %i DEF:Bots=natasha-link.rrd:Bots:LAST LINE1:Bots#FF0000 DEF:Linked=natasha-link.rrd:Linked:LAST LINE2:Linked#0000FF &", RRD_PATH, nowtime - RRD_GRAPH4_START, nowtime); system(query); } /* Make channel graphs */ sprintf(query, "rrdtool update natasha-channels.rrd %i:%i", nowtime, ginfo.channels); system(query); if(!htm) { sprintf(query, "rrdtool graph %schannels1.gif --title=\"Channels (60 mins)\" --start %i --end %i DEF:Channels=natasha-channels.rrd:Channels:LAST LINE1:Channels#0000FF &", RRD_PATH, nowtime - RRD_GRAPH1_START, nowtime); system(query); sprintf(query, "rrdtool graph %schannels2.gif --title=\"Channels (24 hours)\" --start %i --end %i DEF:Channels=natasha-channels.rrd:Channels:LAST LINE1:Channels#0000FF &", RRD_PATH, nowtime - RRD_GRAPH2_START, nowtime); system(query); sprintf(query, "rrdtool graph %schannels3.gif --title=\"Channels (30 days)\" --start %i --end %i DEF:Channels=natasha-channels.rrd:Channels:LAST LINE1:Channels#0000FF &", RRD_PATH, nowtime - RRD_GRAPH3_START, nowtime); system(query); sprintf(query, "rrdtool graph %schannels4.gif --title=\"Channels (365 days)\" --start %i --end %i DEF:Channels=natasha-channels.rrd:Channels:LAST LINE1:Channels#0000FF &", RRD_PATH, nowtime - RRD_GRAPH4_START, nowtime); system(query); } /* Make users graph */ sprintf(query, "rrdtool update natasha-users.rrd %i:%i:%i", nowtime, ginfo.usersonline, ginfo.usersauthed); system(query); if(!htm) { sprintf(query, "rrdtool graph %susers1.gif --title=\"Online/Authed Users (60 mins)\" --start %i --end %i DEF:Authed=natasha-users.rrd:Authed:LAST LINE1:Authed#0000FF DEF:Techs=natasha-users.rrd:Techs:LAST LINE2:Techs#00cc00 &", RRD_PATH, nowtime - RRD_GRAPH1_START, nowtime); system(query); sprintf(query, "rrdtool graph %susers2.gif --title=\"Online/Authed Users (24 hours)\" --start %i --end %i DEF:Authed=natasha-users.rrd:Authed:LAST LINE1:Authed#0000FF DEF:Techs=natasha-users.rrd:Techs:LAST LINE2:Techs#00cc00 &", RRD_PATH, nowtime - RRD_GRAPH2_START, nowtime); system(query); sprintf(query, "rrdtool graph %susers3.gif --title=\"Online/Authed Users (30 days)\" --start %i --end %i DEF:Authed=natasha-users.rrd:Authed:LAST LINE1:Authed#0000FF DEF:Techs=natasha-users.rrd:Techs:LAST LINE2:Techs#00cc00 &", RRD_PATH, nowtime - RRD_GRAPH3_START, nowtime); system(query); sprintf(query, "rrdtool graph %susers4.gif --title=\"Online/Authed Users (365 days)\" --start %i --end %i DEF:Authed=natasha-users.rrd:Authed:LAST LINE1:Authed#0000FF DEF:Techs=natasha-users.rrd:Techs:LAST LINE2:Techs#00cc00 &", RRD_PATH, nowtime - RRD_GRAPH4_START, nowtime); system(query); } /* Make total-users graph */ sprintf(query, "rrdtool update natasha-totusers.rrd %i:%i", nowtime, ginfo.totalusers); system(query); if(!htm) { sprintf(query, "rrdtool graph %stotusers1.gif --title=\"Total Users (60 mins)\" --start %i --end %i DEF:Total=natasha-totusers.rrd:Total:LAST LINE1:Total#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH1_START, nowtime); system(query); sprintf(query, "rrdtool graph %stotusers2.gif --title=\"Total Users (24 hours)\" --start %i --end %i DEF:Total=natasha-totusers.rrd:Total:LAST LINE1:Total#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH2_START, nowtime); system(query); sprintf(query, "rrdtool graph %stotusers3.gif --title=\"Total Users (30 days)\" --start %i --end %i DEF:Total=natasha-totusers.rrd:Total:LAST LINE1:Total#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH3_START, nowtime); system(query); sprintf(query, "rrdtool graph %stotusers4.gif --title=\"Total Users (365 days)\" --start %i --end %i DEF:Total=natasha-totusers.rrd:Total:LAST LINE1:Total#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH4_START, nowtime); system(query); } /* Make queue graph */ sprintf(query, "rrdtool update natasha-queue.rrd %i:%i", nowtime, ginfo.queuestatus); system(query); if(!htm) { sprintf(query, "rrdtool graph %squeue1.gif --title=\"Items in queue (60 mins)\" --start %i --end %i DEF:Items=natasha-queue.rrd:Items:LAST LINE1:Items#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH1_START, nowtime); system(query); sprintf(query, "rrdtool graph %squeue2.gif --title=\"Items in queue(24 hours)\" --start %i --end %i DEF:Items=natasha-queue.rrd:Items:LAST LINE1:Items#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH2_START, nowtime); system(query); sprintf(query, "rrdtool graph %squeue3.gif --title=\"Items in queue (30 days)\" --start %i --end %i DEF:Items=natasha-queue.rrd:Items:LAST LINE1:Items#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH3_START, nowtime); system(query); sprintf(query, "rrdtool graph %squeue4.gif --title=\"Items in queue (365 days)\" --start %i --end %i DEF:Items=natasha-queue.rrd:Items:LAST LINE1:Items#FF0000 &", RRD_PATH, nowtime - RRD_GRAPH4_START, nowtime); system(query); } printf("Graphs done.\n"); } }