[rrd-users] rrdtool problem.

Jakub Drwal kubel at t15.ds.pwr.wroc.pl
Fri Dec 20 19:15:24 MET 2002



 Hello,

  I want to do some statistisc with rrd, so I started with (i think) easy 
example, system load. I write a script in perl, but it seems that sth
is wronk, since it desn't work correctly. Can you review it and give 
me some advices ?

 Jakub Drwal

---
source
---

#!/usr/local/bin/perl

use lib qw( /usr/local/rrdtool/lib/perl );

use RRDs;

my $db_dir="/some/dir";
my $db_file="system.rrd";
my $png_dir="/some/dir";

if (! -f $db_dir.$db_file or ! -w $db_dir.$db_file) {
RRDs::create($db_dir.$db_file,
             "--start",time(),
             "--step","300",
             "DS:sysload1:GAUGE:600:U:U",
             "DS:sysload5:GAUGE:600:U:U",
             "DS:sysload15:GAUGE:600:U:U",
             "RRA:AVERAGE:0.5:1:300");
my $ERROR=RRDs::error();
die "$0: unable to create $db_file': $ERROR\n" if $ERROR;

print("Created.\n");
exit(0);
}

#gatchering data...

$_=`uptime`;
s/[a-zA-Z:\ ]+//g;
@uptime=split(/,/);

RRDs::update($db_dir.$db_file,"N:$uptime[3]:$uptime[4]:$uptime[5]");
my $ERROR=RRDs::error();
die "$0: cannot update: $ERROR\n" if $ERROR;

$file=$db_dir.$db_file;

RRDs::graph("test.gif",
            "DEF:sload1=$file:sysload1:AVERAGE");

my $ERROR=RRDs::error();
die "$0: cannot make graph: $ERROR\n" if $ERROR;
-----
end-of-source
-----



---
Experience is that marvellous thing that enables you recognize a mistake
when you make it again.

--
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://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list