I discovered (belatedly) that my weather plotting graphs hadn’t updated in forever — a problem with how the data was expected: something changed in rrdtool and I never noticed when it stopped working — and while I was fixing them, I decided to take a stab at moving the hits/errors graphing from mrtg to rrdtool.
So I edited my small script from a few days ago. (It’s not all the useful with just two datapoints since that’s all mrtg provides: I haven’t decided yet what to add as additional data for this but I do have some ideas for different system graphs. Watch this space.)
Then I created an rrd data file:
rrdtool create httpd.rrd –step 300
DS:hits:GAUGE:600:0:100000 RRA:AVERAGE:0.5:1:1:1200 RRA:MAX:0.5:12:2400: RRA:MIN:0.5:12:2400
DS:errs:GAUGE:600:0:100000 RRA:AVERAGE:0.5:1:1:1200 RRA:MAX:0.5:12:2400: RRA:MIN:0.5:12:2400
RTFM for more information on how this works.
Then the data collection and updating needs to be managed:
#!/bin/sh
cd /usr/local/etc/rrdtool/
/usr/home/paul/bin/hitrrd.pl > httpd.out
/usr/local/bin/rrdtool update httpd.rrd `cat httpd.out`
rrdtool graph httpd.png –title “httpd hits and errors per minute ” -s -3days
DEF:hits=httpd.rrd:hits:AVERAGE DEF:errors=httpd.rrd:errs:AVERAGE
AREA:hits#00FF00:”hits” LINE2:errors#FF0000:”errors”
And that’s it: if you like, you can make multiple graphs for different periods (like mrtg does by default) by repeating the last statement and adjusting the output file and the interval to be graphed.
The results are here. And the full script that generates four graphs is below. I leave migrating data from mrtg to rrdtool with the attendant alterations to the internals of an rrd file as an exercise for the reader but with these hints: log2rrd and rrdtool tune.
#!/bin/sh
cd /usr/local/etc/rrdtool/
/usr/home/paul/bin/hitrrd.pl > httpd.out
/usr/local/bin/rrdtool update httpd.rrd `cat httpd.out`
rrdtool graph httpd.png –title “httpd hits and errors per minute: today” -s -3days DEF:hits=httpd.rrd:hits:AVERAGE DEF:errors=httpd.rrd:errs:AVERAGE AREA:hits#00FF00:”hits” LINE2:errors#FF0000:”errors”
rrdtool graph httpd-week.png –title “httpd hits and errors per minute: this week” -s -7days DEF:hits=httpd.rrd:hits:AVERAGE DEF:errors=httpd.rrd:errs:AVERAGE AREA:hits#00FF00:”hits” LINE2:errors#FF0000:”errors”
rrdtool graph httpd-month.png –title “httpd hits and errors per minute: this month” -s -30days DEF:hits=httpd.rrd:hits:AVERAGE DEF:errors=httpd.rrd:errs:AVERAGE AREA:hits#00FF00:”hits” LINE2:errors#FF0000:”errors”
rrdtool graph httpd-year.png –title “httpd hits and errors per minute: this year” -s -365days DEF:hits=httpd.rrd:hits:AVERAGE DEF:errors=httpd.rrd:errs:AVERAGE AREA:hits#00FF00:”hits” LINE2:errors#FF0000:”errors”