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

Dayton Jones jones.dayton at gmail.com
Wed Oct 26 02:07:54 CEST 2011

Ah..thanks, yes that did it.

----- Original Message -----
From: "Steve Shipway" <s.shipway at auckland.ac.nz>
To: "Dayton Jones" <jones.dayton at gmail.com>
Cc: rrd-users at lists.oetiker.ch
Sent: Tuesday, October 25, 2011 4:32:46 PM
Subject: RE: [rrd-users] rrd->update from an array of values

> 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 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 

More information about the rrd-users mailing list