f3c8f315871e464a9106ec669c79d0fa14998d26
[ampy.git] / html / currentjson.php
1 <?php
2 $RRDFILE="/home/nirgal/ampy/power.rrd";
3
4 $info=rrd_lastupdate($RRDFILE);
5 if ($info === FALSE)
6         $result=[
7                 'last_update' => 'unknown',
8                 'watts' => 'unknown'
9         ];
10 else
11         $result=[
12                 'last_update' => $info['last_update'],
13                 'watts' => $info['data'][0]
14         ];
15 header("Content-Type: text/json");
16 echo(json_encode($result));
17 ?>