[rrd-users] TRENDNAN: I'm doing it wrong

Charles Polisher cpolish at surewest.net
Mon Jun 6 01:56:19 CEST 2011


Dear all,

I'm spending a lot of quality time with the rrdtool docs and
tutorials these days, trying to wrap my head around both the
toolset and the analysis I'm trying to achieve.

First, I'm trying to graph a rolling average, each plotted
data-point being the average value of a time-series spanning the
preceeding 12 hours, the succeeding 12 hours, and the current
hour, so 25 hours.

Second, I want a de-trended plot of the same data, where the 25
hour average is the baseline value. I'm at a loss how to
approach it and in this matter G**gle is not being my friend.
(An exemplar: http://i.imgur.com/hnhdi.png ).

Probably I'm misusing TRENDNAN. I want the fucsia "baz"
(TRENDNANed) line to stretch all the way to the left-hand edge.
It's not cooperating.

The black dashed line is possibly the 25 hour rolling average
but the solid black "excursion" line (which overlays the green
"baz24hr" line) certainly isn't the desired excursion from the
trend.

Can someone point me in the right direction?

Best regards,
-- 
Charles Polisher

PS: Here's the output graph: http://i.imgur.com/EI8bq.png
PPS: Here's the code that generated it:

#!/bin/bash

# general constants defined in seconds

MINUTE=60
FIVE_MINUTE=$(( $MINUTE * 5 ))
HOUR=$(( $MINUTE * 60 ))
TWELVE_HOUR=$(( $HOUR * 12 ))
TWENTY_FOUR_HOUR=$(( $HOUR * 24 ))
TWENTY_FIVE_HOUR=$(( $HOUR * 25 ))
FORTY_EIGHT_HOUR=$(( $HOUR * 48 ))
WEEK=$(( TWENTY_FOUR_HOUR * 7))

# correction constant (empirical)
CORRECTION="123.456"

PALE_VIOLET=66FF66EF
PALE_GRAY=E0E0E0FF
MINT_GREEN=74C366FF
FUCSIA=FF00FFFF
BLACK="000000FF"

# Define plain time-series interval to graph
SERIES_1_END=1306796178
SERIES_1_START=$(( $SERIES_1_END - $TWENTY_FOUR_HOUR ))

# Define rolling-average time-series interval to graph
SERIES_2_END=1306796178
SERIES_2_START=$(( $SERIES_1_END - $FORTY_EIGHT_HOUR ))

# ccat1.rrd: heartbeat=600 seconds min=0 max=100 consolidation functions: AVERAGE, MAX, LAST
# ccat2.rrd: heartbeat=600 seconds min=0 max=100 consolidation functions: AVERAGE, MAX, LAST

#  RRDtool 1.4.5
/usr/local/rrdtool/bin/rrdtool graph - \
--imgformat=PNG \
--start=$SERIES_1_START \
--end=$SERIES_1_END \
--title='Test4' \
--rigid \
--alt-y-grid \
--units-exponent=0 \
--base=1000 \
--height=120 \
--width=500 \
--upper-limit='15000' \
--lower-limit='5000' \
--vertical-label='baz' \
--slope-mode \
--font TITLE:11: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
  \
DEF:foo_raw24hr="ccat1.rrd":CCAT1:AVERAGE:start=$SERIES_1_START:end=$SERIES_1_END \
DEF:bar_raw24hr="ccat2.rrd":CCAT2:AVERAGE:start=$SERIES_1_START:end=$SERIES_1_END \
  \
DEF:foo_raw48hr="ccat1.rrd":CCAT1:AVERAGE:start=$SERIES_2_START:end=$SERIES_2_END \
DEF:bar48hr="ccat2.rrd":CCAT2:AVERAGE:start=$SERIES_2_START:end=$SERIES_2_END \
  \
CDEF:baz24hr=foo_raw24hr,bar_raw24hr,-,$CORRECTION,* \
CDEF:baz_average12=baz24hr,$TWELVE_HOUR,TRENDNAN \
  \
CDEF:baz48hr=foo_raw48hr,bar48hr,-,$CORRECTION,* \
CDEF:baz_average25hr=baz48hr,$TWENTY_FIVE_HOUR,TRENDNAN \
  \
VDEF:baseline=baz_average25hr,AVERAGE \
CDEF:excursion=baz24hr,baseline,-,baseline,+ \
  \
AREA:baz24hr#$PALE_GRAY:"baz"  \
  \
LINE1:baz24hr#$MINT_GREEN:"baz24hr"  \
  \
LINE1:baz_average12#$FUCSIA:"baz avg 12" \
LINE1:baz_average25hr#$BLACK:"baz avg 25\n":dashes \
LINE2:excursion#$BLACK:"excursion" \
  \
GPRINT:baz24hr:LAST:'Cur24\:%8.0lf'  \
GPRINT:baz24hr:AVERAGE:"Avg24\:%8.0lf"  \
GPRINT:baz24hr:MIN:"Min24\:%8.0lf"  \
GPRINT:baz24hr:MAX:"Max24\:%8.0lf\n"  \
  \
GPRINT:baz_average25hr:LAST:"Cur25\:%8.0lf"  \
GPRINT:baz_average25hr:AVERAGE:"Avg25\:%8.0lf"  \
GPRINT:baz_average25hr:MIN:"Min25\:%8.0lf"  \
GPRINT:baz_average25hr:MAX:"Max25\:%8.0lf\n"  \
  \
> $0.png

#EOF



More information about the rrd-users mailing list