5 $IMGFILE="/tmp/power.svg";
7 $hours = array_key_exists('h', $_REQUEST) ? (int)$_REQUEST['h'] : 0;
8 $minutes = array_key_exists('m', $_REQUEST) ? (int)$_REQUEST['m'] : 0;
9 if (!$hours && !$minutes)
14 "-s", "now-".$hours."h".$minutes."m",
15 "--width", "".IMGWIDTH,
16 "--height", "".IMGHEIGHT,
17 "--vertical-label", "watts",
19 "DEF:watts=".RRDFILE.":watts:AVERAGE",
20 #"DEF:maxwatts=".RRDFILE.":watts:MAX:step=".(60*(60*$hours)+$minutes),
21 #"DEF:maxwatts=".RRDFILE.":watts:MAX",
22 "CDEF:wh_raw=watts,".(float)($hours+$minutes/60.).",*",
23 "VDEF:watts_avg=watts,AVERAGE",
24 "VDEF:wh=wh_raw,AVERAGE",
26 "LINE:watts_avg#00FF00",
27 "GPRINT:watts_avg:Average %6.2lf %swatts",
28 "GPRINT:wh:Total %6.2lf %swh",
29 #"LINE:maxwatts#0000FF",
30 #"GPRINT:maxwatts:Max %6.2lf %sW",
33 /*header("Content-Type: text/plain");
34 foreach ($params as $param) echo(escapeshellarg($param)." ");
37 $result=rrd_graph("$IMGFILE", $params);
38 if ($result === FALSE) {
39 echo("Error in rrd_graph:<br>");
43 header("Content-Type: image/svg+xml");
44 header("Cache-Control: no-cache, max-age=0, must-revalidate");
45 header("Refresh: ".(60*(60*$hours)+$minutes)/IMGWIDTH);