[rrd-developers] alternate update interface, updatev

Jake Brutlag jakeb at microsoft.com
Fri Apr 25 20:48:34 MEST 2003


I and others have expressed interest in a version of update which would
return information about which consolidated data points are generated
(written to disk) in response to a call to update. Well, I set aside
some time this week and implemented this feature. It order to avoid
confusing those that use update (and expect an integer return value), I
decided on a new command, updatev.

Here is the description from the doc (rrdupdate.pod):

This alternate version of B<update> takes the same arguments and
performs the same function. The I<v> stands for I<verbose>, which
describes the output returned. B<updatev> returns a list of any and all
consolidated data points (CDPs) written to disk as a result of the
invocation of update. The values are indexed by timestamp (time_t),
RRA (index number), and data source (name). Note that depending
on the arguments of the current and previous call to update, the
list may have no entries or a large number of entries.

This new interface leverages the existing scaffolding for rrd_info. I
also implemented the perl-shared interface. Here is a sample script:

#!/usr/local/bin/perl -w
# the updatev interface is not available in older versions of RRDs
use RRDs 1.1;

my ($ERR, $hashref);
# create an RRD
RRDs::create ("cookies.rrd","--start=957214000","--step=300",
              "DS:Cookie312:GAUGE:600:U:U",
              "DS:Cookie357:GAUGE:600:U:U",
              "DS:AllCookies:COMPUTE:Cookie312,Cookie357,+",
              "RRA:AVERAGE:0:1:4608",
              "RRA:AVERAGE:0:6:768");
$ERR=RRDs::error;
die "ERROR creating cookies.rrd: $ERR\n" if $ERR;

# conventional update
RRDs::update ("cookies.rrd","957214300:3908:3328");
$ERR=RRDs::error;
die "ERROR updating cookies.rrd: $ERR\n" if $ERR;

# update that returns a hash of CDPs
$hashref = RRDs::updatev ("cookies.rrd","957214600:4148:3363");
$ERR=RRDs::error;
die "ERROR updating cookies.rrd: $ERR\n" if $ERR;
foreach my $key (keys %$hashref) {
    print "$key = $$hashref{$key}\n";
}

Output:
[957214500]RRA[0]DS[AllCookies] = 7419.33333333333
[957214500]RRA[0]DS[Cookie357] = 3351.33333333333
[957214500]RRA[0]DS[Cookie312] = 4068
return_value = 0

Note the CDPs are indexed by time, RRA, and data source. Return_value is
the integer that conventional update would have returned. As always,
your comments and bug reports are welcome.

Jake Brutlag
Network Analyst
Microsoft MSN 

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



More information about the rrd-developers mailing list