bug: triggering on empty or not numeric values

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
opornik
Posts: 15
Joined: Thu Apr 13, 2006 8:00 am
Location: Poland/Warsaw

bug: triggering on empty or not numeric values

Post by opornik »

Hi,
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']);
   ...
   ...
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: bug: triggering on empty or not numeric values

Post by TheWitness »

Ok, fixed just a bit differently in 0.4.9 just to be released. Thanks for the contrib!
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest