Tests on php-rrd not using rrdcahed
authorNirgal <contact_ampy@nirgal.com>
Wed, 16 Oct 2019 10:35:42 +0000 (10:35 +0000)
committerNirgal <contact_ampy@nirgal.com>
Wed, 16 Oct 2019 10:35:42 +0000 (10:35 +0000)
html/ampy.inc.php
html/lastupdate.php

index 050319f53c7db4fa051cf141fbcb21beea6a5b62..a99f7acb6526a331672fe183f2b89a44892d28a8 100644 (file)
@@ -79,6 +79,21 @@ function ampy_get_counter() {
        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
index 74a9479d345d4dbc61d729cf79a9b7cc5da0f456..b5b58a1a4bc1f7eabcd9e8df15faf687f0a67988 100644 (file)
@@ -4,6 +4,16 @@
 <?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());