if eval returns nothing, leave array empty; in that case, don't update
authorrobert <robert>
Fri, 13 May 2005 19:40:26 +0000 (19:40 +0000)
committerrobert <robert>
Fri, 13 May 2005 19:40:26 +0000 (19:40 +0000)
include/classes/rrdstat.php-class

index 6eed1bf259c75360e3aab44cac1ed2cfc3a78df0..15cca53b77b2b86af2e9668862e19b6a9eaef7a9 100644 (file)
@@ -154,7 +154,8 @@ class rrdstat {
       if (!is_null($evalcode)) {
         ob_start();
         eval($evalcode);
-        $upvals = explode("\n", ob_get_contents());
+        $ret = ob_get_contents();
+        if (strlen($ret)) { $upvals = explode("\n", $ret); }
         ob_end_clean();
       }
       $walkfunc = create_function('&$val,$key', '$val = is_numeric($val)?$val:"U";');
@@ -195,8 +196,11 @@ class rrdstat {
         $upvals[] = is_null($val)?'U':$val;
       }
     }
-    $update_cmd = 'rrdtool update '.$this->rrd_file.' N:'.implode(':', $upvals);
-    $return = `$update_cmd 2>&1`;
+    $return = null;
+    if (count($upvals)) {
+      $update_cmd = 'rrdtool update '.$this->rrd_file.' N:'.implode(':', $upvals);
+      $return = `$update_cmd 2>&1`;
+    }
 
     if (strpos($return, 'ERROR') !== false) {
       trigger_error($this->rrd_file.' - rrd update error: '.$return, E_USER_WARNING);