return $counter;
}
+/*
+ * Experimental function that uses rrd_graph to get lastest information
+ * This actually flushes the daemon... so it doesn't work
+ *
+function my_lastupdate_noflush() {
+ $info=rrd_graph( '-',
+ '--daemon', RRDSOCK,
+ 'DEF:watts='.RRDFILE.':watts:AVERAGE',
+ '-s' 'now - 5 seconds',
+ 'DEF:watts=/var/lib/rrdcached/db/power.rrd:watts:AVERAGE',
+ 'VDEF:last=watts,LAST',
+ 'PRINT:last:%lf'
+ );
+} */
+
/*
* Return all the information.
* Make sure you call ampy_flush_rrd_daemon() first if you need real time
<?php
require_once('config.php');
+#echo("getenv:".getenv('RRDCACHED_ADDRESS')."\n");
+#echo("env:".$_ENV['RRDCACHED_ADDRESS']."\n");
+
+#if (!putenv("RRDCACHED_ADDRESS=/var/run/rrdcached.sock")) # doesn't work :/
+# trigger_error("putenv failed!");
+#if (!apache_putenv("RRDCACHED_ADDRESS=/var/run/rrdcached.sock")) # doesn't work :/
+# trigger_error("apache_putenv failed!");
+#$_ENV['RRDCACHED_ADDRESS']='/var/run/rrdcached.sock';
+
+
$info=rrd_lastupdate(RRDFILE);
if ($info === FALSE)
echo("error in rrd_lastupdate: ".rrd_error());