# Simple datalogger for digitemp. # Christian Moen, 2007. # chr at syntaks dot org include ("config.php"); // First make one set of graphs for each sensor.. foreach ($sensors as $n=>$str) { // Hour Graph $command = $rrdtool.' graph '.$rrdImgDir.$n.'_hour.png --start -3600 '. 'DEF:d='.$rrdDir.$n.'.rrd:temp:AVERAGE '. 'LINE1:d'.$color[0].':"'.$sensors[$n].'" '. 'GPRINT:d:LAST:"Temp\:%1.2lf %s" '. 'GPRINT:d:MIN:"Min\:%1.2lf %s" '. 'GPRINT:d:MAX:"Max\:%1.2lf %s" '. '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); // Daily graph $command = $rrdtool.' graph '.$rrdImgDir.$n.'_day.png --start -160000 '. 'DEF:d='.$rrdDir.$n.'.rrd:temp:AVERAGE '. 'LINE1:d'.$color[0].':"'.$sensors[$n].'" '. 'GPRINT:d:LAST:"Temp\:%8.2lf %s" '. 'GPRINT:d:MIN:"Min\:%8.2lf %s" '. 'GPRINT:d:MAX:"Max\:%8.2lf %s" '. '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); // Weekly graph $command = $rrdtool.' graph '.$rrdImgDir.$n.'_week.png -s -1week '. 'DEF:d='.$rrdDir.$n.'.rrd:temp:AVERAGE '. 'LINE1:d'.$color[0].':"'.$sensors[$n].'" '. 'GPRINT:d:MIN:"Min\:%8.2lf %s" '. 'GPRINT:d:MAX:"Max\:%8.2lf %s" '. '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); // Monthly graph $command = $rrdtool.' graph '.$rrdImgDir.$n.'_month.png -s -1month '. 'DEF:d='.$rrdDir.$n.'.rrd:temp:AVERAGE '. 'LINE1:d'.$color[0].':"'.$sensors[$n].'" '. 'GPRINT:d:MIN:"Min\:%8.2lf %s" '. 'GPRINT:d:MAX:"Max\:%8.2lf %s" '. '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); // Yearly graph $command = $rrdtool.' graph '.$rrdImgDir.$n.'_year.png -s -1year '. 'DEF:d='.$rrdDir.$n.'.rrd:temp:AVERAGE '. 'LINE1:d'.$color[0].':"'.$sensors[$n].'" '. 'GPRINT:d:MIN:"Min\:%8.2lf %s" '. 'GPRINT:d:MAX:"Max\:%8.2lf %s" '. '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); } // Create a graph with all sensors, one graph for each time frame. $commands_all = array("hour"=>"--start -3600","day"=>"--start -160000","week"=>"-s -1week","month"=>"-s -1month","year"=>"-s -1year"); foreach ($commands_all as $name=>$time) { $command = $rrdtool.' graph '.$rrdImgDir.'all_'.$name.'.png '.$time.' '; foreach ($sensors as $n=>$str) { $command .= 'DEF:d'.$n.'='.$rrdDir.$n.'.rrd:temp:AVERAGE '; } foreach ($sensors as $n=>$str) { $command .= 'LINE1:d'.$n.$color[$n].':"'.$str.'" '; } $command .= '-h'.$y.' -w'.$x.' -y1:2 --color GRID#dddddd --color MGRID#aaaaaa'; shell_exec($command); } // Make index.html $index = '
';
$index .= '![]() Hour | '; $index .= ' | ';
$index .= '![]() Day | ';
$index .= '
';
$index .= '![]() Week | '; $index .= ' | ';
$index .= '![]() Month |
';
$index .= '![]() Year |