[rrd-users] Help on RRDTOO monitoring cpu loadavg needed!

"CHEW YEW CHOONG" 055919 at mis.nagaokaut.ac.jp
Sat Sep 3 01:19:09 MEST 2005


 Hi there,
 
 Im learning perl and rrdtool now. I try to make
 rrdtool to monitoring cpu loadavg. Everythings seems
 working (rrd db created, updated, rrd images created,
 updated. i check with doing a ls -l and compare the
 timestamp on those files).
 
 However, the is only one problem that screw the whole
 things -- the graph is blank wiht no line :(
 
 I tried many times but still not able to get it solve.
 Thus, im posting my script here and hope someone can
 help me.
 
> # cat rrd_cpu.pl
> #!/usr/bin/perl
> use RRDs;
> my $rrd = '/var/www/htdocs/rrd_db';
> my $img = '/var/www/htdocs/rrd_images';
>   if (! -e "$rrd/cpu.rrd") {
>     RRDs::create "$rrd/cpu.rrd",
>       "-s 300",
>       "DS:1min:GAUGE:600:U:U",
>       "DS:5min:GAUGE:600:U:U",
>       "DS:15min:GAUGE:600:U:U",
>       "RRA:AVERAGE:0.5:1:576",
>       "RRA:AVERAGE:0.5:6:672",
>       "RRA:AVERAGE:0.5:24:732",
>       "RRA:AVERAGE:0.5:144:1460";
>     }
>     my $min1 = `cat /proc/loadavg | cut -d" " -f1`;
>     my $min5 = `cat /proc/loadavg | cut -d" " -f2`;
>     my $min15 = `cat /proc/loadavg | cut -d" " -f3`;
> 
>     RRDs::update "$rrd/cpu.rrd",
>       "-t", "1min:5min:15min",
>       "N:$min1:$min5:$min15";
> 
>     RRDs::graph "$img/cpu-day.png",
>       "--lazy",
>       "-s -1day",
>       "-t CPU information :: day",
>       "-h", "120", "-w", "600",
>       "-a", "PNG",
>       "-v Load AVG %",
>       "DEF:imin1=$rrd/cpu.rrd:1min:AVERAGE",
>       "DEF:imin5=$rrd/cpu.rrd:5min:AVERAGE",
>       "DEF:imin15=$rrd/cpu.rrd:15min:AVERAGE",
>       "LINE2:imin1#ff0000:1min",
>       "LINE2:imin5#009f32:5min",
>       "LINE2:imin15#0000ff:15min";
> 
>         if ($ERROR = RRDs::error) { print "$0: unable to generate cpu graph: $ERROR\n"; }
> }
 
 Thanks in advance.



--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list