}
}
}
- $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'; }
}
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";');
+ array_walk($upvals, $walkfunc);
}
else {
foreach ($this->rrd_fields as $ds) {
$upvals[] = is_null($val)?'U':$val;
}
}
- $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 = 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);
+ $success = false;
+ }
+ else { $success = true; }
return ($return_var == 0);
}
$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 {
$duration = isset($gconf['duration'])?$gconf['duration']:396*86400; // 365+31 days
$slice = isset($gconf['slice'])?$gconf['slice']:86400; // 1 day
// vertical lines at month borders
- $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01')).'#FF0000';
- $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01').' -1 year').'#FF0000';
+ $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01 12:00:00')).'#FF0000';
+ $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01 12:00:00').' -1 year').'#FF0000';
}
else {
$duration = isset($gconf['duration'])?$gconf['duration']:$this->rrd_step*500; // 500 steps
$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;