X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=include%2Fclasses%2Frrdstat.php-class;h=6eed1bf259c75360e3aab44cac1ed2cfc3a78df0;hp=9e2a747b9da4e41b5b6847f135f3025dc8437ee5;hb=579a80ebd0fdf1304f305b36058b9c8499d50a45;hpb=86ff8b911079d133c04f45ba8da182e2ef4ccda2 diff --git a/include/classes/rrdstat.php-class b/include/classes/rrdstat.php-class index 9e2a747..6eed1bf 100644 --- a/include/classes/rrdstat.php-class +++ b/include/classes/rrdstat.php-class @@ -138,9 +138,10 @@ class rrdstat { } } } - $output = array(); $return_var = null; - exec($create_cmd, $output, $return_var); - if ($return_var) { trigger_error('rrd create returned with value '.$return_var, E_USER_WARNING); } + $return = `$create_cmd 2>&1`; + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd create error: '.$return, E_USER_WARNING); + } else { $this->status = 'ok'; } } @@ -156,6 +157,8 @@ class rrdstat { $upvals = explode("\n", ob_get_contents()); ob_end_clean(); } + $walkfunc = create_function('&$val,$key', '$val = is_numeric($val)?$val:"U";'); + array_walk($upvals, $walkfunc); } else { foreach ($this->rrd_fields as $ds) { @@ -193,9 +196,13 @@ class rrdstat { } } $update_cmd = 'rrdtool update '.$this->rrd_file.' N:'.implode(':', $upvals); - $output = array(); $return_var = null; - exec($update_cmd, $output, $return_var); - if ($return_var) { trigger_error('rrd update returned with value '.$return_var, E_USER_WARNING); } + $return = `$update_cmd 2>&1`; + + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd update error: '.$return, E_USER_WARNING); + $success = false; + } + else { $success = true; } return ($return_var == 0); } @@ -216,7 +223,7 @@ class rrdstat { $return = `$fetch_cmd 2>&1`; if (strpos($return, 'ERROR') !== false) { - trigger_error('rrd fetch error: '.$return, E_USER_WARNING); + trigger_error($this->rrd_file.' - rrd fetch error: '.$return, E_USER_WARNING); $fresult = false; } else { @@ -457,7 +464,7 @@ class rrdstat { $return = `$graph_cmd 2>&1`; if (strpos($return, 'ERROR') !== false) { - trigger_error('rrd graph error: '.$return, E_USER_WARNING); + trigger_error($this->rrd_file.' - rrd graph error: '.$return, E_USER_WARNING); $return = $graph_cmd."\n\n".$return; } $return = 'file:'.$fname."\n".$return;