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

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

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

...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 \
--start 1325376000 --end 1325377800 --step 1800



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 Haynes
Scout Web Monitoring and Reporting ~ http://scoutapp.com
Blog ~ http://blog.scoutapp.com

More information about the rrd-users mailing list