I don't know if I should post it here but I have probably found a bug in Thold version 0.4.8. Correct me if I'm wrong.
Sometimes when script returns empty value or not numeric value (I now I should avoid it) Thold updates table thold_data table with "lastread"=0. Then the Lo trigger will almost always fire.
The problem is in polling.php: in all cases the input value is rounded by 4 digits. If $currentval is empty or not numeric such rounding always returns 0 instead of empty.
I modified the polling.php like this:
Code: Select all
function thold_poller_output ($rrd_update_array) {
...
...
switch ($t_item['data_type']) {
case 0:
if (is_numeric($currentval)) { ### added by Opornik ###
$currentval = round($currentval, 4);
}
break;
case 1:
if ($t_item['cdef'] != 0) {
$currentval = thold_build_cdef($t_item['cdef'], $currentval, $t_item['rra_id'], $t_item['data_id']);
}
if (is_numeric($currentval)) { ### added by Opornik ###
$currentval = round($currentval, 4);
}
break;
case 2:
if ($t_item['percent_ds'] != '') {
$currentval = thold_calculate_percent($t_item, $currentval, $rrd_reindexed);
}
if (is_numeric($currentval)) { ### added by Opornik ###
$currentval = round($currentval, 4);
}
break;
case 3:
if ($t_item['expression'] != '') {
$currentval = thold_calculate_expression($t_item, $currentval, $rrd_reindexed, $rrd_time_reindexed);
}
if (is_numeric($currentval)) { ### added by Opornik ###
$currentval = round($currentval, 4);
}
break;
}
### added by Opornik ###
if (!is_numeric($currentval)) {
$currentval = '';
}
######
db_execute("UPDATE thold_data SET tcheck=1, lastread='$currentval',
lasttime='" . date("Y-m-d H:i:s", $currenttime) . "',
oldvalue='" . $item[$t_item['name']] . "'
WHERE rra_id = " . $t_item['rra_id'] . "
AND data_id = " . $t_item['data_id']);
...
...