[rrd-users] CDEF options to generate night and day areas not working

marsel60 marsel60 at gmail.com
Tue Nov 17 19:33:48 CET 2015


Hello to everybody, this is my first post here and I'm a terrible newbi to
RRDTOOL. I'm trying to store and graph sensors data gathered by a RasPi;
everything is working fine BUT the CDEF part that should display night and
day areas is not working properly. With the code posted at the bottom I'm
obtaining "just" two areas, one for the night and another for the day BUT
i'm trying to plot ALSO the time that is between night and day! I tried to
verify what's wrong but I have no experience in that... for this reason I'm
asking an help by all of you... what's wrong? 
Thanks in advance guys for your valuable help.
Following the code:

DUSKHR=$(awk -F',' '{ print $1 }' /var/www/rrd-data/sunwait_nautical.txt |
cut -c 1-2)
DUSKMN=$(awk -F',' '{ print $1 }' /var/www/rrd-data/sunwait_nautical.txt |
cut -c 4-5)
DAWNHR=$(awk -F',' '{ print $2 }' /var/www/rrd-data/sunwait_nautical.txt |
cut -c 2-3)
DAWNMN=$(awk -F',' '{ print $2 }' /var/www/rrd-data/sunwait_nautical.txt |
cut -c 5-6)
SUNRISEHR=$(awk -F',' '{ print $1 }' /var/www/rrd-data/sunwait_civil.txt |
cut -c 1-2)
SUNRISEMN=$(awk -F',' '{ print $1 }' /var/www/rrd-data/sunwait_civil.txt |
cut -c 4-5)
SUNSETHR=$(awk -F',' '{ print $2 }' /var/www/rrd-data/sunwait_civil.txt |
cut -c 2-3)
SUNSETMN=$(awk -F',' '{ print $2 }' /var/www/rrd-data/sunwait_civil.txt |
cut -c 5-6)
# converting all times in seconds
SUNR=$(($SUNRISEHR * 3600 + $SUNRISEMN * 60))
SUNS=$(($SUNSETHR * 3600 + $SUNSETMN * 60))
DUSK=$(($DUSKHR * 3600 + $DUSKMN * 60))
DAWN=$(($DAWNHR * 3600 + $DAWNMN * 60))
#
## Graph for last 24 hours
/usr/bin/rrdtool graph /var/www/rrd-graph/temp1_daily.png \
-w 785 -h 240 -a PNG \
--slope-mode \
--color=SHADEB#9999CC \
--start -86400 --end now \
--font DEFAULT:9: \
--title "Daily internal temperature  -  Home Meteo Station" \
--watermark "`date`                 © Marco  - 2015" \
--lower-limit 0 \
--vertical-label "Temperature (°C)" \
--right-axis 1:0 \
--x-grid MINUTE:15:HOUR:1:MINUTE:120:0:%R \
--alt-y-grid --rigid \
--alt-autoscale-max \
DEF:temp=/var/www/rrd-data/meteostation.rrd:temp1:MAX \
CDEF:nightplus=LTIME,86400,%,$SUNR,LT,INF,LTIME,86400,%,$SUNS,GT,INF,UNKN,temp,*,IF,IF
\
CDEF:nightminus=LTIME,86400,%,$SUNR,LT,NEGINF,LTIME,86400,%,$SUNS,GT,NEGINF,UNKN,temp,*,IF,IF
\
CDEF:dusktilldawn=LTIME,86400,%,$DAWN,LT,INF,LTIME,86400,%,$DUSK,GT,INF,UNKN,temp,*,IF,IF
\
CDEF:dawntilldusk=LTIME,86400,%,$DAWN,LT,NEGINF,LTIME,86400,%,$DUSK,GT,NEGINF,UNKN,temp,*,IF,IF
\
AREA:dusktilldawn#FFFF80 \
AREA:dawntilldusk#FFFF80 \
AREA:nightplus#E0E0E0 \
AREA:nightminus#E0E0E0 \
LINE2:temp#000000:"Temperature (°C)" \
GPRINT:temp:LAST:"\tCurrent\: %2.2lf" \
GPRINT:temp:MIN:"Min\: %2.2lf" \
GPRINT:temp:AVERAGE:"Average\: %2.2lf" \
GPRINT:temp:MAX:"Max\: %2.2lf\t\t\t\n"



--
View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/CDEF-options-to-generate-night-and-day-areas-not-working-tp7583213.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.



More information about the rrd-users mailing list