#!/bin/sh
echo "Content-type: image/png"
echo
D=/var/log/arexxd
current ()
{
Z=$(rrdtool fetch $1 AVERAGE -s-5min -r900 | grep : | grep -v nan | tail -1 | cut -d ' ' -f 2)
if [ -z "$Z" ] ; then
echo -n "---"
else
printf "%5.1f" "$Z"
fi
}
exec rrdtool graph - \
--start 'now-12h' \
--end 'now' \
--title "Temperature" \
-w 720 -h 600 \
-x MINUTE:10:HOUR:1:HOUR:2:0:%H:%M \
-y 5:1 \
--right-axis 1:0 --right-axis-format "%3.0lf" \
--units-exponent 0 --lower-limit -20 --upper-limit 40 --rigid \
--legend-position east \
--pango-markup \
DEF:c=$D/sensor-catarium.rrd:temp:AVERAGE \
DEF:u=$D/sensor-ursarium.rrd:temp:AVERAGE \
DEF:b=$D/sensor-balcony.rrd:temp:AVERAGE \
DEF:o=$D/sensor-outside.rrd:temp:AVERAGE \
DEF:t=$D/sensor-aquarium.rrd:temp:AVERAGE \
'AREA:c#cc7777' \
'AREA:u#7777cc' \
'AREA:b#cc77cc' \
'AREA:o#77cc77' \
'LINE2:c#cc0000:Catarium\n' \
'LINE2:u#0000cc:Ursarium\n' \
'LINE2:t#00cccc:Aquarium\n' \
'LINE2:b#cc00cc:Balcony\n' \
'LINE2:o#00cc00:Outside\n' \
'HRULE:0#0000ff' \
'COMMENT:\s' \
'COMMENT:\s' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-catarium.rrd)"' °C\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-ursarium.rrd)"' °C\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-aquarium.rrd)"' °C\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-balcony.rrd)"' °C\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-outside.rrd)"' °C\l' \