Skip to content

Commit

Permalink
Starting #590 - Just the settings with some outstanding issues
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheWitness committed Jul 28, 2023
1 parent 0e5285a commit c6501c1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 18 deletions.
31 changes: 31 additions & 0 deletions includes/arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
2 changes: 1 addition & 1 deletion includes/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
34 changes: 31 additions & 3 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1605,4 +1605,3 @@ function thold_clog_regex_threshold($matches) {

return $result;
}

10 changes: 5 additions & 5 deletions thold.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -1807,19 +1807,19 @@ 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(
'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, 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,
Expand Down
9 changes: 7 additions & 2 deletions thold_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions thold_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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,
Expand Down

0 comments on commit c6501c1

Please sign in to comment.