projects
/
php-utility-classes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
if eval returns nothing, leave array empty; in that case, don't update
[php-utility-classes.git]
/
include
/
classes
/
rrdstat.php-class
diff --git
a/include/classes/rrdstat.php-class
b/include/classes/rrdstat.php-class
index 55ffaec9d380e2ac7099597ddfb7757a92c91149..15cca53b77b2b86af2e9668862e19b6a9eaef7a9 100644
(file)
--- a/
include/classes/rrdstat.php-class
+++ b/
include/classes/rrdstat.php-class
@@
-154,9
+154,12
@@
class rrdstat {
if (!is_null($evalcode)) {
ob_start();
eval($evalcode);
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();
}
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) {
}
else {
foreach ($this->rrd_fields as $ds) {
@@
-193,8
+196,11
@@
class rrdstat {
$upvals[] = is_null($val)?'U':$val;
}
}
$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);
if (strpos($return, 'ERROR') !== false) {
trigger_error($this->rrd_file.' - rrd update error: '.$return, E_USER_WARNING);