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