#!/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 "%4.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:g=$D/sensor-garage.rrd:temp:AVERAGE \
DEF:u=$D/sensor-ursarium.rrd:temp:AVERAGE \
DEF:c=$D/sensor-catarium.rrd:temp:AVERAGE \
DEF:m=$D/sensor-machinarium.rrd:temp:AVERAGE \
DEF:a=$D/sensor-aquarium.rrd:temp:AVERAGE \
'AREA:u#7777cc' \
'AREA:m#77cc77' \
'AREA:c#cc77cc' \
'AREA:g#cc7777' \
'LINE2:g#cc0000:Garage\n' \
'LINE2:u#0000cc:Ursarium\n' \
'LINE2:a#00cccc:Aquarium\n' \
'LINE2:c#cc00cc:Catarium\n' \
'LINE2:m#00cc00:Machinarium\n' \
'HRULE:0#0000ff' \
'COMMENT:\s' \
'COMMENT:\s' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-garage.rrd)"'\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-ursarium.rrd)"'\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-aquarium.rrd)"'\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-catarium.rrd)"'\l' \
'COMMENT:\s' \
'COMMENT:'"$(current $D/sensor-machinarium.rrd)"'\l' \