[rrd-users] rrd->update from an array of values

Steve Shipway s.shipway at auckland.ac.nz
Wed Oct 26 01:32:46 CEST 2011


> I've got a perl script using rrd::simple that queries a list of hosts and
> grabs several values.  I want to take that array and dice it up to populate
> the "rrd->update ( )" structure, but I can't seem to get it right.

This is just off the top of my head, but this should do what you're after, provided the RRD file actually has the specified datasource names in it.

# using RRDs
%values = { ds0=>$value0, ds1=>$value1, ds2=>$value2 };
$timestamp = 'N'; # or use a specific time
$rrdfilename = 'filename.rrd'; # must be already created
RRDs::update( $rrdfilename, '--template', (join ':',(keys %values)), 
"$timestamp:".(join ':',(map {$values{$_}?},(keys %values)))
);

# Or, using RRD::Simple
@values = ( "ds0:$value0","ds1:$value1","ds2:$value2");
%values = ();
foreach ( @values ) { $values{$1}=$2 if(/(\S+):(\S+)/); }
$rrd->update( %values );

Steve

Steve Shipway
ITS Unix Services Design Lead
University of Auckland, New Zealand
Floor 1, 58 Symonds Street, Auckland
Phone: +64 (0)9 3737599 ext 86487
DDI: +64 (0)9 924 6487
Mobile: +64 (0)21 753 189
Email: s.shipway at auckland.ac.nz
 Please consider the environment before printing this e-mail 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4928 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-users/attachments/20111025/06a5538d/attachment.bin 


More information about the rrd-users mailing list