[rrd-users] Calculating AVG, treating UNKNOWNs as zero

Derek Haynes derek.haynes at gmail.com
Mon Jul 30 20:54:36 CEST 2012


The AVG consolidation function excludes UNKNOWN values. Instead of
excluding them, I'd like to convert each UNKNOWN value to zero and
then generate the average.

Example use case: recording visits to a URL, updating once-per minute
(but only if any visits), and then calculating the throughput over a
given period.

Example ----

1-minute Average RRA. 1 second step:

rrdtool create test.rrd \
--start 1325376000 \
--step 1 \
DS:x:GAUGE:60:U:U \
RRA:AVERAGE:0.99:60:10080

Updates - 1 at Jan 1 00:01, another at Jan 1 00:30:

rrdtool update test.rrd \
1325376060:100 \
1325377799:U \
1325377800:25

...this means the values for the CDPs from 00:02 - 00:29 will be
UNKNOWNs. The 2nd update above forces the 3rd to be recorded.

XPORT - fetching at 30-minute step for hypothetical display across a
long time period:

rrdtool xport DEF:x=test.rrd:x:AVERAGE \
XPORT:x \
--start 1325376000 --end 1325377800 --step 1800

Result:

    <row><t>1325377800</t><v>6.2500000000e+01</v></row>

62.5 is the average. Instead, I'd like to get a value of 4.1667, which
represents the average over 30 minutes if the UNKNOWNs were zero (
100+25+28 zeros)/30.

Any ideas?

Derek

-- 
Derek Haynes
Scout Web Monitoring and Reporting ~ http://scoutapp.com
Blog ~ http://blog.scoutapp.com
415.871.7979



More information about the rrd-users mailing list