Diff between stable and this version 0.4.6
setup.php
Code: Select all
--- setup.php
+++ /modif/setup.php
@@ -29,6 +29,7 @@
api_plugin_register_hook('thold', 'top_graph_header_tabs', 'thold_show_tab', 'includes/tab.php');
api_plugin_register_hook('thold', 'config_insert', 'thold_config_insert', 'includes/settings.php');
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');
api_plugin_register_hook('thold', 'draw_navigation_text', 'thold_draw_navigation_text', 'includes/settings.php');
api_plugin_register_hook('thold', 'data_sources_table', 'thold_data_sources_table', 'setup.php');
@@ -275,6 +276,14 @@
}
$result = db_execute($sql);
}
+ 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;
}
thold_functions.php
Code: Select all
--- thold_functions.php
+++ /modif/thold_functions.php
@@ -2667,6 +2667,9 @@
$v = thold_version();
$Mailer->header_set('X-Mailer', 'Cacti-Thold-v' . $v['version']);
$Mailer->header_set('User-Agent', 'Cacti-Thold-v' . $v['version']);
+ if (read_config_option('thold_email_prio') == 'on') {
+ $Mailer->header_set('X-Priority', '1');
+ }
thold_debug("Sending email to '" . trim(implode(',',$to),',') . "'");
if ($Mailer->send($text) == false) {
includes/settings.php
Code: Select all
--- includes/settings.php
+++ /modif/includes/settings.php
@@ -72,6 +72,36 @@
}
}
+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 () {
global $tabs, $settings, $item_rows, $config;
@@ -195,6 +225,12 @@
'method' => 'checkbox',
'default' => 'on'
),
+ 'thold_email_prio' => array(
+ 'friendly_name' => 'Set e-mail prio to 1',
+ 'description' => 'Allows you to set e-mail priority to 1',
+ 'method' => 'checkbox',
+ 'default' => 'off'
+ ),
'alert_email' => array(
'friendly_name' => 'Dead Host Notifications Email',
'description' => 'This is the email address that the dead host notifications will be sent to.',
@@ -212,12 +248,12 @@
),
'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><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <CUR_TIME> <AVR_TIME> <NOTES>',
+ '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><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <TOT_POLL> <FAIL_POLL> <CUR_TIME> <AVG_TIME> <NOTES>',
'method' => 'textarea',
'class' => 'textAreaNotes',
'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>',
+ 'default' => 'System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>System total pollings check: <TOT_POLL><br>System failds pollings check: <FAIL_POLL><br>Last date going DOWN : <LAST_FAIL><br>Host had been up for: <DOWNTIME><br>NOTE: <NOTES>',
),
'thold_up_subject' => array(
'friendly_name' => 'Recovering Host Subject',
@@ -229,12 +265,12 @@
),
'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><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <CUR_TIME> <AVR_TIME> <NOTES>',
+ '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><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <TOT_POLL> <FAIL_POLL> <CUR_TIME> <AVG_TIME> <NOTES>',
'method' => 'textarea',
'class' => 'textAreaNotes',
'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>',
+ 'default' => '<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>System total pollings check: <TOT_POLL><br>System failds pollings check: <FAIL_POLL><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>',
),
'thold_from_email' => array(
'friendly_name' => 'From Email Address',
includes/polling.php
Code: Select all
--- includes/polling.php
+++ /modif/includes/polling.php
@@ -256,7 +256,6 @@
$downtime_hours = floor(($downtime - ($downtime_days * 86400))/3600);
$downtime_minutes = floor(($downtime - ($downtime_days * 86400) - ($downtime_hours * 3600))/60);
$downtime_seconds = $downtime - ($downtime_days * 86400) - ($downtime_hours * 3600) - ($downtime_minutes * 60);
- $msg = $msg . "<br><br>Host was down for ";
if ($downtime_days > 0 ) {
$downtimemsg = $downtime_days . "d " . $downtime_hours . "h " . $downtime_minutes . "m " . $downtime_seconds . "s ";
} elseif ($downtime_hours > 0 ) {
@@ -280,7 +279,7 @@
$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>';
+ $msg = '<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>System total pollings check: <TOT_POLL><br>System failds pollings check: <FAIL_POLL><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>';
}
$msg = str_replace('<SUBJECT>', $subject, $msg);
$msg = str_replace('<HOSTNAME>', $host['hostname'], $msg);
@@ -298,13 +297,23 @@
$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>', round(($host["availability"]), 2) . ' %', $msg);
+ $msg = str_replace('<TOT_POLL>', $host["total_polls"], $msg);
+ $msg = str_replace('<FAIL_POLL>', $host["failed_polls"], $msg);
$msg = str_replace('<CUR_TIME>', round(($host["cur_time"]), 2), $msg);
$msg = str_replace('<AVG_TIME>', round(($host["avg_time"]), 2), $msg);
$msg = str_replace('<NOTES>', $host["notes"], $msg);
$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');
- } else {
+ 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 == '') {
+ cacti_log('THOLD: Can not send Host Recovering email since the \'Alert e-mail\' setting is not set !', true, 'POLLER');
+ } elseif ($host['thold_send_email'] != 'on' && $host['thold_host_email'] == '' ) {
+ cacti_log('THOLD: Not send Host Recovering email, disabled per host : ' . $host['description'] . ' !', true, 'POLLER');
+ } else {
thold_mail($alert_email, '', $subject, $msg, '');
}
}
@@ -344,12 +353,12 @@
}
$subject = str_replace('<HOSTNAME>', $host['hostname'], $subject);
$subject = str_replace('<DESCRIPTION>', $host['description'], $subject);
- $subject = str_replace('<DOWN/UP>', 'UP', $subject);
+ $subject = str_replace('<DOWN/UP>', 'DOWN', $subject);
$subject = strip_tags($subject);
$msg = read_config_option('thold_down_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>';
+ $msg = 'System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>System total pollings check: <TOT_POLL><br>System failds pollings check: <FAIL_POLL><br>Last date going DOWN : <LAST_FAIL><br>Host had been up for: <DOWNTIME><br>NOTE: <NOTES>';
}
$msg = str_replace('<SUBJECT>', $subject, $msg);
$msg = str_replace('<HOSTNAME>', $host['hostname'], $msg);
@@ -365,12 +374,22 @@
$msg = str_replace('<LAST_FAIL>', $host["status_fail_date"], $msg);
$msg = str_replace('<AVAILABILITY>', round(($host["availability"]), 2) . ' %', $msg);
$msg = str_replace('<CUR_TIME>', round(($host["cur_time"]), 2), $msg);
+ $msg = str_replace('<TOT_POLL>', $host["total_polls"], $msg);
+ $msg = str_replace('<FAIL_POLL>', $host["failed_polls"], $msg);
$msg = str_replace('<AVG_TIME>', round(($host["avg_time"]), 2), $msg);
$msg = str_replace('<NOTES>', $host["notes"], $msg);
$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');
- } else {
+ 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 == '') {
+ cacti_log('THOLD: Can not send Host Recovering email since the \'Alert e-mail\' setting is not set !', true, 'POLLER');
+ } elseif ($host['thold_send_email'] != 'on' && $host['thold_host_email'] == '' ) {
+ cacti_log('THOLD: Not send Host Recovering email, disabled per host : ' . $host['description'] . ' !', true, 'POLLER');
+ } else {
thold_mail($alert_email, '', $subject, $msg, '');
}
}