NAME
RRD::Simple::Examples
EXAMPLES
Example 1: Basic Data Gathering Using vmstat
my $rrd = new RRD::Simple;
my @keys = ();
my %update = ();
open(PH,'-|',$cmd) || die "Unable to open file handle PH for command '$cmd': $!";
while (local $_ = <PH>) {
next if /---/;
s/^\s+|\s+$//g;
if (/\d+/ && @keys) {
@update{@keys} = split(/\s+/,$_);
} else { @keys = split(/\s+/,$_); }
}
close(PH) || die "Unable to close file handle PH for command '$cmd': $!";
my @cpukeys = splice(@keys,-4,4);
my %labels = (wa => 'IO wait', id => 'Idle', sy => 'System', us => 'User');
my $rrdfile = "vmstat-cpu.rrd";
$rrd->create($rrdfile, map { ($_ => 'GAUGE') } @cpukeys )
unless -f $rrdfile;
$rrd->update($rrdfile, map {( $_ => $update{$_} )} @cpukeys );
COPYRIGHT
Copyright 2005,2006 Nicola Worthington.
This software is licensed under The Apache Software License, Version 2.0.