[FIX] thold 0.4.3-2

Support questions about the Threshold plugin

Moderators: Developers, Moderators

sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

[FIX] thold 0.4.3-2

Post by sodium »

Hi,

new thold code with the following fixes:

* Fix for empty baseline percentages
* added update function in autocreate (updates the ifAlias in the thold_data tables)

have fun with it

new version : http://forums.cacti.net/viewtopic.php?f=17&t=41781
Attachments
thold-0.4.3-3.tgz
this release fixes database.php (diff posted is ok only wrong file was in release)
(87.23 KiB) Downloaded 545 times
Last edited by sodium on Mon Feb 14, 2011 1:46 pm, edited 2 times in total.
All the problems of the world could be settled if people were only willing to think...
diggity
Posts: 7
Joined: Mon Jan 31, 2011 1:31 pm

Re: [FIX] thold 0.4.3-2

Post by diggity »

Thank you for the updated code.
* Fix for empty baseline percentages
It appears as though when I create a baseline thold template with only a deviation up value and click Save, the deviation down value automatically gets set to 0. I am guessing that is what was fixed. In my scenario, we don't want threshold to check deviation down at all. We only are looking for increases in the data. By having this field auto-set to zero, threshold now checking the deviation down. I noticed before this fix that if I clicked the thold tab, clicked the Edit Threshold button, unchecked the Template Propagate Enabled check box, changed the deviation up value and clicked save, the deviation down value (which was blank) gets auto-set to zero. We want to do this for certain devices where a different deviation up percentage make more sense. Again, we don't want to check the deviation down, and auto-setting the value to zero ends up causing the threshold to breach down fairly often. Is there a way to get both of those options updated so the value boxes remain blank and do not auto-set a value?

I appreciate the excellent work you've done!
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

diggity wrote:It appears as though when I create a baseline thold template with only a deviation up value and click Save, the deviation down value automatically gets set to 0. I am guessing that is what was fixed. I...
Yep that is right, other users pointed us to this and we fixed it...

I think we have to re-look at the ifAlias/ifDescription change in the thresholds (now fixed when autocreate is re-run) in our setup autocreate is run every night after autom8 has re-detected new "up"interfaces in the network... and all thresholds are template derived... you are the second person pointing at template propagation being disabled (and thus autocreate is not rerun - and as such alarm-texts are unreliable)
We have to look at hooking to the poller_recache events...

sodium
All the problems of the world could be settled if people were only willing to think...
diggity
Posts: 7
Joined: Mon Jan 31, 2011 1:31 pm

Re: [FIX] thold 0.4.3-2

Post by diggity »

Yep that is right, other users pointed us to this and we fixed it...
Since this is an issue for us, can you point me in the right direction as to where in the code this happens? I'd like to get this changed on our end so a blank deviation value doesn't auto-set a value and trigger an alarm.

Thanks!
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

these are the changes

Code: Select all

--- trunk/thold/includes/database.php	2011/01/27 22:37:00	31
+++ trunk/thold/includes/database.php	2011/01/27 22:37:51	32
@@ -131,6 +131,10 @@
 		api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php');
 		db_execute('UPDATE plugin_hooks SET status = 1 WHERE name=\'thold\'');
 		db_execute('ALTER TABLE thold_data ADD COLUMN bl_thold_valid INT UNSIGNED NOT NULL DEFAULT 0');
+		db_execute('ALTER TABLE thold_template MODIFY COLUMN bl_pct_down varchar(100)');
+		db_execute('ALTER TABLE thold_template MODIFY COLUMN bl_pct_up varchar(100)');
+		db_execute('ALTER TABLE thold_data MODIFY COLUMN bl_pct_down varchar(100)');
+		db_execute('ALTER TABLE thold_data MODIFY COLUMN bl_pct_up varchar(100)');
 		$e = strtolower(db_fetch_cell("SELECT `value` FROM settings WHERE `name` = 'thold_from_email'"));
 		if ($e == 'cacti@cactiusers.org') {
 			db_execute("UPDATE settings SET `value`='cacti@localhost' WHERE `name`='thold_from_email'");
@@ -162,8 +166,8 @@
 	$data['columns'][] = array('name' => 'thold_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0);
 	$data['columns'][] = array('name' => 'bl_enabled', 'type' => "enum('on','off')", 'NULL' => false, 'default' => 'off');
 	$data['columns'][] = array('name' => 'bl_ref_time_range', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
-	$data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
-	$data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
+	$data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'varchar(100)', 'NULL' => true);
+	$data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'varchar(100)', 'NULL' => true);
 	$data['columns'][] = array('name' => 'bl_fail_trigger', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
 	$data['columns'][] = array('name' => 'bl_fail_count', 'type' => 'int(11)', 'NULL' => true, 'unsigned' => true);
 	$data['columns'][] = array('name' => 'bl_alert', 'type' => 'int(2)', 'NULL' => false, 'default' => '0');
@@ -216,8 +220,8 @@
 	$data['columns'][] = array('name' => 'thold_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0);
 	$data['columns'][] = array('name' => 'bl_enabled', 'type' => "enum('on','off')", 'NULL' => false, 'default' => 'off');
 	$data['columns'][] = array('name' => 'bl_ref_time_range', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
-	$data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
-	$data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
+	$data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'varchar(100)', 'NULL' => true);
+	$data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'varchar(100)', 'NULL' => true);
 	$data['columns'][] = array('name' => 'bl_fail_trigger', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
 	$data['columns'][] = array('name' => 'bl_fail_count', 'type' => 'int(11)', 'NULL' => true, 'unsigned' => true);
 	$data['columns'][] = array('name' => 'bl_alert', 'type' => 'int(2)', 'NULL' => false, 'default' => '0');

--- trunk/thold/thold_templates.php	2011/01/27 22:37:00	31
+++ trunk/thold/thold_templates.php	2011/01/27 22:37:51	32
@@ -290,10 +290,10 @@
 		else
 			$save['bl_ref_time_range'] = 10800;
 	}
-	if (isset($_POST['bl_pct_down']) && $_POST['bl_pct_down'] != '')
-		$save['bl_pct_down'] = $_POST['bl_pct_down'];
-	if (isset($_POST['bl_pct_up']) && $_POST['bl_pct_up'] != '')
-		$save['bl_pct_up'] = $_POST['bl_pct_up'];
+
+	$save['bl_pct_down'] = $_POST['bl_pct_down'];
+	$save['bl_pct_up'] = $_POST['bl_pct_up'];
+	
 	if (isset($_POST['bl_fail_trigger']) && $_POST['bl_fail_trigger'] != '')
 		$save['bl_fail_trigger'] = $_POST['bl_fail_trigger'];
 	else {
@@ -576,7 +576,6 @@
 		'bl_ref_time_range' => array(
 			'friendly_name' => 'Time reference in the past',
 			'method' => 'drop_array',
-			'max_length' => 20,
 			'array' => $reference_types,
 			'default' => read_config_option('alert_bl_timerange_def'),
 			'description' => 'Specifies the point in the past (based on rrd resolution) that will be used as a reference',

All the problems of the world could be settled if people were only willing to think...
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

keep in mind that after you upgrade the code to 0.4.3-2 you have to upgrade the database (use ../plugins/thold/extras/upgrade.php) to alter the database.

Sodium
All the problems of the world could be settled if people were only willing to think...
User avatar
dragossto
Cacti User
Posts: 86
Joined: Tue May 15, 2007 5:24 am
Location: Romania
Contact:

Re: [FIX] thold 0.4.3-2

Post by dragossto »

Hello ,
I try your version of thold to see if it any difference for my error

still don't return the the value of $host("avg_time")

but i discover one little error on /include/polling.php
on line 309
$subject = read_config_option('thold_up_subject');
should be
$subject = read_config_option('thold_down_subject');

and one more touch , to replace
$host["availability"] whit round(($host["availability"]), 2)

look more easy to read the value only two decimal .

Thanks.
Cacti - 0.8.7h
Plugin Architecture - 3.0
Poller Type - SPINE 0.8.7g
Server Info - Linux 2.6.35.10 - Slackware 13.1
Web Server - Apache/2.2.17 (Unix) DAV/2 PHP 5.3.5
MySQL - 5.1.53 ;RRDTool - 1.4.5 ;SNMP - 5.6.1
Plugins
  • (tools - v0.3) (Thold - v0.4.6) (Ntop - v0.2) (Discovery - v1.2a) (Monitor - v1.2)
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

Are you telling me there are 2 things you want fixed and both are outside the thold code?

Sodium
All the problems of the world could be settled if people were only willing to think...
User avatar
dragossto
Cacti User
Posts: 86
Joined: Tue May 15, 2007 5:24 am
Location: Romania
Contact:

Re: [FIX] thold 0.4.3-2

Post by dragossto »

both it about thold code
to be more specific it about
polling.php ,

my problem, why thold don't return the average response time for host
noted whit <AVG_TIME> in thold plug in and the value returned should be $host["avg_time"]
thold return the value for $host["cur_time"] ,but don't want to return the average value

in cacti i see average value for host , but not in thold

Have a nice day.
Cacti - 0.8.7h
Plugin Architecture - 3.0
Poller Type - SPINE 0.8.7g
Server Info - Linux 2.6.35.10 - Slackware 13.1
Web Server - Apache/2.2.17 (Unix) DAV/2 PHP 5.3.5
MySQL - 5.1.53 ;RRDTool - 1.4.5 ;SNMP - 5.6.1
Plugins
  • (tools - v0.3) (Thold - v0.4.6) (Ntop - v0.2) (Discovery - v1.2a) (Monitor - v1.2)
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

can you give me an example of the output you want (and include the output you now have)

Sodium
All the problems of the world could be settled if people were only willing to think...
User avatar
dragossto
Cacti User
Posts: 86
Joined: Tue May 15, 2007 5:24 am
Location: Romania
Contact:

Re: [FIX] thold 0.4.3-2

Post by dragossto »

it not the problem the output

i make this update because thold return for avg_time null value
this it actually my problem , when i make upgrade i discover in this version the little error
whit down and up , whit notification on email

this it only fink i use from thold , to notice me about change of device from the network , if go down or up
and also to give me more info in email about the device that it monitor.

any way, i still don't find the reason for not returned me the the value for avg_time
i will try to make a new update from the svn

Thanks for your time.
Cacti - 0.8.7h
Plugin Architecture - 3.0
Poller Type - SPINE 0.8.7g
Server Info - Linux 2.6.35.10 - Slackware 13.1
Web Server - Apache/2.2.17 (Unix) DAV/2 PHP 5.3.5
MySQL - 5.1.53 ;RRDTool - 1.4.5 ;SNMP - 5.6.1
Plugins
  • (tools - v0.3) (Thold - v0.4.6) (Ntop - v0.2) (Discovery - v1.2a) (Monitor - v1.2)
sasifras
Cacti User
Posts: 58
Joined: Tue Nov 18, 2008 6:57 am

Re: [FIX] thold 0.4.3-2

Post by sasifras »

Btw, looking in the 0.4.3-2 code package for the ./includes/database.php file shows the following:

Code: Select all

grep bl_pct database.php 

        $data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
        $data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
        $data['columns'][] = array('name' => 'bl_pct_down', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
        $data['columns'][] = array('name' => 'bl_pct_up', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true);
In the "above" post, you indicated that these should be varchars by the patch output. You sure the package has the right database.php file in it? We're going to manually modify those lines and re-run the upgrade.php, but the DB was definitely still set to INT after we ran it.

We took your thold package, placed it in the thold directory, (backed up our files, of course), and uncompressed it.


EDIT:

Editting the database.php to to accurate to your above post and running the upgrade.php did fix the DB and that seems to work for both instances we had problems with. We're going to expand the testing a bit and if all is good, we'll likely be moving this code to prod.

Thank you for the help!
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

did something wrong in the release of 0.4.3-2 (wrong version of database.php) fixed in 0.4.3-3 :-)
All the problems of the world could be settled if people were only willing to think...
sasifras
Cacti User
Posts: 58
Joined: Tue Nov 18, 2008 6:57 am

Re: [FIX] thold 0.4.3-2

Post by sasifras »

No big deal, we just were all trying to figure out why it wasn't doing what we thought. Any other changes to -3 beyond the updated database.php?
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

addition of cli_autocreate.php for the rest same as 0.4.3-2
All the problems of the world could be settled if people were only willing to think...
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests