[rrd-users] LAST always returning zero

Alex van den Bogaerdt alex at ergens.op.het.net
Fri Mar 7 04:59:18 CET 2008


On Thu, Mar 06, 2008 at 06:42:02PM -0600, Wes wrote:
> I have a data source defined as a GAUGE that is fairly static - it is always
> a zero or a one, and does not change frequently.  It represents the state of
> a queue - disabled or enabled.  When I graph it, the graph is always
> correct.  GPRINT MAX is always right.  However, LAST usually, but not always
> shows zero.

rrdtool create test.rrd \
	--step 10 \
	--start 1204844400 \
	DS:a:GAUGE:600:U:U \
	RRA:AVERAGE:0:1:10

rrdtool update test.rrd \
	1204844410:0 \
	1204844420:U \
	1204844430:0 \
	1204844440:1

rrdtool fetch test.rrd AVERAGE --start 1204844400 --end 1204844445

rrdtool graph test.png \
	--start 1204844400 --end 1204844445 \
	--lower-limit -1 \
	--upper-limit 3 \
	DEF:a=test.rrd:a:AVERAGE \
	CDEF:b=a,0,GT,0,1,IF \
	CDEF:c=b,2,* \
	CDEF:d=a,UN,-INF,UNKN,IF \
	CDEF:e=b,UN,INF,UNKN,IF \
	AREA:d#808000 \
	AREA:e#808000 \
	AREA:c#0000FF \
	LINE2:a#FF0000


The red line is your variable, either 0 or 1.
The blue area is the result of your CDEF. It is twice as high so that
it stands out.
The area below the X-axis is when your variable is unknown.
The same colour could appear above the X-axis should your CDEF
become unknown. However, it appears RRDtool's IF statement does
not handle NaN properly (or so I think. it seems to me it should
either branch to false, or it should propagate the NaN.)

The problem: when the original data is unknown, IF branches to true,
and your CDEF returns 0.

Solution for you: do not end your graph 'now'. Find the last update
time, round down to the nearest multiple of your step size, and use
that as your end.  For instance: --end $(($(date +%s)/10*10))

HTH
-- 
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/



More information about the rrd-users mailing list