From c6501c1911dddd38238a790c5bfc304ed76cec5c Mon Sep 17 00:00:00 2001 From: TheWitness Date: Thu, 27 Jul 2023 21:48:06 -0400 Subject: [PATCH] Starting #590 - Just the settings with some outstanding issues Found that there is no good way to hook the settings page without a global JavaScript file. Really need a hook at the bottom of the settings page. --- includes/arrays.php | 31 +++++++++++++++++++++++++++++++ includes/database.php | 2 +- includes/settings.php | 34 +++++++++++++++++++++++++++++++--- setup.php | 1 - thold.php | 10 +++++----- thold_functions.php | 9 +++++++-- thold_templates.php | 12 ++++++------ 7 files changed, 81 insertions(+), 18 deletions(-) diff --git a/includes/arrays.php b/includes/arrays.php index 0e05ce9..dea2da2 100644 --- a/includes/arrays.php +++ b/includes/arrays.php @@ -554,3 +554,34 @@ 10 => __('%d Digits', 10, 'thold'), ); +/** + * Notifcation Pause Settings come in three varieties + * + * 1 - Global number of notifications + * 2 - X% from a Site + * 3 - X% globally + * + */ +$devices_down = array(10,30,50,100,1000,2000,3000); +$percentiles_down = array(10,20,30,40,50); + +$notification_pause_values[-1] = __('Disabled', 'thold'); + +foreach($devices_down as $d) { + $notification_pause_values["$d|g"] = __('> %d Devices', $d, 'thold'); +} + +foreach($percentiles_down as $p) { + $notification_pause_values["$p|ps"] = __('> %d%%% of Devices in a Site', $p, 'thold'); +} + +foreach($percentiles_down as $p) { + $notification_pause_values["$p|pg"] = __('> %d%%% of Devices Globally', $p, 'thold'); +} + +$notification_delay_values = array( + 5 => __('%d Minutes', '5', 'thold'), + 10 => __('%d Minutes', '10', 'thold'), + 15 => __('%d Minutes', '15', 'thold'), + 20 => __('%d Minutes', '20', 'thold') +); diff --git a/includes/database.php b/includes/database.php index f152b73..3ff6e14 100644 --- a/includes/database.php +++ b/includes/database.php @@ -1590,7 +1590,7 @@ function thold_upgrade_database($force = false) { db_execute('UPDATE plugin_notification_lists SET enabled = "on"'); } - api_plugin_register_hook('thold', 'device_template_change', 'thold_device_template_change', 'setup.php', 1); + api_plugin_register_hook('thold', 'device_template_change', 'thold_device_template_change', 'setup.php', 1); api_plugin_register_realm('thold', 'notify_lists.php,notify_queue.php', 'Manage Notification Lists', 1); thold_setup_database(); diff --git a/includes/settings.php b/includes/settings.php index 5655685..bc570c0 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -683,19 +683,47 @@ function thold_config_settings() { 'method' => 'spacer', ), 'alert_deadnotify' => array( - 'friendly_name' => __('Device Notifications', 'thold'), + 'friendly_name' => __('Enable Notifications', 'thold'), 'description' => __('Enable Dead/Recovering host notification', 'thold'), 'method' => 'checkbox', 'default' => 'on' ), 'alert_deadnotify_one_mail' => array( - 'friendly_name' => __('Device Notifications Single Email', 'thold'), + 'friendly_name' => __('Notification Single Email', 'thold'), 'description' => __('Supported for Notification Lists and the Notification Queue only. If there are Down Device Notifications in a single processing cycle. Send only one Email to Notification List repipients for all Devices.', 'thold'), 'method' => 'checkbox', 'default' => 'on' ), + 'thold_notification_delay' => array( + 'friendly_name' => __('Device Notification Delay Options', 'thold'), + 'method' => 'spacer', + ), + 'alert_notification_pause' => array( + 'friendly_name' => __('Notification Delay', 'thold'), + 'description' => __('If a large influx of Down Device Notifications come in, Cacti can pause sending out those Notifications for a certain period of time to see if the issue is transient before sending them out. Select the threshold Down Device Notifications before the Pause is Triggered.', 'thold'), + 'array' => $notification_pause_values, + 'method' => 'drop_array', + 'default' => '-1' + ), + 'alert_notification_delay' => array( + 'friendly_name' => __('Notification Delay', 'thold'), + 'description' => __('If you choose to delay Notifications for a large Down Devices Notification inrush, how long are you willing to wait before allowing the notifications to be processed?', 'thold'), + 'array' => $notification_delay_values, + 'method' => 'drop_array', + 'default' => '-1' + ), + 'alert_deadnotify_single_transaction' => array( + 'friendly_name' => __('Notification Delay Single Transaction', 'thold'), + 'description' => __('When the Notification Delay has been Triggered, and Email and or Command will be executed to indicate that the Notifcation Delay has been triggered. A separate Email will be sent if and when the event has ended notifying the recipients that the events were canceled.', 'thold'), + 'method' => 'checkbox', + 'default' => '' + ), + 'thold_device_email' => array( + 'friendly_name' => __('Device Notification Email Options', 'thold'), + 'method' => 'spacer', + ), 'alert_email' => array( - 'friendly_name' => __('Device Notifications Email', 'thold'), + 'friendly_name' => __('Global Notification Email', 'thold'), 'description' => __('This is the Email Address that the Dead Device Notifications will be sent to if the Global Notification List is selected.', 'thold'), 'method' => 'textbox', 'size' => 80, diff --git a/setup.php b/setup.php index c2c6926..02640b3 100644 --- a/setup.php +++ b/setup.php @@ -1605,4 +1605,3 @@ function thold_clog_regex_threshold($matches) { return $result; } - diff --git a/thold.php b/thold.php index db97e72..d745d46 100644 --- a/thold.php +++ b/thold.php @@ -1789,14 +1789,14 @@ function thold_edit() { 'description' => __("Numeric values for High and Low Thresholds can include the following suffixes for numbers greater than 1 to 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', and for numbers less than 1 'm', 'u', 'p', 'f'.", 'thold') ), 'bl_type' => array( - 'friendly_name' => __('Baseline Type', 'thold'), + 'friendly_name' => __('Type', 'thold'), 'method' => 'drop_array', 'array' => $bl_types, 'description' => __('The type of Baseline. Percentage Deviation is a percentage value from the historical trend. Absolute Value is a deviation either above or below the Baseline over that historical trend.', 'thold'), 'value' => isset($thold_data['bl_type']) ? $thold_data['bl_type'] : 0 ), 'bl_ref_time_range' => array( - 'friendly_name' => __('Time range', 'thold'), + 'friendly_name' => __('Time Range', 'thold'), 'method' => 'drop_array', 'array' => $reference_types, 'description' => __('Specifies the point in the past (based on rrd resolution) that will be used as a reference or the duration to use for the Floating Average when using the Floating Average type Threshold', 'thold'), @@ -1807,7 +1807,7 @@ function thold_edit() { 'method' => 'textbox', 'max_length' => 12, 'size' => 15, - 'description' => __('Specifies allowed deviation in percentage for the upper bound Threshold. If not set, upper bound Threshold will not be checked at all.', 'thold'), + 'description' => __('Specifies allowed deviation for the upper bound Threshold. If not set, the upper bound Threshold will not be checked at all. The unit of measure is an absolute values for \'Absolute Value\' Type, and a Percentable for both \'%% Deviation\' and \'%% Floating Average\'', 'thold'), 'value' => isset($thold_data['bl_pct_up']) ? $thold_data['bl_pct_up'] : '' ), 'bl_pct_down' => array( @@ -1815,11 +1815,11 @@ function thold_edit() { 'method' => 'textbox', 'max_length' => 12, 'size' => 15, - 'description' => __('Specifies allowed deviation in percentage for the lower bound Threshold. If not set, lower bound Threshold will not be checked at all.', 'thold'), + 'description' => __('Specifies allowed deviation for the lower bound Threshold. If not set, the lower bound Threshold will not be checked at all. The unit of measure is an absolute values for \'Absolute Value\' Type, and a Percentable for both \'%% Deviation\' and \'%% Floating Average\'', 'thold'), 'value' => isset($thold_data['bl_pct_down']) ? $thold_data['bl_pct_down'] : '' ), 'bl_fail_trigger' => array( - 'friendly_name' => __('Baseline Trigger Count', 'thold'), + 'friendly_name' => __('Trigger Count', 'thold'), 'method' => 'textbox', 'max_length' => 3, 'size' => 15, diff --git a/thold_functions.php b/thold_functions.php index c0a3ee6..e6c5206 100644 --- a/thold_functions.php +++ b/thold_functions.php @@ -2110,12 +2110,15 @@ function thold_check_threshold(&$thold_data) { thold_debug('Threshold checking halted by Device Status (' . $h['status'] . ')' ); return; } + + $h['thold_id'] = $thold_data['id']; } else { /* function called during polling */ $h['id'] = $thold_data['host_id']; $h['snmp_engine_id'] = $thold_data['snmp_engine_id']; $h['description'] = $thold_data['description']; $h['hostname'] = $thold_data['hostname']; + $h['thold_id'] = $thold_data['id']; } /* ensure that Cacti will make of individual defined SNMP Engine IDs */ @@ -5946,7 +5949,8 @@ function thold_mail($to_email, $bcc_email, $from_email, $subject, $message, $fil 'body_text' => $text['text'], 'attachments' => empty($attachments) ? null : $attachments, 'headers' => $headers, - 'html' => $thold_send_text_only != 'on' + 'html' => $thold_send_text_only != 'on', + 'id' => (isset($host['thold_id']) ? $host['thold_id']:$host['id']) ); thold_notification_add($topic, $data, 'id', $notify_list_id, $host); @@ -5980,7 +5984,8 @@ function thold_mail($to_email, $bcc_email, $from_email, $subject, $message, $fil 'body_text' => $text['text'], 'attachments' => empty($attachments) ? '' : $attachments, 'headers' => $headers, - 'html' => $thold_send_text_only != 'on' + 'html' => $thold_send_text_only != 'on', + 'id' => (isset($host['thold_id']) ? $host['thold_id']:$host['id']) ); thold_notification_add($topic, $data, 'id', $notify_list_id, $host); diff --git a/thold_templates.php b/thold_templates.php index b4eae87..4cde6cd 100644 --- a/thold_templates.php +++ b/thold_templates.php @@ -1368,7 +1368,7 @@ function template_edit() { 'description' => __("Numeric values for High and Low Thresholds can include the following suffixes for numbers greater than 1 to 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', and for numbers less than 1 'm', 'u', 'p', 'f'.", 'thold') ), 'bl_type' => array( - 'friendly_name' => __('Baseline Type', 'thold'), + 'friendly_name' => __('Type', 'thold'), 'method' => 'drop_array', 'array' => $bl_types, 'description' => __('The type of Baseline. Percentage Deviation is a percentage value from the historical trend. Absolute Value is a deviation either above or below the Baseline over that historical trend.', 'thold'), @@ -1382,23 +1382,23 @@ function template_edit() { 'value' => isset($thold_data['bl_ref_time_range']) ? $thold_data['bl_ref_time_range'] : read_config_option('alert_bl_timerange_def') ), 'bl_pct_up' => array( - 'friendly_name' => __('Baseline Deviation UP', 'thold'), + 'friendly_name' => __('Deviation UP', 'thold'), 'method' => 'textbox', 'max_length' => 12, 'size' => 15, - 'description' => __('Specifies allowed deviation in percentage for the upper bound Threshold. If not set, upper bound Threshold will not be checked at all.', 'thold'), + 'description' => __('Specifies allowed deviation for the upper bound Threshold. If not set, upper bound Threshold will not be checked at all. The unit of measure is an absolute values for \'Absolute Value\' Type, and a Percentable for both \'%% Deviation\' and \'%% Floating Average\'', 'thold'), 'value' => isset($thold_data['bl_pct_up']) ? $thold_data['bl_pct_up'] : read_config_option('alert_bl_percent_def') ), 'bl_pct_down' => array( - 'friendly_name' => __('Baseline Deviation DOWN', 'thold'), + 'friendly_name' => __('Deviation DOWN', 'thold'), 'method' => 'textbox', 'max_length' => 12, 'size' => 15, - 'description' => __('Specifies allowed deviation in percentage for the lower bound Threshold. If not set, lower bound Threshold will not be checked at all.', 'thold'), + 'description' => __('Specifies allowed deviation for the lower bound Threshold. If not set, lower bound Threshold will not be checked at all. The unit of measure is an absolute values for \'Absolute Value\' Type, and a Percentable for both \'%% Deviation\' and \'%% Floating Average\'', 'thold'), 'value' => isset($thold_data['bl_pct_down']) ? $thold_data['bl_pct_down'] : read_config_option('alert_bl_percent_def') ), 'bl_fail_trigger' => array( - 'friendly_name' => __('Baseline Trigger Count', 'thold'), + 'friendly_name' => __('Trigger Count', 'thold'), 'method' => 'textbox', 'max_length' => 3, 'size' => 15,