#!/bin/sh cd /home/1-wire || exit 1 if [ -f log/graph.lock ] then #echo "$0 (PID $$) aborted, last session is still running" >&2 exit 1 fi touch log/graph.lock export PATH=$PATH:/usr/local/bin xpoints=513 ypoints=140 db_in=db/temp_in.rrd db_out=db/temp_out.rrd db_server=db/temp_server.rrd dest=www graph() { local start title graph arg1 arg2 start=$1 title=$2 graph="$dest/temp-$start.png" arg1= arg2= #if [ "$title" = Yearly ] #then # arg1=_ # # arg2='CDEF:temp_in_cf_max=temp_in_cf_max_,1,POP' # # echo $arg1 # echo $arg2 #fi rrdtool graph "$graph.tmp" \ \ --imgformat PNG \ \ --width "$xpoints" \ --height "$ypoints" \ \ --start "-$start" \ \ --title "$title temperatures" \ --vertical-label '°C' \ \ --units-exponent 0 \ --units-length 5 \ \ --slope-mode \ --interlaced \ --alt-y-grid \ \ "DEF:temp_in=$db_in:temp:AVERAGE" \ "DEF:temp_in_cf_min=$db_in:temp:MIN" \ "DEF:temp_in_cf_max$arg1=$db_in:temp:MAX" \ \ "DEF:temp_out=$db_out:temp:AVERAGE" \ "DEF:temp_out_cf_min=$db_out:temp:MIN" \ "DEF:temp_out_cf_max=$db_out:temp:MAX" \ \ "DEF:temp_server=$db_server:temp:AVERAGE" \ "DEF:temp_server_cf_min=$db_server:temp:MIN" \ "DEF:temp_server_cf_max=$db_server:temp:MAX" \ \ $arg2 \ \ 'VDEF:temp_in_min=temp_in_cf_min,MINIMUM' \ 'VDEF:temp_in_max=temp_in_cf_max,MAXIMUM' \ 'VDEF:temp_in_avg=temp_in,AVERAGE' \ 'VDEF:temp_in_last=temp_in,LAST' \ \ 'VDEF:temp_out_min=temp_out_cf_min,MINIMUM' \ 'VDEF:temp_out_max=temp_out_cf_max,MAXIMUM' \ 'VDEF:temp_out_avg=temp_out,AVERAGE' \ 'VDEF:temp_out_last=temp_out,LAST' \ \ 'VDEF:temp_server_min=temp_server_cf_min,MINIMUM' \ 'VDEF:temp_server_max=temp_server_cf_max,MAXIMUM' \ 'VDEF:temp_server_avg=temp_server,AVERAGE' \ 'VDEF:temp_server_last=temp_server,LAST' \ \ 'COMMENT:\s' \ 'COMMENT:\s' \ 'COMMENT:\s' \ 'COMMENT: Min Max Avg Last' \ 'COMMENT:\s' \ 'COMMENT:\s' \ 'COMMENT:\s' \ \ 'LINE2:temp_in#DD3F4A:Indoor ' \ 'GPRINT:temp_in_min:%6.1lf' \ 'GPRINT:temp_in_max:%6.1lf' \ 'GPRINT:temp_in_avg:%6.1lf' \ 'GPRINT:temp_in_last:%6.1lf\n' \ \ 'LINE2:temp_out#3F4ADD:Outdoor ' \ 'GPRINT:temp_out_min:%6.1lf' \ 'GPRINT:temp_out_max:%6.1lf' \ 'GPRINT:temp_out_avg:%6.1lf' \ 'GPRINT:temp_out_last:%6.1lf\n' \ \ 'LINE2:temp_server#4ADD3F:Server corner' \ 'GPRINT:temp_server_min:%6.1lf' \ 'GPRINT:temp_server_max:%6.1lf' \ 'GPRINT:temp_server_avg:%6.1lf' \ 'GPRINT:temp_server_last:%6.1lf\n' \ \ 'COMMENT:\s' \ 'COMMENT:\s' \ 'COMMENT:\s' \ "COMMENT: `date '+%Y-%m-%d %H\:%M\:%S GMT%z/%Z'`" \ \ > /dev/null && \ \ mv "$graph.tmp" "$graph" || \ exit 1 } graph 1d Daily graph 1w Weekly graph 1m Monthly graph 1y Yearly graph 10y Decennary sh graph-out.sh rm log/graph.lock