[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

Re: [FIX] thold 0.4.3-2

Post by sodium »

dragossto wrote: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
.
found it :-) in the code AVG_TIME was misspelled as AVR_TIME .
fixed it in our trunk (should be in the next release)
in the mean time you can change the settings in the GUI into AVR_TIME (or fix the 2 lines in the polling.php)

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 »

:)) ,
you have perfect right
i'm not see that :-?
tested and now work

the diff below

Code: Select all

--- polling.original.php        2011-01-12 17:38:19.000000000 +0200
+++ polling.php 2011-02-02 23:10:36.000000000 +0200
@@ -255,19 +255,17 @@
                                        $msg = str_replace('<DESCRIPTION>', $host['description'], $msg);
                                        $msg = str_replace('<UPTIME>', $snmp_uptime, $msg);
                                        $msg = str_replace('<UPTIMETEXT>', $uptimelong, $msg);
-
                                        $msg = str_replace('<DOWNTIME>', $downtimemsg, $msg);
                                        $msg = str_replace('<MESSAGE>', '', $msg);
                                        $msg = str_replace('<DOWN/UP>', 'UP', $msg);
-
                                        $msg = str_replace('<SNMP_HOSTNAME>', $snmp_hostname, $msg);
                                        $msg = str_replace('<SNMP_LOCATION>', $snmp_location, $msg);
                                        $msg = str_replace('<SNMP_CONTACT>', $snmp_contact, $msg);
                                        $msg = str_replace('<SNMP_SYSTEM>', html_split_string($snmp_system), $msg);
                                        $msg = str_replace('<LAST_FAIL>', $host["status_fail_date"], $msg);
-                                       $msg = str_replace('<AVAILABILITY>', $host["availability"] . '%', $msg);
-                                       $msg = str_replace('<CUR_TIME>', $host["cur_time"], $msg);
-                                       $msg = str_replace('<AVR_TIME>', $host["avg_time"], $msg);
+                                       $msg = str_replace('<AVAILABILITY>', round(($host["availability"]), 2) . ' %', $msg);
+                                       $msg = str_replace('<CUR_TIME>', round(($host["cur_time"]), 2), $msg);
+                                       $msg = str_replace('<AVR_TIME>', round(($host["avg_time"]), 2), $msg);
                                        $msg = str_replace('<NOTES>', $host["notes"], $msg);
                                        $msg = str_replace("\n", '<br>', $msg);
                                        if ($alert_email == '') {
@@ -306,7 +304,7 @@
                                $downtimemsg = $downtime_seconds . "s ";
                        }

-                       $subject = read_config_option('thold_up_subject');
+                       $subject = read_config_option('thold_down_subject');
                        if ($subject == '') {
                                $subject = 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN';
                        }
@@ -331,9 +329,9 @@
                        $msg = str_replace('<SNMP_CONTACT>', '', $msg);
                        $msg = str_replace('<SNMP_SYSTEM>', '', $msg);
                        $msg = str_replace('<LAST_FAIL>', $host["status_fail_date"], $msg);
-                       $msg = str_replace('<AVAILABILITY>', $host["availability"], $msg);
+                       $msg = str_replace('<AVAILABILITY>', round(($host["availability"]), 2) . ' %', $msg);
                        $msg = str_replace('<CUR_TIME>', '', $msg);
-                       $msg = str_replace('<AVR_TIME>', $host["avg_time"], $msg);
+                       $msg = str_replace('<AVR_TIME>', round(($host["avg_time"]), 2), $msg);
                        $msg = str_replace('<NOTES>', $host["notes"], $msg);
                        $msg = str_replace("\n", '<br>', $msg);
                        if ($alert_email == '') {
and the change for description it file settings.php
in line 207

i'm em a little angry because not see that
i even look in host.php from cacti to see how it declare there
and was correct , but that basic check i don't look :(

Thanks for your time.
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)
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 »

i make one extra modification , possibility to have different message
for system down ,or system up . i put the diff below
if will putted in svn i will be more than happy :)
also i attach this two files whit modification

Code: Select all

--- polling.original.php        2011-01-12 17:38:19.000000000 +0200
+++ polling.php 2011-02-02 23:56:45.000000000 +0200
@@ -246,7 +246,7 @@
                                        $subject = str_replace('<DOWN/UP>', 'UP', $subject);
                                        $subject = strip_tags($subject);

-                                       $msg = read_config_option('thold_down_text');
+                                       $msg = read_config_option('thold_up_text');
                                        if ($msg == '') {
                                                $msg = 'Host: <DESCRIPTION> (<HOSTNAME>)<br>Status: <DOWN/UP><br>Message: <MESSAGE><br><br>Uptime: <UPTIMETEXT><br>Availiability: <AVAILABILITY><br>Response: <CUR_TIME> ms<br>Down Since: <LAST_FAIL><br>NOTE: <NOTES>';
                                        }
@@ -255,19 +255,17 @@
                                        $msg = str_replace('<DESCRIPTION>', $host['description'], $msg);
                                        $msg = str_replace('<UPTIME>', $snmp_uptime, $msg);
                                        $msg = str_replace('<UPTIMETEXT>', $uptimelong, $msg);
-
                                        $msg = str_replace('<DOWNTIME>', $downtimemsg, $msg);
                                        $msg = str_replace('<MESSAGE>', '', $msg);
                                        $msg = str_replace('<DOWN/UP>', 'UP', $msg);
-
                                        $msg = str_replace('<SNMP_HOSTNAME>', $snmp_hostname, $msg);
                                        $msg = str_replace('<SNMP_LOCATION>', $snmp_location, $msg);
                                        $msg = str_replace('<SNMP_CONTACT>', $snmp_contact, $msg);
                                        $msg = str_replace('<SNMP_SYSTEM>', html_split_string($snmp_system), $msg);
                                        $msg = str_replace('<LAST_FAIL>', $host["status_fail_date"], $msg);
-                                       $msg = str_replace('<AVAILABILITY>', $host["availability"] . '%', $msg);
-                                       $msg = str_replace('<CUR_TIME>', $host["cur_time"], $msg);
-                                       $msg = str_replace('<AVR_TIME>', $host["avg_time"], $msg);
+                                       $msg = str_replace('<AVAILABILITY>', round(($host["availability"]), 2) . ' %', $msg);
+                                       $msg = str_replace('<CUR_TIME>', round(($host["cur_time"]), 2), $msg);
+                                       $msg = str_replace('<AVR_TIME>', round(($host["avg_time"]), 2), $msg);
                                        $msg = str_replace('<NOTES>', $host["notes"], $msg);
                                        $msg = str_replace("\n", '<br>', $msg);
                                        if ($alert_email == '') {
@@ -306,7 +304,7 @@
                                $downtimemsg = $downtime_seconds . "s ";
                        }

-                       $subject = read_config_option('thold_up_subject');
+                       $subject = read_config_option('thold_down_subject');
                        if ($subject == '') {
                                $subject = 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN';
                        }
@@ -331,9 +329,9 @@
                        $msg = str_replace('<SNMP_CONTACT>', '', $msg);
                        $msg = str_replace('<SNMP_SYSTEM>', '', $msg);
                        $msg = str_replace('<LAST_FAIL>', $host["status_fail_date"], $msg);
-                       $msg = str_replace('<AVAILABILITY>', $host["availability"], $msg);
+                       $msg = str_replace('<AVAILABILITY>', round(($host["availability"]), 2) . ' %', $msg);
                        $msg = str_replace('<CUR_TIME>', '', $msg);
-                       $msg = str_replace('<AVR_TIME>', $host["avg_time"], $msg);
+                       $msg = str_replace('<AVR_TIME>', round(($host["avg_time"]), 2), $msg);
                        $msg = str_replace('<NOTES>', $host["notes"], $msg);
                        $msg = str_replace("\n", '<br>', $msg);
                        if ($alert_email == '') {

Code: Select all

--- settings.original.php       2011-01-12 17:38:19.000000000 +0200
+++ settings.php        2011-02-03 00:18:03.000000000 +0200
@@ -195,6 +195,14 @@
                        'max_length' => 255,
                        'default' => 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN',
                        ),
+               'thold_down_text' => array(
+                       'friendly_name' => 'Down Host Message',
+                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVR_TIME&#062 &#060NOTES&#062',
+                       'method' => 'textarea',
+                       'textarea_rows' => '5',
+                       'textarea_cols' => '80',
+                       'default' => 'Host: <DESCRIPTION> (<HOSTNAME>)<br>Status: <DOWN/UP><br>Message: <MESSAGE><br><br>Uptime: <UPTIME> (<UPTIMETEXT>)<br>Availiability: <AVAILABILITY><br>Response: <CUR_TIME> ms<br>Down Since: <LAST_FAIL><br>NOTE: <NOTES>',
+                       ),
                'thold_up_subject' => array(
                        'friendly_name' => 'Recovering Host Subject',
                        'description' => 'This is the email subject that will be used for Recovering Host Messages.',
@@ -202,14 +210,14 @@
                        'max_length' => 255,
                        'default' => 'Host Notice: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state',
                        ),
-               'thold_down_text' => array(
-                       'friendly_name' => 'Down Host Message',
-                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062',
+               'thold_up_text' => array(
+                       'friendly_name' => 'Recovering Host Message',
+                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVR_TIME&#062 &#060NOTES&#062',
                        'method' => 'textarea',
                        'textarea_rows' => '5',
                        'textarea_cols' => '80',
                        'default' => 'Host: <DESCRIPTION> (<HOSTNAME>)<br>Status: <DOWN/UP><br>Message: <MESSAGE><br><br>Uptime: <UPTIME> (<UPTIMETEXT>)<br>Availiability: <AVAILABILITY><br>Response: <CUR_TIME> ms<br>Down Since: <LAST_FAIL><br>NOTE: <NOTES>',
-                       ),
+               ),
                'thold_from_email' => array(
                        'friendly_name' => 'From Email Address',
                        'description' => 'This is the email address that the threshold will appear from.',
the reason for doing this , it because i have different message body

For down like this
System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVR_TIME> ms<br>System availability: <AVAILABILITY><br>Last date going DOWN : <LAST_FAIL><br>Host had been up for: <DOWNTIME><br>NOTE: <NOTES>
And for up like this
Host: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state<br>System status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVR_TIME> ms<br>System availability: <AVAILABILITY><br>Last time see system UP: <LAST_FAIL><br>Host had been down for: <DOWNTIME><br><br>Snmp Info:<br>Name - <SNMP_HOSTNAME><br>Location - <SNMP_LOCATION><br>Uptime - <UPTIMETEXT> (<UPTIME> ms)<br>System - <SNMP_SYSTEM><br><br>NOTE: <NOTES>
Attachments
includes.zip
polling.php and stting.php
(7.47 KiB) Downloaded 141 times
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 »

Thanks, I'll merge it in our trunk.
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 »

I've noticed one small detail that may be nice to have corrected. When you click on Console -> Threshold Templates, this screen lists all the templates built along with other various values. It appears the High, Low and Trigger count values don't pull the baseline values for baseline tholds, but instead pull the values from the High/Low. So when I create a Baseline Template, (Deviation up: 10; Deviation down: <blank>; Trigger Count: 3) and click save, the threshold template screen says the Up and Down are blank, and the Trigger is 1. If I edit the thold, and make it High/Low and set the High to 20, Low leave blank, Trigger duration to 10 and click save, I now see on the threshold templates screen that my thold has a high of 20, low is blank, and trigger is 10 minutes. Now, I'll go back and change my thold back to baseline and I continue to see the values I set for High/Low except the Trigger will be 2 instead of 10 minutes.

Thanks for all your hard work!
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 sodium

A new update from me :)
Fixed a minor error, one new line added in polling.php whit snmp_uptime=''

In the update it about possibility to send, or not for one host email whit up and down
or
To send email for certain host to another email address
Also , if it putted one (ore more) email address in the box for email and the option to send email it disable
will send email only to specified email in the box

This it maid , by creating in the host database 2 new columns
thold_send_email and thold_host_email

Till now , i don't discover any errors

the update it work only
if execute from CLI from directory extras

Code: Select all

php upgrade.php
Have a nice day.
Attachments
the screen shot whit update
the screen shot whit update
thold update.JPG (184.42 KiB) Viewed 4305 times
thold.zip
the new thold
(111.69 KiB) Downloaded 115 times
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)
hmorandell
Cacti User
Posts: 73
Joined: Mon May 03, 2010 11:48 am

Re: [FIX] thold 0.4.3-2

Post by hmorandell »

Hi,

I have upgraded thold plugin using your attached file, but I do not get the 2 extra fields in my "Add Device" screen.
Do I have to modify other files as well? Can you please help me?

Thx.
dragossto wrote:Hello sodium

A new update from me :)
Fixed a minor error, one new line added in polling.php whit snmp_uptime=''

In the update it about possibility to send, or not for one host email whit up and down
or
To send email for certain host to another email address
Also , if it putted one (ore more) email address in the box for email and the option to send email it disable
will send email only to specified email in the box

This it maid , by creating in the host database 2 new columns
thold_send_email and thold_host_email

Till now , i don't discover any errors

the update it work only
if execute from CLI from directory extras

Code: Select all

php upgrade.php
Have a nice day.
_________________
Cacti - 1.2.14
Poller Type - SPINE 1.2.14
Devices 3,892
Graphs 21,483
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 »

i notice that it a new update on the svn
i will make update and till tomorrow i will post the new one
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 »

All the problems of the world could be settled if people were only willing to think...
hmorandell
Cacti User
Posts: 73
Joined: Mon May 03, 2010 11:48 am

Re: [FIX] thold 0.4.3-2

Post by hmorandell »

sodium wrote:version bump to 0.4.4-41 -- http://forums.cacti.net/viewtopic.php?f ... 81&start=0
hello,

does this version include also the modifications made by dragossto as posted earlier in this thread?

thx
_________________
Cacti - 1.2.14
Poller Type - SPINE 1.2.14
Devices 3,892
Graphs 21,483
sodium
Cacti User
Posts: 115
Joined: Wed Feb 01, 2006 10:29 am

Re: [FIX] thold 0.4.3-2

Post by sodium »

his mail output fixes are included except that I renamed AVR_TIME to AVG_TIME
the fix with additional email options is under consideration (I was in the middle of a release when his patch came in)
will be in the next sub-release

I use our SVN release numbers in the version numbering 0.4.4 = main number
-041 is our SVN release number

the next release (with only minor fixes) will only have a higher SVN release number

I hope Jimmy at some point will merge our code with the main SVN trunk...
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 sodium
i take your update and put my in your update
but i have some issue whit my update

1) it that, when i make uninstall of thold the column putted in database host
whit thold_send_email and thold_host_email they bean erased , they bean erased from the database

2) the update it work only when install the plugin if run from cli

Code: Select all

php upgrade.php
once after the plugin it installed from the plugin management

and other problem whit
Notice: Undefined index: 6 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Notice: Undefined index: 24 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Notice: Undefined index: 288 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Mandatory settings
when i try to make a template of advanced ping for loss

the modification made by me don't include this file thold_templates.php
i will make some check tomorrow

The changes made by me (only the diff -Nau2r yourfile.php myfile.php)

Code: Select all

+++ polling.php 2011-02-14 22:51:44.000000000 +0200
@@ -181,2 +181,3 @@
                                        $snmp_contact = '';
+                                       $snmp_uptime = '';
                                        $uptimelong = '';
@@ -226,3 +227,2 @@
                                                $downtime_seconds = $downtime - ($downtime_days * 86400) - ($downtime_hours * 3600) - ($downtime_minutes * 60);
-                                               $msg = $msg . "<br><br>Host was down for ";
                                                if ($downtime_days > 0 ) {
@@ -270,4 +270,10 @@
                                        $msg = str_replace("\n", '<br>', $msg);
-                                       if ($alert_email == '') {
-                                               cacti_log('THOLD: Can not send Host Recovering email since the \'Alert e-mail\' setting is not set!', true, 'POLLER');
+                                       if ($host['thold_send_email'] == 'on' && $host['thold_host_email'] != '' ) {
+                                               $alert_email = $alert_email . ',' . $host['thold_host_email'];
+                                       }
+                                       if ($host['thold_send_email'] != 'on' && $host['thold_host_email'] != '' ) {
+                                               $alert_email = $host['thold_host_email'];
+                                       }
+                                       if ($alert_email == '' || ($host['thold_send_email'] != 'on' && $host['thold_host_email'] == '' )) {
+                                               cacti_log('THOLD: Can not send Host Recovering email since the \'Alert e-mail\' setting is not set or disable per host!', true, 'POLLER');
                                        } else {
@@ -336,4 +342,10 @@
                        $msg = str_replace("\n", '<br>', $msg);
-                       if ($alert_email == '') {
-                               cacti_log('THOLD: Can not send Host Down email since the \'Alert e-mail\' setting is not set!', true, 'POLLER');
+                       if ($host['thold_send_email'] == 'on' && $host['thold_host_email'] != '' ) {
+                               $alert_email = $alert_email . ',' . $host['thold_host_email'];
+                       }
+                       if ($host['thold_send_email'] != 'on' && $host['thold_host_email'] != '' ) {
+                               $alert_email = $host['thold_host_email'];
+                       }
+                       if ($alert_email == '' || ($host['thold_send_email'] != 'on' && $host['thold_host_email'] == '' )) {
+                               cacti_log('THOLD: Can not send Host Recovering email since the \'Alert e-mail\' setting is not set or disable per host!', true, 'POLLER');
                        } else {

Code: Select all

+++ database.php        2011-02-14 20:43:03.000000000 +0200
@@ -80,3 +80,5 @@

-
+               // Added in thold v0.4.3 to disable email fosr host or send email to extra account
+               api_plugin_db_add_column ('thold', 'host', array('name' => 'thold_send_email', 'type' => 'char(3)', 'NULL' => false, 'default' => 'on', 'after' => 'disabled'));
+               api_plugin_db_add_column ('thold', 'host', array('name' => 'thold_host_email', 'type' => 'text', 'NULL' => false, 'after' => 'thold_send_email'));
                // Update our hooks

Code: Select all

+++ settings.php        2011-02-14 22:35:27.000000000 +0200
@@ -74,2 +74,32 @@

+function thold_config_form () {
+       global $fields_host_edit;
+       $fields_host_edit2 = $fields_host_edit;
+       $fields_host_edit3 = array();
+       foreach ($fields_host_edit2 as $f => $a) {
+               $fields_host_edit3[$f] = $a;
+               if ($f == 'disabled') {
+                       $fields_host_edit3['thold_send_email'] = array(
+                               'method' => 'checkbox',
+                               'friendly_name' => 'Thold Email Host',
+                               'description' => 'Check this box to send Email for Host/Up.',
+                               'value' => '|arg1:thold_send_email|',
+                               'default' => '',
+                               'form_id' => false
+                       );
+                       $fields_host_edit3['thold_host_email'] = array(
+                               'friendly_name' => 'Additional Email address',
+                               'description' => 'Additional Email address, separated by commas for multi Emails.',
+                               'method' => 'textarea',
+                               'max_length' => 1000,
+                               'textarea_rows' => 1,
+                               'textarea_cols' => 30,
+                               'value' => '|arg1:thold_host_email|',
+                               'default' => '',
+                       );
+               }
+       }
+       $fields_host_edit = $fields_host_edit3;
+}
+
 function thold_config_settings () {
@@ -199,3 +229,3 @@
                        'friendly_name' => 'Down Host Message',
-                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVR_TIME&#062 &#060NOTES&#062',
+                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062',
                        'method' => 'textarea',
@@ -214,3 +244,3 @@
                        'friendly_name' => 'Recovering Host Message',
-                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVR_TIME&#062 &#060NOTES&#062',
+                       'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062',
                        'method' => 'textarea',

Code: Select all

+++ setup.php   2011-02-14 21:12:08.000000000 +0200
@@ -31,2 +31,3 @@
        api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php');
+       api_plugin_register_hook('thold', 'config_form', 'thold_config_form', 'includes/settings.php');
        api_plugin_register_hook('thold', 'config_settings', 'thold_config_settings', 'includes/settings.php');
@@ -276,2 +277,12 @@
        }
+
+       if (isset($_POST['thold_send_email']))
+               $save['thold_send_email'] = form_input_validate($_POST['thold_send_email'], 'thold_send_email', '', true, 3);
+       else
+               $save['thold_send_email'] = form_input_validate('', 'thold_send_email', '', true, 3);
+       if (isset($_POST['thold_host_email']))
+               $save['thold_host_email'] = form_input_validate($_POST['thold_host_email'], 'thold_host_email', '', true, 3);
+       else
+               $save['thold_host_email'] = form_input_validate('', 'thold_host_email', '', true, 3);
+
        return $save;
Have good night.
Attachments
thold.zip
the new plugin
(98.1 KiB) Downloaded 263 times
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 »

hi are these the same patches as you posted last sunday?

do you mean that these patches do not work?

(please only post diff's against the latest version)
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 »

hi,
the diff it between your last snapshot
download from
http://forums.cacti.net/download/file.php?id=22872
in the new thread http://forums.cacti.net/viewtopic.php?f ... 81&start=0
and over them apply my modification .

But like i told you before , i have 2 problem (minor) when uninstall thold from plugin management
the data it lost from database host ,maybe my approach it not right
i don't know why :(
and the second it when make the install , to work my modified host , have to run upgrade.php from cli

this is my problem , this it the reason for posting hear and not in your last thread

the error whit

Code: Select all

Notice: Undefined index: 6 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Notice: Undefined index: 24 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Notice: Undefined index: 288 in /var/www/htdocs/cacti/plugins/thold/thold_templates.php on line 429 Mandatory settings
it was discovered by me , just trying to make one template thold whit loss for Advanced ping.
Don't have any connection whit my modification.
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)
CanDee
Posts: 11
Joined: Wed Jul 23, 2008 12:47 am

Re: [FIX] thold 0.4.3-2

Post by CanDee »

Hi all,
i installed this update hoping it will solve my email problem as well. but it doesn't

i've set up a thold for my graph "Local - Cacti Poller - Statistics [Time]"
whenever it's triggered the email is not contending the associated graph

email looks like:

Code: Select all

An alert has been issued that requires your attention. 

Host: Cacti (xxx.xxx.xxx)
URL: http://xxx.xxx.xxx/cacti//graph.php?local_graph_id=0&rra_id=1
Message: Local - Cacti Poller - Statistics [Time] restored to normal threshold with value 10.3791



Could not open!
http://xxx.xxx.xxx/cacti//graph_image.php?local_graph_id=0&rra_id=0&view_type=tree
a look at the URL makes me wonder why there are 2 // at first sight...then local_graph_id=0 .... where the graph id should be 1007 (in my installation)

any ideas how to get that woring?


regards
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests