web: small bug fix in the night.rrd timestamping

This commit is contained in:
Bart Van Der Meerssche 2009-09-24 21:52:51 +00:00
parent f45ef2f2fa
commit f40851ab3d
2 changed files with 5 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -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