#!/usr/bin/perl -w use CGI ; my $q = new CGI ; my $end = "" ; $end = " --end \'-".$q->param("end")."days\'" if $q->param("end") ; my $start = "" ; $start = " --start \'end -".$q->param("duration")."days \'" if $q->param("duration") ; if ( exists $ARGV[0] ) { $start = " --start \'end -1days \'" if $ARGV[0] eq "DAY" ; $start = " --start \'end -7days \'" if $ARGV[0] eq "WEEK" ; $start = " --start \'end -31days \'" if $ARGV[0] eq "MONTH" ; $start = " --start \'end -366days \'" if $ARGV[0] eq "YEAR" ; } print "Content-type: image/gif\n" ; #print "Expires: ".gmtime(600+time())."\n" #print "Cache-Control: max-age=600\n" ; #print "Pragma: content=no-cache" ; print "\n" ; my %defs = ( "a0" => "CellarTemp0:MIN", "a1" => "CellarTemp1:MIN", "a2" => "CellarTemp2:MIN", "b0" => "CellarTemp0:AVERAGE", "b1" => "CellarTemp1:AVERAGE", "b2" => "CellarTemp2:AVERAGE", "c0" => "CellarTemp0:MAX", "c1" => "CellarTemp1:MAX", "c2" => "CellarTemp2:MAX", ) ; sub deffer() { return join(" ",map( "DEF:".$_."=/var/rrd//cellar.rrd:".$defs{$_},keys(%defs))) ; } my $cmd="/usr/bin/rrdtool graph - --imgformat GIF $start $end --title \"Temperature Detail\" --height 200 --width 600 --base 1000 --interlaced ".deffer() ; print `$cmd LINE2:b0#FFAA00:"Cellar Temperature" LINE2:b1#FF8800:"" LINE2:b2#FF0000:"Bottle" LINE1:a0#FFAA00:"" LINE1:a1#FF8800:"" LINE1:a2#FF0000:"" LINE1:c0#FFAA00:"" LINE1:c1#FF8800:"" LINE1:c2#FF0000:"" ` ;