[mrtg] RPN question with high and low bounds

Mark Ter Morshuizen mark at itbox.co.za
Thu Mar 3 18:58:55 CET 2011


Hi,

I'm trying to do a graph that's red for too hot, green for OK, and blue for 
too cold. The script below sort of works but only if I overlay the red and 
blue over the green. I guess that's because of the CDEF:righttemp line doing 
the wrong thing. I only want it to show if the temperature is between $hi and 
$lo. It shows all the time. Why?

#!/bin/bash
cd /root/rrdtool
starttime=`date -d "119 minutes ago" +%s`
endtime=`date -d "1 minutes" +%s`
hi=30
lo=27
/usr/bin/rrdtool graph /var/www/temperature.png           \
 -w 600 -h 200 -v Temperature                             \
 --start $starttime --end $endtime                        \
 DEF:mytemp=temperature.rrd:temp:AVERAGE                  \
 CDEF:toohot=mytemp,$hi,GE,mytemp,UNKN,IF                 \
 CDEF:righttemp=mytemp,$lo,GT,$hi,LT,mytemp,UNKN,IF       \
 CDEF:toocold=mytemp,$lo,LE,mytemp,UNKN,IF                \
 HRULE:100#FF0000:"Boiling"                               \
 HRULE:0#0000FF:"Freezing"                                \
 LINE:righttemp#00AA00:"Temperature OK"                   \
 LINE:toohot#AA0000:"Too Hot"                             \
 LINE:toocold#0000AA:"Too Cold"

Thanks,
-- 
Mark Ter Morshuizen	



More information about the mrtg mailing list