From f40851ab3d950c4b76f818563ef28952c27491b4 Mon Sep 17 00:00:00 2001 From: Bart Van Der Meerssche Date: Thu, 24 Sep 2009 21:52:51 +0000 Subject: [PATCH] web: small bug fix in the night.rrd timestamping --- web/drupal/modules/logger/xmlrpc.inc | 6 +++--- web/drupal/modules/logger/xmlrpc1.inc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/drupal/modules/logger/xmlrpc.inc b/web/drupal/modules/logger/xmlrpc.inc index 54f5f38..be72f86 100644 --- a/web/drupal/modules/logger/xmlrpc.inc +++ b/web/drupal/modules/logger/xmlrpc.inc @@ -84,10 +84,10 @@ function _logger_measurement_add($logs) { $end = $start + 10800; // 3h time interval $command = $path->root ."/rrdtool fetch ". $path->base . $meter .".rrd AVERAGE -r 900 -s ". $start ." -e ". $end ." | tail -n 12 | awk -F': ' '{SUM += $2} END {print SUM/12}'"; $night = (float)shell_exec($command); //test shell_exec iso system - $command = $path->root .'/rrdtool update '. $path->night . $meter .'.rrd '. $timestamp .':'. $night; + $command = $path->root .'/rrdtool update '. $path->night . $meter .'.rrd '. $end .':'. $night; system($command, $return); if ($return == 0) { - watchdog_xmlrpc('logger.measurementAdd', 'successful update for night rrd: %command', array('%command' => $command), WATCHDOG_NOTICE); //debugging + watchdog_xmlrpc('logger.measurementAdd', 'successful update for night rrd: %command | midnight = %midnight', array('%command' => $command, '%midnight' => $midnight), WATCHDOG_NOTICE); //debugging } else { watchdog_xmlrpc('logger.measurementAdd', 'error updating night rrd: %command', array('%command' => $command), WATCHDOG_ERROR); //debugging @@ -115,4 +115,4 @@ function _logger_midnight($timestamp, $device) { // search for first $midnight < $timestamp while ($midnight > $timestamp) $midnight -= 86400; return $midnight; -} \ No newline at end of file +} diff --git a/web/drupal/modules/logger/xmlrpc1.inc b/web/drupal/modules/logger/xmlrpc1.inc index f930bc9..ee03d21 100644 --- a/web/drupal/modules/logger/xmlrpc1.inc +++ b/web/drupal/modules/logger/xmlrpc1.inc @@ -110,10 +110,10 @@ function _logger_measurement_add($auth, $logs) { $end = $start + 10800; // 3h time interval $command = $path->root ."/rrdtool fetch ". $path->base . $meter .".rrd AVERAGE -r 900 -s ". $start ." -e ". $end ." | tail -n 12 | awk -F': ' '{SUM += $2} END {print SUM/12}'"; $night = (float)shell_exec($command); //test shell_exec iso system - $command = $path->root .'/rrdtool update '. $path->night . $meter .'.rrd '. $timestamp .':'. $night; + $command = $path->root .'/rrdtool update '. $path->night . $meter .'.rrd '. $end .':'. $night; system($command, $return); if ($return == 0) { - watchdog_xmlrpc('logger.measurementAdd', 'successful update for night rrd: %command', array('%command' => $command), WATCHDOG_NOTICE); //debugging + watchdog_xmlrpc('logger.measurementAdd', 'successful update for night rrd: %command | midnight = %midnight', array('%command' => $command, '%midnight' => $midnight), WATCHDOG_NOTICE); //debugging } else { watchdog_xmlrpc('logger.measurementAdd', 'error updating night rrd: %command', array('%command' => $command), WATCHDOG_ERROR); //debugging