function template_edit() { global $colors; /* ================= input validation ================= */ input_validate_input_number(get_request_var('id')); /* ==================================================== */ $id = $_GET['id']; $thold_item_data = db_fetch_assoc('SELECT * FROM thold_template WHERE id=' . $id); $thold_item_data = count($thold_item_data) > 0 ? $thold_item_data[0] : $thold_item_data; $temp = db_fetch_assoc('SELECT id, name FROM data_template WHERE id=' . $thold_item_data['data_template_id']); foreach ($temp as $d) { $data_templates[$d['id']] = $d['name']; } $temp = db_fetch_assoc('SELECT id, data_source_name, data_input_field_id FROM data_template_rrd WHERE id=' . $thold_item_data['data_source_id']); $source_id = $temp[0]['data_input_field_id']; if ($source_id != 0) { $temp2 = db_fetch_assoc('SELECT id, name FROM data_input_fields WHERE id=' . $source_id); foreach ($temp2 as $d) { $data_fields[$d['id']] = $d['name']; } } else { $data_fields[$temp[0]['id']] = $temp[0]['data_source_name']; } $send_notification_array = array(); $users = db_fetch_assoc("SELECT plugin_thold_contacts.id, plugin_thold_contacts.data, \r\n\t\tplugin_thold_contacts.type, user_auth.full_name \r\n\t\tFROM plugin_thold_contacts, user_auth \r\n\t\tWHERE user_auth.id=plugin_thold_contacts.user_id \r\n\t\tAND plugin_thold_contacts.data!='' \r\n\t\tORDER BY user_auth.full_name ASC, plugin_thold_contacts.type ASC"); if (!empty($users)) { foreach ($users as $user) { $send_notification_array[$user['id']] = $user['full_name'] . ' - ' . ucfirst($user['type']); } } if (isset($thold_item_data['id'])) { $sql = 'SELECT contact_id as id FROM plugin_thold_template_contact WHERE template_id=' . $thold_item_data['id']; } else { $sql = 'SELECT contact_id as id FROM plugin_thold_template_contact WHERE template_id=0'; } $step = db_fetch_cell('SELECT rrd_step FROM data_template_data WHERE data_template_id = ' . $thold_item_data['data_template_id'], FALSE); if ($step == 60) { $repeatarray = array(0 => 'Never', 1 => 'Every Minute', 2 => 'Every 2 Minutes', 3 => 'Every 3 Minutes', 4 => 'Every 4 Minutes', 5 => 'Every 5 Minutes', 10 => 'Every 10 Minutes', 15 => 'Every 15 Minutes', 20 => 'Every 20 Minutes', 30 => 'Every 30 Minutes', 45 => 'Every 45 Minutes', 60 => 'Every Hour', 120 => 'Every 2 Hours', 180 => 'Every 3 Hours', 240 => 'Every 4 Hours', 360 => 'Every 6 Hours', 480 => 'Every 8 Hours', 720 => 'Every 12 Hours', 1440 => 'Every Day', 2880 => 'Every 2 Days', 10080 => 'Every Week', 20160 => 'Every 2 Weeks', 43200 => 'Every Month'); $alertarray = array(0 => 'Never', 1 => '1 Minute', 2 => '2 Minutes', 3 => '3 Minutes', 4 => '4 Minutes', 5 => '5 Minutes', 10 => '10 Minutes', 15 => '15 Minutes', 20 => '20 Minutes', 30 => '30 Minutes', 45 => '45 Minutes', 60 => '1 Hour', 120 => '2 Hours', 180 => '3 Hours', 240 => '4 Hours', 360 => '6 Hours', 480 => '8 Hours', 720 => '12 Hours', 1440 => '1 Day', 2880 => '2 Days', 10080 => '1 Week', 20160 => '2 Weeks', 43200 => '1 Month'); $timearray = array(1 => '1 Minute', 2 => '2 Minutes', 3 => '3 Minutes', 4 => '4 Minutes', 5 => '5 Minutes', 6 => '6 Minutes', 7 => '7 Minutes', 8 => '8 Minutes', 9 => '9 Minutes', 10 => '10 Minutes', 12 => '12 Minutes', 15 => '15 Minutes', 20 => '20 Minutes', 24 => '24 Minutes', 30 => '30 Minutes', 45 => '45 Minutes', 60 => '1 Hour', 120 => '2 Hours', 180 => '3 Hours', 240 => '4 Hours', 288 => '4.8 Hours', 360 => '6 Hours', 480 => '8 Hours', 720 => '12 Hours', 1440 => '1 Day', 2880 => '2 Days', 10080 => '1 Week', 20160 => '2 Weeks', 43200 => '1 Month'); } else { if ($step == 300) { $repeatarray = array(0 => 'Never', 1 => 'Every 5 Minutes', 2 => 'Every 10 Minutes', 3 => 'Every 15 Minutes', 4 => 'Every 20 Minutes', 6 => 'Every 30 Minutes', 8 => 'Every 45 Minutes', 12 => 'Every Hour', 24 => 'Every 2 Hours', 36 => 'Every 3 Hours', 48 => 'Every 4 Hours', 72 => 'Every 6 Hours', 96 => 'Every 8 Hours', 144 => 'Every 12 Hours', 288 => 'Every Day', 576 => 'Every 2 Days', 2016 => 'Every Week', 4032 => 'Every 2 Weeks', 8640 => 'Every Month'); $alertarray = array(0 => 'Never', 1 => '5 Minutes', 2 => '10 Minutes', 3 => '15 Minutes', 4 => '20 Minutes', 6 => '30 Minutes', 8 => '45 Minutes', 12 => '1 Hour', 24 => '2 Hours', 36 => '3 Hours', 48 => '4 Hours', 72 => '6 Hours', 96 => '8 Hours', 144 => '12 Hours', 288 => '1 Day', 576 => '2 Days', 2016 => '1 Week', 4032 => '2 Weeks', 8640 => '1 Month'); $timearray = array(1 => '5 Minutes', 2 => '10 Minutes', 3 => '15 Minutes', 4 => '20 Minutes', 6 => '30 Minutes', 8 => '45 Minutes', 12 => '1 Hour', 24 => '2 Hours', 36 => '3 Hours', 48 => '4 Hours', 72 => '6 Hours', 96 => '8 Hours', 144 => '12 Hours', 288 => '1 Day', 576 => '2 Days', 2016 => '1 Week', 4032 => '2 Weeks', 8640 => '1 Month'); } else { $repeatarray = array(0 => 'Never', 1 => 'Every Polling', 2 => 'Every 2 Pollings', 3 => 'Every 3 Pollings', 4 => 'Every 4 Pollings', 6 => 'Every 6 Pollings', 8 => 'Every 8 Pollings', 12 => 'Every 12 Pollings', 24 => 'Every 24 Pollings', 36 => 'Every 36 Pollings', 48 => 'Every 48 Pollings', 72 => 'Every 72 Pollings', 96 => 'Every 96 Pollings', 144 => 'Every 144 Pollings', 288 => 'Every 288 Pollings', 576 => 'Every 576 Pollings', 2016 => 'Every 2016 Pollings'); $alertarray = array(0 => 'Never', 1 => '1 Polling', 2 => '2 Pollings', 3 => '3 Pollings', 4 => '4 Pollings', 6 => '6 Pollings', 8 => '8 Pollings', 12 => '12 Pollings', 24 => '24 Pollings', 36 => '36 Pollings', 48 => '48 Pollings', 72 => '72 Pollings', 96 => '96 Pollings', 144 => '144 Pollings', 288 => '288 Pollings', 576 => '576 Pollings', 2016 => '2016 Pollings'); $timearray = array(1 => '1 Polling', 2 => '2 Pollings', 3 => '3 Pollings', 4 => '4 Pollings', 6 => '6 Pollings', 8 => '8 Pollings', 12 => '12 Pollings', 24 => '24 Pollings', 36 => '36 Pollings', 48 => '48 Pollings', 72 => '72 Pollings', 96 => '96 Pollings', 144 => '144 Pollings', 288 => '288 Pollings', 576 => '576 Pollings', 2016 => '2016 Pollings'); } } $thold_types = array(0 => 'High / Low Values', 1 => 'Baseline Deviation', 2 => 'Time Based'); $data_types = array(0 => 'Exact Value', 1 => 'CDEF', 2 => 'Percentage', 3 => 'RPN Expression'); $rra_steps = db_fetch_assoc("SELECT rra.steps \r\n\t\tFROM data_template_data d \r\n\t\tJOIN data_template_data_rra a \r\n\t ON d.id=a.data_template_data_id \r\n\t\tJOIN rra \r\n\t\tON a.rra_id=rra.id \r\n\t WHERE rra.steps>1 \r\n\t\tAND d.data_template_id=" . $thold_item_data['data_template_id'] . "\r\n\t AND d.local_data_template_data_id=0 \r\n\t\tORDER BY steps"); $reference_types = array(); foreach ($rra_steps as $rra_step) { $seconds = $step * $rra_step['steps']; $reference_types[$seconds] = $timearray[$rra_step['steps']] . " Average"; } $data_fields2 = array(); $temp = db_fetch_assoc('SELECT id, local_data_template_rrd_id, data_source_name, data_input_field_id FROM data_template_rrd WHERE local_data_template_rrd_id=0 AND data_template_id=' . $thold_item_data['data_template_id']); foreach ($temp as $d) { if ($d['data_input_field_id'] != 0) { $temp2 = db_fetch_assoc('SELECT id, name, data_name FROM data_input_fields WHERE id=' . $d['data_input_field_id'] . ' ORDER BY data_name'); $data_fields2[$d['data_source_name']] = $temp2[0]['data_name'] . ' (' . $temp2[0]['name'] . ')'; } else { $temp2[0]['name'] = $d['data_source_name']; $data_fields2[$d['data_source_name']] = $temp2[0]['name']; } } $replacements = db_fetch_assoc("SELECT DISTINCT field_name\r\n\t\tFROM data_local AS dl\r\n\t\tINNER JOIN (SELECT DISTINCT field_name, snmp_query_id FROM host_snmp_cache) AS hsc\r\n\t\tON dl.snmp_query_id=hsc.snmp_query_id\r\n\t\tWHERE dl.data_template_id=" . $thold_item_data['data_template_id']); $nr = array(); if (sizeof($replacements)) { foreach ($replacements as $r) { $nr[] = "<span style='color:blue;'>|query_" . $r['field_name'] . "|</span>"; } } $vhf = explode("|", trim(VALID_HOST_FIELDS, "()")); if (sizeof($vhf)) { foreach ($vhf as $r) { $nr[] = "<span style='color:blue;'>|" . $r . "|</span>"; } } $replacements = "<br><b>Replacement Fields:</b> " . implode(", ", $nr); $dss = db_fetch_assoc("SELECT data_source_name FROM data_template_rrd WHERE data_template_id=" . $thold_item_data['data_template_id'] . " AND local_data_id=0"); if (sizeof($dss)) { foreach ($dss as $ds) { $dsname[] = "<span style='color:blue;'>|ds:" . $ds["data_source_name"] . "|</span>"; } } $datasources = "<br><b>Data Sources:</b> " . implode(", ", $dsname); print "<form name='THold' action='thold_templates.php' method='post'>\n"; html_start_box('', '100%', $colors['header'], '3', 'center', ''); $form_array = array('general_header' => array('friendly_name' => 'Mandatory settings', 'method' => 'spacer'), 'name' => array('friendly_name' => 'Template Name', 'method' => 'textbox', 'max_length' => 100, 'default' => $thold_item_data['data_template_name'] . ' [' . $thold_item_data['data_source_name'] . ']', 'description' => 'Provide the THold Template a meaningful name. Host Substritution and Data Query Substitution variables can be used as well as |graph_title| for the Graph Title', 'value' => isset($thold_item_data['name']) ? $thold_item_data['name'] : ''), 'data_template_name' => array('friendly_name' => 'Data Template', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Data Template that you are using. (This can not be changed)', 'value' => $thold_item_data['data_template_id'], 'array' => $data_templates), 'data_field_name' => array('friendly_name' => 'Data Field', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Data Field that you are using. (This can not be changed)', 'value' => $thold_item_data['id'], 'array' => $data_fields), 'thold_enabled' => array('friendly_name' => 'Enabled', 'method' => 'checkbox', 'default' => 'on', 'description' => 'Whether or not this threshold will be checked and alerted upon.', 'value' => isset($thold_item_data['thold_enabled']) ? $thold_item_data['thold_enabled'] : ''), 'exempt' => array('friendly_name' => 'Weekend Exemption', 'description' => 'If this is checked, this Threshold will not alert on weekends.', 'method' => 'checkbox', 'default' => 'off', 'value' => isset($thold_item_data['exempt']) ? $thold_item_data['exempt'] : ''), 'restored_alert' => array('friendly_name' => 'Disable Restoration Email', 'description' => 'If this is checked, Thold will not send an alert when the threshold has returned to normal status.', 'method' => 'checkbox', 'default' => 'off', 'value' => isset($thold_item_data['restored_alert']) ? $thold_item_data['restored_alert'] : ''), 'thold_type' => array('friendly_name' => 'Threshold Type', 'method' => 'drop_array', 'on_change' => 'changeTholdType()', 'array' => $thold_types, 'default' => read_config_option('thold_type'), 'description' => 'The type of Threshold that will be monitored.', 'value' => isset($thold_item_data['thold_type']) ? $thold_item_data['thold_type'] : ''), 'repeat_alert' => array('friendly_name' => 'Re-Alert Cycle', 'method' => 'drop_array', 'array' => $repeatarray, 'default' => read_config_option('alert_repeat'), 'description' => 'Repeat alert after this amount of time has pasted since the last alert.', 'value' => isset($thold_item_data['repeat_alert']) ? $thold_item_data['repeat_alert'] : ''), 'thold_warning_header' => array('friendly_name' => 'High / Low Warning Settings', 'method' => 'spacer'), 'thold_warning_hi' => array('friendly_name' => 'High Warning Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, alert will be triggered', 'value' => isset($thold_item_data['thold_warning_hi']) ? $thold_item_data['thold_warning_hi'] : ''), 'thold_warning_low' => array('friendly_name' => 'Low Warning Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, alert will be triggered', 'value' => isset($thold_item_data['thold_warning_low']) ? $thold_item_data['thold_warning_low'] : ''), 'thold_warning_fail_trigger' => array('friendly_name' => 'Min Warning Trigger Duration', 'method' => 'drop_array', 'array' => $alertarray, 'description' => 'The amount of time the data source must be in a breach condition for an alert to be raised.', 'value' => isset($thold_item_data['thold_warning_fail_trigger']) ? $thold_item_data['thold_warning_fail_trigger'] : read_config_option('alert_trigger')), 'thold_header' => array('friendly_name' => 'High / Low Settings', 'method' => 'spacer'), 'thold_hi' => array('friendly_name' => 'High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, alert will be triggered', 'value' => isset($thold_item_data['thold_hi']) ? $thold_item_data['thold_hi'] : ''), 'thold_low' => array('friendly_name' => 'Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, alert will be triggered', 'value' => isset($thold_item_data['thold_low']) ? $thold_item_data['thold_low'] : ''), 'thold_fail_trigger' => array('friendly_name' => 'Min Trigger Duration', 'method' => 'drop_array', 'array' => $alertarray, 'description' => 'The amount of time the data source must be in a breach condition for an alert to be raised.', 'value' => isset($thold_item_data['thold_fail_trigger']) ? $thold_item_data['thold_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_header' => array('friendly_name' => 'Time Based Warning Settings', 'method' => 'spacer'), 'time_warning_hi' => array('friendly_name' => 'High Warning Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, warning will be triggered', 'value' => isset($thold_item_data['time_warning_hi']) ? $thold_item_data['time_warning_hi'] : ''), 'time_warning_low' => array('friendly_name' => 'Low Warning Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, warning will be triggered', 'value' => isset($thold_item_data['time_warning_low']) ? $thold_item_data['time_warning_low'] : ''), 'time_warning_fail_trigger' => array('friendly_name' => 'Warning Trigger Count', 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'default' => read_config_option('thold_warning_time_fail_trigger'), 'description' => 'The number of times the data source must be in breach condition prior to issuing a warning.', 'value' => isset($thold_item_data['time_warning_fail_trigger']) ? $thold_item_data['time_warning_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_fail_length' => array('friendly_name' => 'Warning Time Period Length', 'method' => 'drop_array', 'array' => $timearray, 'description' => 'The amount of time in the past to check for threshold breaches.', 'value' => isset($thold_item_data['time_warning_fail_length']) ? $thold_item_data['time_warning_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1)), 'time_header' => array('friendly_name' => 'Time Based Settings', 'method' => 'spacer'), 'time_hi' => array('friendly_name' => 'High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, alert will be triggered', 'value' => isset($thold_item_data['time_hi']) ? $thold_item_data['time_hi'] : ''), 'time_low' => array('friendly_name' => 'Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, alert will be triggered', 'value' => isset($thold_item_data['time_low']) ? $thold_item_data['time_low'] : ''), 'time_fail_trigger' => array('friendly_name' => 'Trigger Count', 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'description' => 'The number of times the data source must be in breach condition prior to issuing an alert.', 'value' => isset($thold_item_data['time_fail_trigger']) ? $thold_item_data['time_fail_trigger'] : read_config_option('thold_time_fail_trigger')), 'time_fail_length' => array('friendly_name' => 'Time Period Length', 'method' => 'drop_array', 'array' => $timearray, 'description' => 'The amount of time in the past to check for threshold breaches.', 'value' => isset($thold_item_data['time_fail_length']) ? $thold_item_data['time_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_time_fail_length') : 2)), 'baseline_header' => array('friendly_name' => 'Baseline Monitoring', 'method' => 'spacer'), 'bl_ref_time_range' => array('friendly_name' => 'Time reference in the past', 'method' => 'drop_array', 'array' => $reference_types, 'description' => 'Specifies the point in the past (based on rrd resolution) that will be used as a reference', 'value' => isset($thold_item_data['bl_ref_time_range']) ? $thold_item_data['bl_ref_time_range'] : read_config_option('alert_bl_timerange_def')), 'bl_pct_up' => array('friendly_name' => 'Baseline Deviation UP', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Specifies allowed deviation in percentage for the upper bound threshold. If not set, upper bound threshold will not be checked at all.', 'value' => isset($thold_item_data['bl_pct_up']) ? $thold_item_data['bl_pct_up'] : read_config_option("alert_bl_percent_def")), 'bl_pct_down' => array('friendly_name' => 'Baseline Deviation DOWN', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Specifies allowed deviation in percentage for the lower bound threshold. If not set, lower bound threshold will not be checked at all.', 'value' => isset($thold_item_data['bl_pct_down']) ? $thold_item_data['bl_pct_down'] : read_config_option("alert_bl_percent_def")), 'bl_fail_trigger' => array('friendly_name' => 'Baseline Trigger Count', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Number of consecutive times the data source must be in a breached condition for an alert to be raised.<br>Leave empty to use default value (<b>Default: ' . read_config_option('alert_bl_trigger') . ' cycles</b>)', 'value' => isset($thold_item_data['bl_fail_trigger']) ? $thold_item_data['bl_fail_trigger'] : read_config_option("alert_bl_trigger")), 'data_manipulation' => array('friendly_name' => 'Data Manipulation', 'method' => 'spacer'), 'data_type' => array('friendly_name' => 'Data Type', 'method' => 'drop_array', 'on_change' => 'changeDataType()', 'array' => $data_types, 'description' => 'Special formatting for the given data.', 'value' => isset($thold_item_data['data_type']) ? $thold_item_data['data_type'] : read_config_option('data_type')), 'cdef' => array('friendly_name' => 'Threshold CDEF', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Apply this CDEF before returning the data.', 'value' => isset($thold_item_data['cdef']) ? $thold_item_data['cdef'] : 0, 'array' => thold_cdef_select_usable_names()), 'percent_ds' => array('friendly_name' => 'Percent Datasource', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Second Datasource Item to use as total value to calculate percentage from.', 'value' => isset($thold_item_data['percent_ds']) ? $thold_item_data['percent_ds'] : 0, 'array' => $data_fields2), 'expression' => array('friendly_name' => 'RPN Expression', 'method' => 'textbox', 'default' => '', 'description' => 'An RPN Expression is an RRDtool Compatible RPN Expression. Syntax includes all functions below in addition to both Host and Data Query replacement expressions such as <span style="color:blue;">|query_ifSpeed|</span>. To use a Data Source in the RPN Expression, you must use the syntax: <span style="color:blue;">|ds:dsname|</span>. For example, <span style="color:blue;">|ds:traffic_in|</span> will get the current value of the traffic_in Data Source for the RRDfile(s) associated with the Graph. Any Data Source for a Graph can be included.<br>Math Operators: <span style="color:blue;">+, -, /, *, %, ^</span><br>Functions: <span style="color:blue;">SIN, COS, TAN, ATAN, SQRT, FLOOR, CEIL, DEG2RAD, RAD2DEG, ABS, EXP, LOG, ATAN, ADNAN</span><br>Flow Operators: <span style="color:blue;">UN, ISINF, IF, LT, LE, GT, GE, EQ, NE</span><br>Comparison Functions: <span style="color:blue;">MAX, MIN, INF, NEGINF, NAN, UNKN, COUNT, PREV</span>' . $replacements . $datasources, 'value' => isset($thold_item_data['expression']) ? $thold_item_data['expression'] : '', 'max_length' => '255', 'size' => '80'), 'other_header' => array('friendly_name' => 'Other setting', 'method' => 'spacer'), 'notify_warning' => array('friendly_name' => 'Warning Notification List', 'method' => 'drop_sql', 'description' => 'You may specify choose a Notification List to receive Warnings for this Data Source', 'value' => isset($thold_item_data['notify_warning']) ? $thold_item_data['notify_warning'] : '', 'none_value' => 'None', 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name'), 'notify_alert' => array('friendly_name' => 'Alert Notification List', 'method' => 'drop_sql', 'description' => 'You may specify choose a Notification List to receive Alerts for this Data Source', 'value' => isset($thold_item_data['notify_alert']) ? $thold_item_data['notify_alert'] : '', 'none_value' => 'None', 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name')); if (read_config_option("thold_disable_legacy") != 'on') { $extra = array('notify_accounts' => array('friendly_name' => 'Notify accounts', 'method' => 'drop_multi', 'description' => 'This is a listing of accounts that will be notified when this threshold is breached.<br><br><br><br>', 'array' => $send_notification_array, 'sql' => $sql), 'notify_extra' => array('friendly_name' => 'Alert Emails', 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => 'You may specify here extra Emails to receive alerts for this data source (comma separated)', 'value' => isset($thold_item_data['notify_extra']) ? $thold_item_data['notify_extra'] : ''), 'notify_warning_extra' => array('friendly_name' => 'Warning Emails', 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => 'You may specify here extra Emails to receive warnings for this data source (comma separated)', 'value' => isset($thold_item_data['notify_warning_extra']) ? $thold_item_data['notify_warning_extra'] : '')); $form_array += $extra; } else { $extra = array('notify_accounts' => array('method' => 'hidden', 'value' => 'ignore'), 'notify_extra' => array('method' => 'hidden', 'value' => isset($thold_item_data['notify_extra']) ? $thold_item_data['notify_extra'] : ''), 'notify_warning_extra' => array('method' => 'hidden', 'value' => isset($thold_item_data['notify_warning_extra']) ? $thold_item_data['notify_warning_extra'] : '')); $form_array += $extra; } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array)); form_hidden_box("save", "edit", ""); form_hidden_box("id", $id, ""); html_end_box(); form_save_button('thold_templates.php?id=' . $id, 'save'); ?> <!-- Make it look intelligent :) --> <script language="JavaScript"> function changeTholdType() { type = document.getElementById('thold_type').value; switch(type) { case '0': // Hi/Low thold_toggle_hilow(''); thold_toggle_baseline('none'); thold_toggle_time('none'); break; case '1': // Baseline thold_toggle_hilow('none'); thold_toggle_baseline(''); thold_toggle_time('none'); break; case '2': // Time Based thold_toggle_hilow('none'); thold_toggle_baseline('none'); thold_toggle_time(''); break; } } function changeDataType() { type = document.getElementById('data_type').value; switch(type) { case '0': document.getElementById('row_cdef').style.display = 'none'; document.getElementById('row_percent_ds').style.display = 'none'; document.getElementById('row_expression').style.display = 'none'; break; case '1': document.getElementById('row_cdef').style.display = ''; document.getElementById('row_percent_ds').style.display = 'none'; document.getElementById('row_expression').style.display = 'none'; break; case '2': document.getElementById('row_cdef').style.display = 'none'; document.getElementById('row_percent_ds').style.display = ''; document.getElementById('row_expression').style.display = 'none'; break; case '3': document.getElementById('row_expression').style.display = ''; document.getElementById('row_cdef').style.display = 'none'; document.getElementById('row_percent_ds').style.display = 'none'; break; } } function thold_toggle_hilow(status) { document.getElementById('row_thold_header').style.display = status; document.getElementById('row_thold_hi').style.display = status; document.getElementById('row_thold_low').style.display = status; document.getElementById('row_thold_fail_trigger').style.display = status; document.getElementById('row_thold_warning_header').style.display = status; document.getElementById('row_thold_warning_hi').style.display = status; document.getElementById('row_thold_warning_low').style.display = status; document.getElementById('row_thold_warning_fail_trigger').style.display = status; } function thold_toggle_baseline(status) { document.getElementById('row_baseline_header').style.display = status; document.getElementById('row_bl_ref_time_range').style.display = status; document.getElementById('row_bl_pct_up').style.display = status; document.getElementById('row_bl_pct_down').style.display = status; document.getElementById('row_bl_fail_trigger').style.display = status; } function thold_toggle_time(status) { document.getElementById('row_time_header').style.display = status; document.getElementById('row_time_hi').style.display = status; document.getElementById('row_time_low').style.display = status; document.getElementById('row_time_fail_trigger').style.display = status; document.getElementById('row_time_fail_length').style.display = status; document.getElementById('row_time_warning_header').style.display = status; document.getElementById('row_time_warning_hi').style.display = status; document.getElementById('row_time_warning_low').style.display = status; document.getElementById('row_time_warning_fail_trigger').style.display = status; document.getElementById('row_time_warning_fail_length').style.display = status; } changeTholdType (); changeDataType (); if (document.THold["notify_accounts[]"] && document.THold["notify_accounts[]"].length == 0) { document.getElementById('row_notify_accounts').style.display='none'; } if (document.THold.notify_warning.length == 1) { document.getElementById('row_notify_warning').style.display='none'; } if (document.THold.notify_alert.length == 1) { document.getElementById('row_notify_alert').style.display='none'; } </script> <?php }
function thold_edit() { global $config; if (isset_request_var('id')) { $thold_data = db_fetch_row_prepared('SELECT * FROM thold_data WHERE id = ?', array(get_request_var('id'))); } elseif (isset_request_var('local_data_id') && isset_request_var('local_graph_id') && isset_request_var('host_id') && isset_request_var('data_template_id') && isset_request_var('data_template_rrd_id')) { $thold_data['id'] = '0'; $thold_data['local_data_id'] = get_filter_request_var('local_data_id'); $thold_data['local_graph_id'] = get_filter_request_var('local_graph_id'); $thold_data['data_template_id'] = get_filter_request_var('data_template_id'); $thold_data['host_id'] = get_filter_request_var('host_id'); $thold_data['data_template_rrd_id'] = get_filter_request_var('data_template_rrd_id'); $thold_data['thold_template_id'] = get_filter_request_var('thold_template_id'); } else { exit; } $desc = db_fetch_cell_prepared('SELECT name_cache FROM data_template_data WHERE local_data_id = ? LIMIT 1', array($thold_data['local_data_id'])); $rrdsql = array_rekey(db_fetch_assoc_prepared("SELECT id \n\t\tFROM data_template_rrd \n\t\tWHERE local_data_id = ? ORDER BY id", array($thold_data['local_data_id'])), 'id', 'id'); $grapharr = db_fetch_assoc('SELECT DISTINCT local_graph_id FROM graph_templates_item WHERE task_item_id IN (' . implode(', ', $rrdsql) . ') AND graph_template_id>0'); if (empty($thold_data['local_graph_id'])) { $thold_data['local_graph_id'] = db_fetch_cell_prepared('SELECT gl.id FROM graph_local AS gl INNER JOIN graph_templates_item AS gti ON gl.id=gti.local_graph_id INNER JOIN data_template_rrd AS dtr ON gti.task_item_id=dtr.id WHERE dtr.local_data_id = ? LIMIT 1', array($thold_data['local_data_id'])); } if (empty($thold_data['data_template_rrd_id'])) { $thold_data['data_template_rrd_id'] = db_fetch_cell_prepared('SELECT id FROM data_template_rrd AS dtr WHERE local_data_id = ? LIMIT 1', array($thold_data['local_data_id'])); } $dt_sql = 'SELECT DISTINCT dtr.local_data_id FROM data_template_rrd AS dtr LEFT JOIN graph_templates_item AS gti ON gti.task_item_id=dtr.id LEFT JOIN graph_local AS gl ON gl.id=gti.local_graph_id WHERE gl.id=' . $thold_data['local_graph_id']; $template_data_rrds = db_fetch_assoc("SELECT td.id AS thold_id, dtr.id, dtr.data_source_name, dtr.local_data_id \n\t\tFROM data_template_rrd AS dtr\n\t\tLEFT JOIN thold_data AS td\n\t\tON dtr.id=td.data_template_rrd_id\n\t\tWHERE dtr.local_data_id IN ({$dt_sql}) \n\t\tORDER BY dtr.id"); form_start('thold.php', 'thold'); html_start_box(__('Graph Data'), '100%', '', '3', 'center', ''); ?> <tr> <td class='textArea'> <?php if (isset($banner)) { echo $banner . '<br><br>'; } ?> <?php print __('Data Source Description:'); ?> <br><?php echo $desc; ?> <br><br> <?php print __('Associated Graph (graphs that use this RRD):'); ?> <br> <select name='element'> <?php foreach ($grapharr as $g) { $graph_desc = db_fetch_row_prepared('SELECT local_graph_id, title, title_cache FROM graph_templates_graph WHERE local_graph_id = ?', array($g['local_graph_id'])); echo "<option value='" . $graph_desc['local_graph_id'] . "'"; if ($graph_desc['local_graph_id'] == $thold_data['local_graph_id']) { echo ' selected'; } echo '>' . $graph_desc['local_graph_id'] . ' - ' . $graph_desc['title_cache'] . " </option>\n"; } ?> </select> <br> <br> </td> <td class='textArea'> <img id='graphimage' src='<?php echo htmlspecialchars($config['url_path'] . 'graph_image.php?local_graph_id=' . $thold_data['local_graph_id'] . '&rra_id=0&graph_start=-32400&graph_height=140&graph_width=500'); ?> '> </td> </tr> <?php html_end_box(); $template_rrd = db_fetch_row_prepared('SELECT * FROM data_template_rrd WHERE id = ?', array($thold_data['data_template_rrd_id'])); //----------------------------- // Tabs (if more than one item) //----------------------------- $i = 0; $ds = 0; if (isset($template_data_rrds)) { if (sizeof($template_data_rrds)) { /* draw the data source tabs on the top of the page */ print "<br><div class='tabs'><nav><ul>\n"; foreach ($template_data_rrds as $template_data_rrd) { if ($template_data_rrd['id'] == $thold_data['data_template_rrd_id']) { $ds = $template_data_rrd['data_source_name']; } if (!empty($template_data_rrd['thold_id'])) { $td = db_fetch_row('SELECT * FROM thold_data WHERE id=' . $template_data_rrd['thold_id']); } else { $td = array(); } $cur_setting = ''; if (!sizeof($td)) { $cur_setting .= "<span style='padding-right:4px;'>" . __('N/A') . "</span>"; } else { $cur_setting = '<span style="padding-right:4px;">' . __('Last:') . '</span>' . ($td['lastread'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceDown'>" . thold_format_number($td['lastread'], 4) . "</span>"); if ($td['thold_type'] != 1) { if ($td['thold_warning_fail_trigger'] != 0) { if ($td['thold_warning_hi'] != '') { $cur_setting .= '<span style="padding:4px">' . __('WHi:') . '</span>' . ($td['thold_warning_hi'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceRecovering'>" . thold_format_number($td['thold_warning_hi'], 2) . '</span>'); } if ($td['thold_warning_low'] != '') { $cur_setting .= '<span style="padding:4px">' . __('WLo:') . '</span>' . ($td['thold_warning_low'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceRecovering'>" . thold_format_number($td['thold_warning_low'], 2) . '</span>'); } } if ($td['thold_fail_trigger'] != 0) { if ($td['thold_hi'] != '') { $cur_setting .= '<span style="padding:4px">' . __('AHi:') . '</span>' . ($td['thold_hi'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceRecovering'>" . thold_format_number($td['thold_hi'], 2) . '</span>'); } if ($td['thold_low'] != '') { $cur_setting .= '<span style="padding:4px">' . __('ALo:') . '</span>' . ($td['thold_low'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceRecovering'>" . thold_format_number($td['thold_low'], 2) . '</span>'); } } } else { $cur_setting .= '<span style="padding:4px">' . __('AHi:') . '</span>' . ($td['thold_hi'] == '' ? "<span>" . __('N/A') . "</span>" : "<span clas='deviceRecovering'>" . thold_format_number($td['thold_hi'], 2) . '</span>'); $cur_setting .= '<span style="padding:4px">' . __('ALo:') . '</span>' . ($td['thold_low'] == '' ? "<span>" . __('N/A') . "</span>" : "<span class='deviceRecovering'>" . thold_format_number($td['thold_low'], 2) . '</span>'); $cur_setting .= '<span>' . __('BL: (Up %s %/Down %s %)', $td['bl_pct_up'], $td['bl_pct_down']) . '</span>'; } } if ($template_data_rrd['id'] == $thold_data['data_template_rrd_id']) { $selected = 'selected'; } else { $selected = ''; } if (!empty($template_data_rrd['thold_id'])) { echo "<li class='textEditTitle'><a class='hyperLink {$selected}' href='" . htmlspecialchars('thold.php?action=edit&id=' . $template_data_rrd['thold_id']) . "'>" . $template_data_rrd['data_source_name'] . '<br>' . $cur_setting . '</a></li>'; } else { echo "<li class='textEditTitle'><a class='hyperLink {$selected}' href='" . htmlspecialchars('thold.php?action=edit&local_data_id=' . $template_data_rrd['local_data_id'] . '&data_template_rrd_id=' . $template_data_rrd['id']) . '&local_graph_id=' . $thold_data['local_graph_id'] . '&host_id=' . $thold_data['host_id'] . '&data_template_id=' . $thold_data['data_template_id'] . '&thold_template_id=0' . "'>" . $template_data_rrd['data_source_name'] . '<br>' . $cur_setting . '</a></li>'; } } echo "<li class='textEditTitle'><a class='hyperLink' href='" . htmlspecialchars('thold.php?action=add' . '&local_graph_id=' . $thold_data['local_graph_id'] . '&host_id=' . $thold_data['host_id']) . "'>new thold<br>n/a</a></li>"; print "</ul></nav></div>\n"; } elseif (sizeof($template_data_rrds) == 1) { set_request_var('data_template_rrd_id', $template_data_rrds[0]['id']); } } //---------------------- // Data Source Item Form //---------------------- $thold_data_cdef = isset($thold_data['cdef']) ? $thold_data['cdef'] : 0; if (isset($thold_data['template'])) { $thold_data['template_name'] = db_fetch_cell_prepared('SELECT name FROM thold_template WHERE id = ?', array($thold_data['thold_template_id'])); } $header_text = __('Data Source Item [%s] ' . ' - Current value: [%s]', isset($template_rrd) ? $template_rrd['data_source_name'] : '', get_current_value($thold_data['local_data_id'], $ds, $thold_data_cdef)); html_start_box($header_text, '100%', '', '3', 'center', ''); $send_notification_array = array(); $users = db_fetch_assoc("SELECT plugin_thold_contacts.id, plugin_thold_contacts.data,\n\t\tplugin_thold_contacts.type, user_auth.full_name\n\t\tFROM plugin_thold_contacts, user_auth\n\t\tWHERE user_auth.id=plugin_thold_contacts.user_id\n\t\tAND plugin_thold_contacts.data!=''\n\t\tORDER BY user_auth.full_name ASC, plugin_thold_contacts.type ASC"); if (!empty($users)) { foreach ($users as $user) { $send_notification_array[$user['id']] = $user['full_name'] . ' - ' . ucfirst($user['type']); } } if (isset($thold_data['id'])) { $sql = 'SELECT contact_id as id FROM plugin_thold_threshold_contact WHERE thold_id=' . $thold_data['id']; $step = db_fetch_cell('SELECT rrd_step FROM data_template_data WHERE local_data_id = ' . $thold_data['local_data_id'], FALSE); } else { $sql = 'SELECT contact_id as id FROM plugin_thold_threshold_contact WHERE thold_id=0'; $step = db_fetch_cell('SELECT rrd_step FROM data_template_data WHERE local_data_id = ' . $thold_data['local_data_id'], FALSE); } include $config['base_path'] . '/plugins/thold/includes/arrays.php'; $data_fields = array(); $reference_types = get_reference_types($thold_data['local_data_id'], $step, $timearray); $temp = db_fetch_assoc('SELECT id, local_data_template_rrd_id, data_source_name, data_input_field_id FROM data_template_rrd WHERE local_data_id=' . $thold_data['local_data_id']); foreach ($temp as $d) { if ($d['data_input_field_id'] != 0) { $name = db_fetch_cell('SELECT name FROM data_input_fields WHERE id=' . $d['data_input_field_id']); } else { $name = $d['data_source_name']; } if ($d['id'] != $thold_data['data_template_rrd_id']) { $data_fields[$d['data_source_name']] = $name; } } $replacements = db_fetch_assoc_prepared('SELECT DISTINCT field_name FROM data_local AS dl INNER JOIN host_snmp_cache AS hsc ON dl.snmp_query_id=hsc.snmp_query_id AND dl.host_id=hsc.host_id WHERE dl.id = ?', array($thold_data['data_template_id'])); $nr = array(); if (sizeof($replacements)) { foreach ($replacements as $r) { $nr[] = "<span class='deviceUp'>|query_" . $r['field_name'] . "|</span>"; } } $vhf = explode('|', trim(VALID_HOST_FIELDS, '()')); if (sizeof($vhf)) { foreach ($vhf as $r) { $nr[] = "<span class='deviceUp'>|" . $r . "|</span>"; } } $replacements = "<br>" . __('Replacement Fields: %s', implode(", ", $nr)); $dss = db_fetch_assoc_prepared('SELECT data_source_name FROM data_template_rrd WHERE local_data_id = ?', array($thold_data['local_data_id'])); if (sizeof($dss)) { foreach ($dss as $ds) { $dsname[] = "<span class='deviceUp'>|ds:" . $ds["data_source_name"] . "|</span>"; } } $datasources = "<br>" . __('Data Sources: %s', implode(", ", $dsname)); $form_array = array('template_header' => array('friendly_name' => __('Template Settings'), 'method' => 'spacer'), 'template_enabled' => array('friendly_name' => __('Template Propagation Enabled'), 'method' => 'checkbox', 'default' => '', 'description' => __('Whether or not these settings will be propagates from the threshold template.'), 'value' => !empty($thold_data['template_enabled']) ? $thold_data['template_enabled'] : ''), 'template_name' => array('friendly_name' => __('Template Name'), 'method' => 'custom', 'default' => '', 'description' => __('Name of the Threshold Template the threshold was created from.'), 'value' => isset($thold_data['template_name']) ? $thold_data['template_name'] : 'N/A'), 'general_header' => array('friendly_name' => __('General Settings'), 'method' => 'spacer'), 'name' => array('friendly_name' => __('Threshold Name'), 'method' => 'textbox', 'max_length' => 100, 'size' => '70', 'default' => $desc . ' [' . $template_rrd['data_source_name'] . ']', 'description' => __('Provide the Thresholds a meaningful name'), 'value' => isset($thold_data['name']) ? $thold_data['name'] : ''), 'thold_enabled' => array('friendly_name' => __('Threshold Enabled'), 'method' => 'checkbox', 'default' => 'on', 'description' => __('Whether or not this threshold will be checked and alerted upon.'), 'value' => isset($thold_data['thold_enabled']) ? $thold_data['thold_enabled'] : ''), 'exempt' => array('friendly_name' => __('Weekend Exemption'), 'description' => __('If this is checked, this Threshold will not alert on weekends.'), 'method' => 'checkbox', 'default' => '', 'value' => isset($thold_data['exempt']) ? $thold_data['exempt'] : ''), 'restored_alert' => array('friendly_name' => __('Disable Restoration Email'), 'description' => __('If this is checked, Thold will not send an alert when the threshold has returned to normal status.'), 'method' => 'checkbox', 'default' => '', 'value' => isset($thold_data['restored_alert']) ? $thold_data['restored_alert'] : ''), 'thold_type' => array('friendly_name' => __('Threshold Type'), 'method' => 'drop_array', 'on_change' => 'changeTholdType()', 'array' => $thold_types, 'default' => read_config_option('thold_type'), 'description' => __('The type of Threshold that will be monitored.'), 'value' => isset($thold_data['thold_type']) ? $thold_data['thold_type'] : ''), 'repeat_alert' => array('friendly_name' => __('Re-Alert Cycle'), 'method' => 'drop_array', 'array' => $repeatarray, 'default' => read_config_option('alert_repeat'), 'description' => __('Repeat alert after this amount of time has pasted since the last alert.'), 'value' => isset($thold_data['repeat_alert']) ? $thold_data['repeat_alert'] : ''), 'thold_warning_header' => array('friendly_name' => __('Warning - High / Low Settings'), 'method' => 'spacer'), 'thold_warning_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, warning will be triggered'), 'value' => isset($thold_data['thold_warning_hi']) ? $thold_data['thold_warning_hi'] : ''), 'thold_warning_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, warning will be triggered'), 'value' => isset($thold_data['thold_warning_low']) ? $thold_data['thold_warning_low'] : ''), 'thold_warning_fail_trigger' => array('friendly_name' => __('Breach Duration'), 'method' => 'drop_array', 'array' => $alertarray, 'description' => __('The amount of time the data source must be in breach of the threshold for a warning to be raised.'), 'value' => isset($thold_data['thold_warning_fail_trigger']) ? $thold_data['thold_warning_fail_trigger'] : read_config_option('alert_trigger')), 'thold_header' => array('friendly_name' => __('Alert - High / Low Settings'), 'method' => 'spacer'), 'thold_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, alert will be triggered'), 'value' => isset($thold_data['thold_hi']) ? $thold_data['thold_hi'] : ''), 'thold_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, alert will be triggered'), 'value' => isset($thold_data['thold_low']) ? $thold_data['thold_low'] : ''), 'thold_fail_trigger' => array('friendly_name' => __('Breach Duration'), 'method' => 'drop_array', 'array' => $alertarray, 'description' => __('The amount of time the data source must be in breach of the threshold for an alert to be raised.'), 'value' => isset($thold_data['thold_fail_trigger']) ? $thold_data['thold_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_header' => array('friendly_name' => __('Warning - Time Based Settings'), 'method' => 'spacer'), 'time_warning_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, warning will be triggered'), 'value' => isset($thold_data['time_warning_hi']) ? $thold_data['time_warning_hi'] : ''), 'time_warning_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, warning will be triggered'), 'value' => isset($thold_data['time_warning_low']) ? $thold_data['time_warning_low'] : ''), 'time_warning_fail_trigger' => array('friendly_name' => __('Breach Count'), 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'description' => __('The number of times the data source must be in breach of the threshold.'), 'value' => isset($thold_data['time_warning_fail_trigger']) ? $thold_data['time_warning_fail_trigger'] : read_config_option('thold_warning_time_fail_trigger')), 'time_warning_fail_length' => array('friendly_name' => __('Breach Window'), 'method' => 'drop_array', 'array' => $timearray, 'description' => __('The amount of time in the past to check for threshold breaches.'), 'value' => isset($thold_data['time_warning_fail_length']) ? $thold_data['time_warning_fail_length'] : (read_config_option('thold_warning_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1)), 'time_header' => array('friendly_name' => __('Alert - Time Based Settings'), 'method' => 'spacer'), 'time_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, alert will be triggered'), 'value' => isset($thold_data['time_hi']) ? $thold_data['time_hi'] : ''), 'time_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, alert will be triggered'), 'value' => isset($thold_data['time_low']) ? $thold_data['time_low'] : ''), 'time_fail_trigger' => array('friendly_name' => __('Breach Count'), 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'default' => read_config_option('thold_time_fail_trigger'), 'description' => __('The number of times the data source must be in breach of the threshold.'), 'value' => isset($thold_data['time_fail_trigger']) ? $thold_data['time_fail_trigger'] : read_config_option('thold_time_fail_trigger')), 'time_fail_length' => array('friendly_name' => __('Breach Window'), 'method' => 'drop_array', 'array' => $timearray, 'description' => __('The amount of time in the past to check for threshold breaches.'), 'value' => isset($thold_data['time_fail_length']) ? $thold_data['time_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_time_fail_length') : 1)), 'baseline_header' => array('friendly_name' => __('Baseline Settings'), 'method' => 'spacer'), 'bl_ref_time_range' => array('friendly_name' => __('Time range'), 'method' => 'drop_array', 'array' => $reference_types, 'description' => __('Specifies the point in the past (based on rrd resolution) that will be used as a reference'), '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' => __('Deviation UP'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Specifies allowed deviation in percentage for the upper bound threshold. If not set, upper bound threshold will not be checked at all.'), 'value' => isset($thold_data['bl_pct_up']) ? $thold_data['bl_pct_up'] : ''), 'bl_pct_down' => array('friendly_name' => __('Deviation DOWN'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Specifies allowed deviation in percentage for the lower bound threshold. If not set, lower bound threshold will not be checked at all.'), 'value' => isset($thold_data['bl_pct_down']) ? $thold_data['bl_pct_down'] : ''), 'bl_fail_trigger' => array('friendly_name' => __('Baseline Trigger Count'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Number of consecutive times the data source must be in breach of the baseline threshold for an alert to be raised.<br>Leave empty to use default value (<b>Default: %s cycles</b>)', read_config_option('alert_bl_trigger')), 'value' => isset($thold_data['bl_fail_trigger']) ? $thold_data['bl_fail_trigger'] : read_config_option("alert_bl_trigger")), 'data_manipulation' => array('friendly_name' => __('Data Manipulation'), 'method' => 'spacer'), 'data_type' => array('friendly_name' => __('Data Type'), 'method' => 'drop_array', 'on_change' => 'changeDataType()', 'array' => $data_types, 'default' => read_config_option('data_type'), 'description' => __('Special formatting for the given data.'), 'value' => isset($thold_data['data_type']) ? $thold_data['data_type'] : ''), 'cdef' => array('friendly_name' => __('Threshold CDEF'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Apply this CDEF before returning the data.'), 'value' => isset($thold_data['cdef']) ? $thold_data['cdef'] : 0, 'array' => thold_cdef_select_usable_names()), 'percent_ds' => array('friendly_name' => __('Percent Datasource'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Second Datasource Item to use as total value to calculate percentage from.'), 'value' => isset($thold_data['percent_ds']) ? $thold_data['percent_ds'] : 0, 'array' => $data_fields), 'expression' => array('friendly_name' => __('RPN Expression'), 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 80, 'default' => '', 'description' => __('An RPN Expression is an RRDtool Compatible RPN Expression. Syntax includes all functions below in addition to both Device and Data Query replacement expressions such as <span class="deviceUp">|query_ifSpeed|</span>. To use a Data Source in the RPN Expression, you must use the syntax: <span class="deviceUp">|ds:dsname|</span>. For example, <span class="deviceUp">|ds:traffic_in|</span> will get the current value of the traffic_in Data Source for the RRDfile(s) associated with the Graph. Any Data Source for a Graph can be included.<br><br>Math Operators: <span class="deviceUp">+, -, /, *, %, ^</span><br>Functions: <span class="deviceUp">SIN, COS, TAN, ATAN, SQRT, FLOOR, CEIL, DEG2RAD, RAD2DEG, ABS, EXP, LOG, ATAN, ADNAN</span><br>Flow Operators: <span class="deviceUp">UN, ISINF, IF, LT, LE, GT, GE, EQ, NE</span><br>Comparison Functions: <span class="deviceUp">MAX, MIN, INF, NEGINF, NAN, UNKN, COUNT, PREV</span>%s %s', $replacements, $datasources), 'value' => isset($thold_data['expression']) ? $thold_data['expression'] : '', 'max_length' => '255', 'size' => '80'), 'other_header' => array('friendly_name' => __('Other Settings'), 'method' => 'spacer'), 'notify_warning' => array('friendly_name' => __('Warning Notification List'), 'method' => 'drop_sql', 'description' => __('You may specify choose a Notification List to receive Warnings for this Data Source'), 'value' => isset($thold_data['notify_warning']) ? $thold_data['notify_warning'] : '', 'none_value' => __('None'), 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name'), 'notify_alert' => array('friendly_name' => __('Alert Notification List'), 'method' => 'drop_sql', 'description' => __('You may specify choose a Notification List to receive Alerts for this Data Source'), 'value' => isset($thold_data['notify_alert']) ? $thold_data['notify_alert'] : '', 'none_value' => __('None'), 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name')); if (read_config_option("thold_alert_snmp") == 'on') { $extra = array('snmp_event_category' => array('friendly_name' => __('SNMP Notification - Event Category'), 'method' => 'textbox', 'description' => __('To allow a NMS to categorize different SNMP notifications more easily please fill in the category SNMP notifications for this template should make use of. E.g.: "disk_usage", "link_utilization", "ping_test", "nokia_firewall_cpu_utilization" ...'), 'value' => isset($thold_data['snmp_event_category']) ? $thold_data['snmp_event_category'] : '', 'default' => '', 'max_length' => '255'), 'snmp_event_severity' => array('friendly_name' => __('SNMP Notification - Alert Event Severity'), 'method' => 'drop_array', 'default' => '3', 'description' => __('Severity to be used for alerts. (low impact -> critical impact)'), 'value' => isset($thold_data['snmp_event_severity']) ? $thold_data['snmp_event_severity'] : 3, 'array' => array(1 => __('Low'), 2 => __('Medium'), 3 => __('High'), 4 => __('Critical')))); $form_array += $extra; if (read_config_option('thold_alert_snmp_warning') != 'on') { $extra = array('snmp_event_warning_severity' => array('friendly_name' => __('SNMP Notification - Warning Event Severity'), 'method' => 'drop_array', 'default' => '2', 'description' => __('Severity to be used for warnings. (Low impact -> Critical impact).<br>Note: The severity of warnings has to be equal or lower than the severity being defined for alerts.'), 'value' => isset($thold_data['snmp_event_warning_severity']) ? $thold_data['snmp_event_warning_severity'] : 2, 'array' => array(1 => __('Low'), 2 => __('Medium'), 3 => __('High'), 4 => __('Critical')))); } $form_array += $extra; } if (read_config_option('thold_disable_legacy') != 'on') { $extra = array('notify_accounts' => array('friendly_name' => __('Notify accounts'), 'method' => 'drop_multi', 'description' => __('This is a listing of accounts that will be notified when this threshold is breached.<br><br><br><br>'), 'array' => $send_notification_array, 'sql' => $sql), 'notify_extra' => array('friendly_name' => __('Alert Emails'), 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => __('You may specify here extra Emails to receive alerts for this data source (comma separated)'), 'value' => isset($thold_data['notify_extra']) ? $thold_data['notify_extra'] : ''), 'notify_warning_extra' => array('friendly_name' => __('Warning Emails'), 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => __('You may specify here extra Emails to receive warnings for this data source (comma separated)'), 'value' => isset($thold_data['notify_warning_extra']) ? $thold_data['notify_warning_extra'] : '')); $form_array += $extra; } else { $extra = array('notify_accounts' => array('method' => 'hidden', 'value' => 'ignore'), 'notify_extra' => array('method' => 'hidden', 'value' => isset($thold_data['notify_extra']) ? $thold_data['notify_extra'] : ''), 'notify_warning_extra' => array('method' => 'hidden', 'value' => isset($thold_data['notify_warning_extra']) ? $thold_data['notify_warning_extra'] : '')); $form_array += $extra; } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array + array('id' => array('method' => 'hidden', 'value' => !empty($thold_data['id']) ? $thold_data['id'] : '0'), 'data_template_rrd_id' => array('method' => 'hidden', 'value' => isset($template_rrd) ? $template_rrd['id'] : '0'), 'host_id' => array('method' => 'hidden', 'value' => $thold_data['host_id']), 'local_data_id' => array('method' => 'hidden', 'value' => $thold_data['local_data_id'])))); html_end_box(); if (isset($_SESSION['data_return'])) { $ajax = false; } else { $ajax = true; } form_save_button('thold.php' . (!empty($thold_data['id']) ? '?id=' . $thold_data['id'] : ''), 'return', 'id', $ajax); ?> <script type='text/javascript'> function templateEnableDisable() { var status = $('#template_enabled').is(':checked'); $('#name').prop('disabled', status); $('#thold_type').prop('disabled', status); $('#thold_hi').prop('disabled', status); $('#thold_low').prop('disabled', status); $('#thold_fail_trigger').prop('disabled', status); $('#thold_warning_hi').prop('disabled', status); $('#thold_warning_low').prop('disabled', status); $('#thold_warning_fail_trigger').prop('disabled', status); $('#repeat_alert').prop('disabled', status); $('#notify_extra').prop('disabled', status); $('#notify_warning_extra').prop('disabled', status); $('#notify_warning').prop('disabled', status); $('#notify_alert').prop('disabled', status); $('#cdef').prop('disabled', status); $('#thold_enabled').prop('disabled', status); if ($('#notify_accounts')) $('#notify_accounts').prop('disabled', status); $('#time_hi').prop('disabled', status); $('#time_low').prop('disabled', status); $('#time_fail_trigger').prop('disabled', status); $('#time_fail_length').prop('disabled', status); $('#time_warning_hi').prop('disabled', status); $('#time_warning_low').prop('disabled', status); $('#time_warning_fail_trigger').prop('disabled', status); $('#time_warning_fail_length').prop('disabled', status); $('#data_type').prop('disabled', status); $('#percent_ds').prop('disabled', status); $('#expression').prop('disabled', status); $('#exempt').prop('disabled', status); $('#restored_alert').prop('disabled', status); if ($('#snmp_event_category')) $('#snmp_event_category').prop('disabled', status); if ($('#snmp_event_severity')) $('#snmp_event_severity').prop('disabled', status); if ($('#snmp_event_warning_severity')) $('#snmp_event_warning_severity').prop('disabled', status); } function changeTholdType() { switch($('#thold_type').val()) { case '0': thold_toggle_hilow(''); thold_toggle_baseline('none'); thold_toggle_time('none'); break; case '1': thold_toggle_hilow('none'); thold_toggle_baseline(''); thold_toggle_time('none'); break; case '2': thold_toggle_hilow('none'); thold_toggle_baseline('none'); thold_toggle_time(''); break; } } function changeDataType () { switch($('#data_type').val()) { case '0': $('#row_cdef').hide(); $('#row_percent_ds').hide(); $('#row_expression').hide(); break; case '1': $('#row_cdef').show(); $('#row_percent_ds').hide(); $('#row_expression').hide(); break; case '2': $('#row_cdef').hide() $('#row_percent_ds').show(); $('#row_expression').hide(); break; case '3': $('#row_expression').show(); $('#row_cdef').hide(); $('#row_percent_ds').hide(); break; } } function thold_toggle_hilow (status) { if (status == '') { $('#row_thold_header, #row_thold_hi, #row_thold_low, #row_thold_fail_trigger').show(); $('#row_thold_warning_header, #row_thold_warning_hi').show(); $('#row_thold_warning_low, #row_thold_warning_fail_trigger').show(); }else{ $('#row_thold_header, #row_thold_hi, #row_thold_low, #row_thold_fail_trigger').hide(); $('#row_thold_warning_header, #row_thold_warning_hi').hide(); $('#row_thold_warning_low, #row_thold_warning_fail_trigger').hide(); } } function thold_toggle_baseline(status) { if (status == '') { $('#row_baseline_header, #row_bl_ref_time_range').show(); $('#row_bl_pct_up, #row_bl_pct_down, #row_bl_fail_trigger').show(); }else{ $('#row_baseline_header, #row_bl_ref_time_range').hide(); $('#row_bl_pct_up, #row_bl_pct_down, #row_bl_fail_trigger').hide(); } } function thold_toggle_time(status) { if (status == '') { $('#row_time_header, #row_time_hi, #row_time_low, #row_time_fail_trigger, #row_time_fail_length').show(); $('#row_time_warning_header, #row_time_warning_hi, #row_time_warning_low').show(); $('#row_time_warning_fail_trigger, #row_time_warning_fail_length').show(); }else{ $('#row_time_header, #row_time_hi, #row_time_low, #row_time_fail_trigger, #row_time_fail_length').hide(); $('#row_time_warning_header, #row_time_warning_hi, #row_time_warning_low').hide(); $('#row_time_warning_fail_trigger, #row_time_warning_fail_length').hide(); } } function graphImage() { var id = $('#element').val(); $('#graphimage').attr(src, '../../graph_image.php?local_graph_id=' + id + '&rra_id=0&graph_start=-32400&graph_height=100&graph_width=300&graph_nolegend=true').change(); } $(function() { if ('<?php print $thold_data['thold_template_id']; ?> ' == '0') { $('#template_enabled').prop('disabled', true); } if ($('#notify_accounts option').length == 0) { $('#row_notify_accounts').hide(); } if ($('#notify_warning option').length == 0) { $('#row_notify_warning').hide(); } if ($('#notify_alert option').length == 0) { $('#row_notify_alert').hide(); } $('#notify_accounts').multiselect({ minWidth: '400', noneSelectedText: '<?php print __('Select Users(s)'); ?> ', selectedText: function(numChecked, numTotal, checkedItems) { myReturn = numChecked + ' <?php print __('Users Selected'); ?> '; $.each(checkedItems, function(index, value) { if (value.value == '0') { myReturn='<?php print __('All Users Selected'); ?> '; return false; } }); return myReturn; }, checkAllText: 'All', uncheckAllText: 'None', uncheckall: function() { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).prop('checked', true); }); }, open: function() { size = $('#notify_accounts option').length * 18 + 20; if (size > 100) { size = 100; } $('ul.ui-multiselect-checkboxes').css('height', size + 'px'); }, click: function(event, ui) { checked=$(this).multiselect('widget').find('input:checked').length; if (ui.value == '0') { if (ui.checked == true) { $('#host').multiselect('uncheckAll'); $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).prop('checked', true); }); } }else if (checked == 0) { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).click(); }); }else if ($(this).multiselect('widget').find('input:checked:first').val() == '0') { if (checked > 0) { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).click(); $(this).prop('disable', true); }); } } } }).multiselectfilter( { label: 'Search', width: '150' }); templateEnableDisable(); $('#template_enabled').click(function() { templateEnableDisable(); }); <?php if (!isset($thold_data['thold_template_id']) || $thold_data['thold_template_id'] == '') { ?> $('#templated_enabled').prop('disabled', true); <?php } ?> changeTholdType (); changeDataType (); $('#element').change(function() { graphImage; }); }); </script> <?php }
} $vhf = explode("|", trim(VALID_HOST_FIELDS, "()")); if (sizeof($vhf)) { foreach ($vhf as $r) { $nr[] = "<span style='color:blue;'>|" . $r . "|</span>"; } } $replacements = "<br><b>Replacement Fields:</b> " . implode(", ", $nr); $dss = db_fetch_assoc("SELECT data_source_name FROM data_template_rrd WHERE local_data_id=" . $rra); if (sizeof($dss)) { foreach ($dss as $ds) { $dsname[] = "<span style='color:blue;'>|ds:" . $ds["data_source_name"] . "|</span>"; } } $datasources = "<br><b>Data Sources:</b> " . implode(", ", $dsname); $form_array = array('template_header' => array('friendly_name' => 'Template settings', 'method' => 'spacer'), 'template_enabled' => array('friendly_name' => 'Template Propagation Enabled', 'method' => 'checkbox', 'default' => '', 'description' => 'Whether or not these settings will be propagates from the threshold template.', 'value' => isset($thold_item_data['template_enabled']) ? $thold_item_data['template_enabled'] : ''), 'general_header' => array('friendly_name' => 'Mandatory settings', 'method' => 'spacer'), 'name' => array('friendly_name' => 'Threshold Name', 'method' => 'textbox', 'max_length' => 100, 'size' => '70', 'default' => $desc . ' [' . $template_rrd['data_source_name'] . ']', 'description' => 'Provide the THold a meaningful name', 'value' => isset($thold_item_data['name']) ? $thold_item_data['name'] : ''), 'thold_enabled' => array('friendly_name' => 'Threshold Enabled', 'method' => 'checkbox', 'default' => 'on', 'description' => 'Whether or not this threshold will be checked and alerted upon.', 'value' => isset($thold_item_data['thold_enabled']) ? $thold_item_data['thold_enabled'] : ''), 'exempt' => array('friendly_name' => 'Weekend Exemption', 'description' => 'If this is checked, this Threshold will not alert on weekends.', 'method' => 'checkbox', 'default' => 'off', 'value' => isset($thold_item_data['exempt']) ? $thold_item_data['exempt'] : ''), 'restored_alert' => array('friendly_name' => 'Disable Restoration Email', 'description' => 'If this is checked, Thold will not send an alert when the threshold has returned to normal status.', 'method' => 'checkbox', 'default' => 'off', 'value' => isset($thold_item_data['restored_alert']) ? $thold_item_data['restored_alert'] : ''), 'thold_type' => array('friendly_name' => 'Threshold Type', 'method' => 'drop_array', 'on_change' => 'changeTholdType()', 'array' => $thold_types, 'default' => read_config_option('thold_type'), 'description' => 'The type of Threshold that will be monitored.', 'value' => isset($thold_item_data['thold_type']) ? $thold_item_data['thold_type'] : ''), 'repeat_alert' => array('friendly_name' => 'Re-Alert Cycle', 'method' => 'drop_array', 'array' => $repeatarray, 'default' => read_config_option('alert_repeat'), 'description' => 'Repeat alert after this amount of time has pasted since the last alert.', 'value' => isset($thold_item_data['repeat_alert']) ? $thold_item_data['repeat_alert'] : ''), 'thold_warning_header' => array('friendly_name' => 'Warning High / Low Settings', 'method' => 'spacer'), 'thold_warning_hi' => array('friendly_name' => 'Warning High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, warning will be triggered', 'value' => isset($thold_item_data['thold_warning_hi']) ? $thold_item_data['thold_warning_hi'] : ''), 'thold_warning_low' => array('friendly_name' => 'Warning Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, warning will be triggered', 'value' => isset($thold_item_data['thold_warning_low']) ? $thold_item_data['thold_warning_low'] : ''), 'thold_warning_fail_trigger' => array('friendly_name' => 'Warning Breach Duration', 'method' => 'drop_array', 'array' => $alertarray, 'description' => 'The amount of time the data source must be in breach of the threshold for a warning to be raised.', 'value' => isset($thold_item_data['thold_warning_fail_trigger']) ? $thold_item_data['thold_warning_fail_trigger'] : read_config_option('alert_trigger')), 'thold_header' => array('friendly_name' => 'Alert High / Low Settings', 'method' => 'spacer'), 'thold_hi' => array('friendly_name' => 'High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, alert will be triggered', 'value' => isset($thold_item_data['thold_hi']) ? $thold_item_data['thold_hi'] : ''), 'thold_low' => array('friendly_name' => 'Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, alert will be triggered', 'value' => isset($thold_item_data['thold_low']) ? $thold_item_data['thold_low'] : ''), 'thold_fail_trigger' => array('friendly_name' => 'Breach Duration', 'method' => 'drop_array', 'array' => $alertarray, 'description' => 'The amount of time the data source must be in breach of the threshold for an alert to be raised.', 'value' => isset($thold_item_data['thold_fail_trigger']) ? $thold_item_data['thold_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_header' => array('friendly_name' => 'Warning Time Based Settings', 'method' => 'spacer'), 'time_warning_hi' => array('friendly_name' => 'Warning High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, warning will be triggered', 'value' => isset($thold_item_data['time_warning_hi']) ? $thold_item_data['time_warning_hi'] : ''), 'time_warning_low' => array('friendly_name' => 'Warning Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, warning will be triggered', 'value' => isset($thold_item_data['time_warning_low']) ? $thold_item_data['time_warning_low'] : ''), 'time_warning_fail_trigger' => array('friendly_name' => 'Warning Breach Count', 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'description' => 'The number of times the data source must be in breach of the threshold.', 'value' => isset($thold_item_data['time_warning_fail_trigger']) ? $thold_item_data['time_warning_fail_trigger'] : read_config_option('thold_warning_time_fail_trigger')), 'time_warning_fail_length' => array('friendly_name' => 'Warning Breach Window', 'method' => 'drop_array', 'array' => $timearray, 'description' => 'The amount of time in the past to check for threshold breaches.', 'value' => isset($thold_item_data['time_warning_fail_length']) ? $thold_item_data['time_warning_fail_length'] : (read_config_option('thold_warning_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1)), 'time_header' => array('friendly_name' => 'Time Based Settings', 'method' => 'spacer'), 'time_hi' => array('friendly_name' => 'High Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes above this number, alert will be triggered', 'value' => isset($thold_item_data['time_hi']) ? $thold_item_data['time_hi'] : ''), 'time_low' => array('friendly_name' => 'Low Threshold', 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => 'If set and data source value goes below this number, alert will be triggered', 'value' => isset($thold_item_data['time_low']) ? $thold_item_data['time_low'] : ''), 'time_fail_trigger' => array('friendly_name' => 'Breach Count', 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'default' => read_config_option('thold_time_fail_trigger'), 'description' => 'The number of times the data source must be in breach of the threshold.', 'value' => isset($thold_item_data['time_fail_trigger']) ? $thold_item_data['time_fail_trigger'] : read_config_option('thold_time_fail_trigger')), 'time_fail_length' => array('friendly_name' => 'Breach Window', 'method' => 'drop_array', 'array' => $timearray, 'description' => 'The amount of time in the past to check for threshold breaches.', 'value' => isset($thold_item_data['time_fail_length']) ? $thold_item_data['time_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_time_fail_length') : 1)), 'baseline_header' => array('friendly_name' => 'Baseline Settings', 'method' => 'spacer'), 'bl_ref_time_range' => array('friendly_name' => 'Time range', 'method' => 'drop_array', 'array' => $reference_types, 'description' => 'Specifies the point in the past (based on rrd resolution) that will be used as a reference', 'value' => isset($thold_item_data['bl_ref_time_range']) ? $thold_item_data['bl_ref_time_range'] : read_config_option('alert_bl_timerange_def')), 'bl_pct_up' => array('friendly_name' => 'Baseline Deviation UP', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Specifies allowed deviation in percentage for the upper bound threshold. If not set, upper bound threshold will not be checked at all.', 'value' => isset($thold_item_data['bl_pct_up']) ? $thold_item_data['bl_pct_up'] : ''), 'bl_pct_down' => array('friendly_name' => 'Baseline Deviation DOWN', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Specifies allowed deviation in percentage for the lower bound threshold. If not set, lower bound threshold will not be checked at all.', 'value' => isset($thold_item_data['bl_pct_down']) ? $thold_item_data['bl_pct_down'] : ''), 'bl_fail_trigger' => array('friendly_name' => 'Baseline Trigger Count', 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => 'Number of consecutive times the data source must be in breach of the baseline threshold for an alert to be raised.<br>Leave empty to use default value (<b>Default: ' . read_config_option('alert_bl_trigger') . ' cycles</b>)', 'value' => isset($thold_item_data['bl_fail_trigger']) ? $thold_item_data['bl_fail_trigger'] : read_config_option("alert_bl_trigger")), 'data_manipulation' => array('friendly_name' => 'Data Manipulation', 'method' => 'spacer'), 'data_type' => array('friendly_name' => 'Data Type', 'method' => 'drop_array', 'on_change' => 'changeDataType()', 'array' => $data_types, 'default' => read_config_option('data_type'), 'description' => 'Special formatting for the given data.', 'value' => isset($thold_item_data['data_type']) ? $thold_item_data['data_type'] : ''), 'cdef' => array('friendly_name' => 'Threshold CDEF', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Apply this CDEF before returning the data.', 'value' => isset($thold_item_data['cdef']) ? $thold_item_data['cdef'] : 0, 'array' => thold_cdef_select_usable_names()), 'percent_ds' => array('friendly_name' => 'Percent Datasource', 'method' => 'drop_array', 'default' => 'NULL', 'description' => 'Second Datasource Item to use as total value to calculate percentage from.', 'value' => isset($thold_item_data['percent_ds']) ? $thold_item_data['percent_ds'] : 0, 'array' => $data_fields), 'expression' => array('friendly_name' => 'RPN Expression', 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 80, 'default' => '', 'description' => 'An RPN Expression is an RRDtool Compatible RPN Expression. Syntax includes all functions below in addition to both Host and Data Query replacement expressions such as <span style="color:blue;">|query_ifSpeed|</span>. To use a Data Source in the RPN Expression, you must use the syntax: <span style="color:blue;">|ds:dsname|</span>. For example, <span style="color:blue;">|ds:traffic_in|</span> will get the current value of the traffic_in Data Source for the RRDfile(s) associated with the Graph. Any Data Source for a Graph can be included.<br><b>Math Operators:</b> <span style="color:blue;">+, -, /, *, %, ^</span><br><b>Functions:</b> <span style="color:blue;">SIN, COS, TAN, ATAN, SQRT, FLOOR, CEIL, DEG2RAD, RAD2DEG, ABS, EXP, LOG, ATAN, ADNAN</span><br><b>Flow Operators:</b> <span style="color:blue;">UN, ISINF, IF, LT, LE, GT, GE, EQ, NE</span><br><b>Comparison Functions:</b> <span style="color:blue;">MAX, MIN, INF, NEGINF, NAN, UNKN, COUNT, PREV</span>' . $replacements . $datasources, 'value' => isset($thold_item_data['expression']) ? $thold_item_data['expression'] : '', 'max_length' => '255', 'size' => '80'), 'other_header' => array('friendly_name' => 'Other Settings', 'method' => 'spacer'), 'notify_warning' => array('friendly_name' => 'Warning Notification List', 'method' => 'drop_sql', 'description' => 'You may specify choose a Notification List to receive Warnings for this Data Source', 'value' => isset($thold_item_data['notify_warning']) ? $thold_item_data['notify_warning'] : '', 'none_value' => 'None', 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name'), 'notify_alert' => array('friendly_name' => 'Alert Notification List', 'method' => 'drop_sql', 'description' => 'You may specify choose a Notification List to receive Alerts for this Data Source', 'value' => isset($thold_item_data['notify_alert']) ? $thold_item_data['notify_alert'] : '', 'none_value' => 'None', 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name')); /* modify for multi user start */ if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) { $form_array["notify_warning"]["sql"] = "SELECT plugin_notification_lists.id, plugin_notification_lists.name FROM plugin_notification_lists \r\n INNER JOIN user_auth ON plugin_notification_lists.name = CONCAT(user_auth.username,'_warning') AND user_auth.id = '" . $_SESSION["sess_user_id"] . "'"; $form_array["notify_alert"]["sql"] = "SELECT plugin_notification_lists.id, plugin_notification_lists.name FROM plugin_notification_lists \r\n INNER JOIN user_auth ON plugin_notification_lists.name = CONCAT(user_auth.username,'_alert') AND user_auth.id = '" . $_SESSION["sess_user_id"] . "'"; } /* modify for multi user end */ if (read_config_option("thold_disable_legacy") != 'on') { $extra = array('notify_accounts' => array('friendly_name' => 'Notify accounts', 'method' => 'drop_multi', 'description' => 'This is a listing of accounts that will be notified when this threshold is breached.<br><br><br><br>', 'array' => $send_notification_array, 'sql' => $sql), 'notify_extra' => array('friendly_name' => 'Alert Emails', 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => 'You may specify here extra Emails to receive alerts for this data source (comma separated)', 'value' => isset($thold_item_data['notify_extra']) ? $thold_item_data['notify_extra'] : ''), 'notify_warning_extra' => array('friendly_name' => 'Warning Emails', 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => 'You may specify here extra Emails to receive warnings for this data source (comma separated)', 'value' => isset($thold_item_data['notify_warning_extra']) ? $thold_item_data['notify_warning_extra'] : '')); $form_array += $extra; } else { $extra = array('notify_accounts' => array('method' => 'hidden', 'value' => 'ignore'), 'notify_extra' => array('method' => 'hidden', 'value' => isset($thold_item_data['notify_extra']) ? $thold_item_data['notify_extra'] : ''), 'notify_warning_extra' => array('method' => 'hidden', 'value' => isset($thold_item_data['notify_warning_extra']) ? $thold_item_data['notify_warning_extra'] : '')); $form_array += $extra;
function template_edit() { global $config; /* ================= input validation ================= */ get_filter_request_var('id'); /* ==================================================== */ $id = get_request_var('id'); $thold_data = db_fetch_row('SELECT * FROM thold_template WHERE id=' . $id . ' LIMIT 1'); $temp = db_fetch_assoc('SELECT id, name FROM data_template WHERE id=' . $thold_data['data_template_id']); foreach ($temp as $d) { $data_templates[$d['id']] = $d['name']; } $temp = db_fetch_row('SELECT id, data_source_name, data_input_field_id FROM data_template_rrd WHERE id=' . $thold_data['data_source_id'] . ' LIMIT 1'); $source_id = $temp['data_input_field_id']; if ($source_id != 0) { $temp2 = db_fetch_assoc('SELECT id, name FROM data_input_fields WHERE id=' . $source_id); foreach ($temp2 as $d) { $data_fields[$d['id']] = $d['name']; } } else { $data_fields[$temp['id']] = $temp['data_source_name']; } $send_notification_array = array(); $users = db_fetch_assoc("SELECT plugin_thold_contacts.id, plugin_thold_contacts.data,\n\t\tplugin_thold_contacts.type, user_auth.full_name\n\t\tFROM plugin_thold_contacts, user_auth\n\t\tWHERE user_auth.id=plugin_thold_contacts.user_id\n\t\tAND plugin_thold_contacts.data!=''\n\t\tORDER BY user_auth.full_name ASC, plugin_thold_contacts.type ASC"); if (!empty($users)) { foreach ($users as $user) { $send_notification_array[$user['id']] = $user['full_name'] . ' - ' . ucfirst($user['type']); } } if (isset($thold_data['id'])) { $sql = 'SELECT contact_id as id FROM plugin_thold_template_contact WHERE template_id=' . $thold_data['id']; } else { $sql = 'SELECT contact_id as id FROM plugin_thold_template_contact WHERE template_id=0'; } $step = db_fetch_cell('SELECT rrd_step FROM data_template_data WHERE data_template_id = ' . $thold_data['data_template_id'], FALSE); include $config['base_path'] . '/plugins/thold/includes/arrays.php'; $rra_steps = db_fetch_assoc("SELECT dspr.steps\n\t\tFROM data_template_data AS dtd\n\t\tINNER JOIN data_source_profiles AS dsp\n\t ON dsp.id=dtd.data_source_profile_id\n\t\tINNER JOIN data_source_profiles_rra AS dspr\n\t\tON dsp.id=dspr.data_source_profile_id\n\t WHERE dspr.steps>1\n\t\tAND dtd.data_template_id=" . $thold_data['data_template_id'] . "\n\t AND dtd.local_data_template_data_id=0\n\t\tORDER BY steps"); $reference_types = array(); foreach ($rra_steps as $rra_step) { $seconds = $step * $rra_step['steps']; $reference_types[$seconds] = $timearray[$rra_step['steps']] . " Average"; } $data_fields2 = array(); $temp = db_fetch_assoc('SELECT id, local_data_template_rrd_id, data_source_name, data_input_field_id FROM data_template_rrd WHERE local_data_template_rrd_id=0 AND data_template_id=' . $thold_data['data_template_id']); foreach ($temp as $d) { if ($d['data_input_field_id'] != 0) { $temp2 = db_fetch_assoc('SELECT id, name, data_name FROM data_input_fields WHERE id=' . $d['data_input_field_id'] . ' ORDER BY data_name'); $data_fields2[$d['data_source_name']] = $temp2[0]['data_name'] . ' (' . $temp2[0]['name'] . ')'; } else { $temp2[0]['name'] = $d['data_source_name']; $data_fields2[$d['data_source_name']] = $temp2[0]['name']; } } $replacements = db_fetch_assoc("SELECT DISTINCT field_name\n\t\tFROM data_local AS dl\n\t\tINNER JOIN (SELECT DISTINCT field_name, snmp_query_id FROM host_snmp_cache) AS hsc\n\t\tON dl.snmp_query_id=hsc.snmp_query_id\n\t\tWHERE dl.data_template_id=" . $thold_data['data_template_id']); $nr = array(); if (sizeof($replacements)) { foreach ($replacements as $r) { $nr[] = "<span style='color:blue;'>|query_" . $r['field_name'] . "|</span>"; } } $vhf = explode("|", trim(VALID_HOST_FIELDS, "()")); if (sizeof($vhf)) { foreach ($vhf as $r) { $nr[] = "<span style='color:blue;'>|" . $r . "|</span>"; } } $replacements = "<br>Replacement Fields: " . implode(", ", $nr); $dss = db_fetch_assoc("SELECT data_source_name FROM data_template_rrd WHERE data_template_id=" . $thold_data['data_template_id'] . " AND local_data_id=0"); if (sizeof($dss)) { foreach ($dss as $ds) { $dsname[] = "<span style='color:blue;'>|ds:" . $ds["data_source_name"] . "|</span>"; } } $datasources = "<br>Data Sources: " . implode(", ", $dsname); $form_array = array('general_header' => array('friendly_name' => __('General Settings'), 'method' => 'spacer'), 'name' => array('friendly_name' => __('Template Name'), 'method' => 'textbox', 'max_length' => 100, 'size' => '60', 'default' => $thold_data['data_template_name'] . ' [' . $thold_data['data_source_name'] . ']', 'description' => __('Provide the Threshold Template a meaningful name. Device Substritution and Data Query Substitution variables can be used as well as |graph_title| for the Graph Title'), 'value' => isset($thold_data['name']) ? $thold_data['name'] : ''), 'data_template_name' => array('friendly_name' => __('Data Template'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Data Template that you are using. (This can not be changed)'), 'value' => $thold_data['data_template_id'], 'array' => $data_templates), 'data_field_name' => array('friendly_name' => __('Data Field'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Data Field that you are using. (This can not be changed)'), 'value' => $thold_data['id'], 'array' => $data_fields), 'thold_enabled' => array('friendly_name' => __('Enabled'), 'method' => 'checkbox', 'default' => 'on', 'description' => __('Whether or not this Threshold will be checked and alerted upon.'), 'value' => isset($thold_data['thold_enabled']) ? $thold_data['thold_enabled'] : ''), 'exempt' => array('friendly_name' => __('Weekend Exemption'), 'description' => __('If this is checked, this Threshold will not alert on weekends.'), 'method' => 'checkbox', 'default' => '', 'value' => isset($thold_data['exempt']) ? $thold_data['exempt'] : ''), 'restored_alert' => array('friendly_name' => __('Disable Restoration Email'), 'description' => __('If this is checked, Thold will not send an alert when the Threshold has returned to normal status.'), 'method' => 'checkbox', 'default' => '', 'value' => isset($thold_data['restored_alert']) ? $thold_data['restored_alert'] : ''), 'thold_type' => array('friendly_name' => __('Threshold Type'), 'method' => 'drop_array', 'on_change' => 'changeTholdType()', 'array' => $thold_types, 'default' => read_config_option('thold_type'), 'description' => __('The type of Threshold that will be monitored.'), 'value' => isset($thold_data['thold_type']) ? $thold_data['thold_type'] : ''), 'repeat_alert' => array('friendly_name' => __('Re-Alert Cycle'), 'method' => 'drop_array', 'array' => $repeatarray, 'default' => read_config_option('alert_repeat'), 'description' => __('Repeat alert after this amount of time has pasted since the last alert.'), 'value' => isset($thold_data['repeat_alert']) ? $thold_data['repeat_alert'] : ''), 'thold_warning_header' => array('friendly_name' => __('Warning - High / Low Settings'), 'method' => 'spacer'), 'thold_warning_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, alert will be triggered'), 'value' => isset($thold_data['thold_warning_hi']) ? $thold_data['thold_warning_hi'] : ''), 'thold_warning_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, alert will be triggered'), 'value' => isset($thold_data['thold_warning_low']) ? $thold_data['thold_warning_low'] : ''), 'thold_warning_fail_trigger' => array('friendly_name' => __('Min Trigger Duration'), 'method' => 'drop_array', 'array' => $alertarray, 'description' => __('The amount of time the data source must be in a breach condition for an alert to be raised.'), 'value' => isset($thold_data['thold_warning_fail_trigger']) ? $thold_data['thold_warning_fail_trigger'] : read_config_option('alert_trigger')), 'thold_header' => array('friendly_name' => __('Alert - High / Low Settings'), 'method' => 'spacer'), 'thold_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, alert will be triggered'), 'value' => isset($thold_data['thold_hi']) ? $thold_data['thold_hi'] : ''), 'thold_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, alert will be triggered'), 'value' => isset($thold_data['thold_low']) ? $thold_data['thold_low'] : ''), 'thold_fail_trigger' => array('friendly_name' => __('Min Trigger Duration'), 'method' => 'drop_array', 'array' => $alertarray, 'description' => __('The amount of time the data source must be in a breach condition for an alert to be raised.'), 'value' => isset($thold_data['thold_fail_trigger']) ? $thold_data['thold_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_header' => array('friendly_name' => __('Warning - Time Based Settings'), 'method' => 'spacer'), 'time_warning_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, warning will be triggered'), 'value' => isset($thold_data['time_warning_hi']) ? $thold_data['time_warning_hi'] : ''), 'time_warning_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, warning will be triggered'), 'value' => isset($thold_data['time_warning_low']) ? $thold_data['time_warning_low'] : ''), 'time_warning_fail_trigger' => array('friendly_name' => __('Trigger Count'), 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'default' => read_config_option('thold_warning_time_fail_trigger'), 'description' => __('The number of times the data source must be in breach condition prior to issuing a warning.'), 'value' => isset($thold_data['time_warning_fail_trigger']) ? $thold_data['time_warning_fail_trigger'] : read_config_option('alert_trigger')), 'time_warning_fail_length' => array('friendly_name' => __('Time Period Length'), 'method' => 'drop_array', 'array' => $timearray, 'description' => __('The amount of time in the past to check for Threshold breaches.'), 'value' => isset($thold_data['time_warning_fail_length']) ? $thold_data['time_warning_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1)), 'time_header' => array('friendly_name' => __('Alert - Time Based Settings'), 'method' => 'spacer'), 'time_hi' => array('friendly_name' => __('High Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes above this number, alert will be triggered'), 'value' => isset($thold_data['time_hi']) ? $thold_data['time_hi'] : ''), 'time_low' => array('friendly_name' => __('Low Threshold'), 'method' => 'textbox', 'max_length' => 100, 'size' => 10, 'description' => __('If set and data source value goes below this number, alert will be triggered'), 'value' => isset($thold_data['time_low']) ? $thold_data['time_low'] : ''), 'time_fail_trigger' => array('friendly_name' => __('Trigger Count'), 'method' => 'textbox', 'max_length' => 5, 'size' => 10, 'description' => __('The number of times the data source must be in breach condition prior to issuing an alert.'), 'value' => isset($thold_data['time_fail_trigger']) ? $thold_data['time_fail_trigger'] : read_config_option('thold_time_fail_trigger')), 'time_fail_length' => array('friendly_name' => __('Time Period Length'), 'method' => 'drop_array', 'array' => $timearray, 'description' => __('The amount of time in the past to check for Threshold breaches.'), 'value' => isset($thold_data['time_fail_length']) ? $thold_data['time_fail_length'] : (read_config_option('thold_time_fail_length') > 0 ? read_config_option('thold_time_fail_length') : 2)), 'baseline_header' => array('friendly_name' => __('Baseline Monitoring'), 'method' => 'spacer'), 'bl_ref_time_range' => array('friendly_name' => __('Time reference in the past'), 'method' => 'drop_array', 'array' => $reference_types, 'description' => __('Specifies the point in the past (based on rrd resolution) that will be used as a reference'), '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'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Specifies allowed deviation in percentage for the upper bound Threshold. If not set, upper bound Threshold will not be checked at all.'), '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'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Specifies allowed deviation in percentage for the lower bound Threshold. If not set, lower bound Threshold will not be checked at all.'), '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'), 'method' => 'textbox', 'max_length' => 3, 'size' => 10, 'description' => __('Number of consecutive times the data source must be in a breached condition for an alert to be raised.<br>Leave empty to use default value (Default: %s cycles', read_config_option('alert_bl_trigger')), 'value' => isset($thold_data['bl_fail_trigger']) ? $thold_data['bl_fail_trigger'] : read_config_option('alert_bl_trigger')), 'data_manipulation' => array('friendly_name' => __('Data Manipulation'), 'method' => 'spacer'), 'data_type' => array('friendly_name' => __('Data Type'), 'method' => 'drop_array', 'on_change' => 'changeDataType()', 'array' => $data_types, 'description' => __('Special formatting for the given data.'), 'value' => isset($thold_data['data_type']) ? $thold_data['data_type'] : read_config_option('data_type')), 'cdef' => array('friendly_name' => __('Threshold CDEF'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Apply this CDEF before returning the data.'), 'value' => isset($thold_data['cdef']) ? $thold_data['cdef'] : 0, 'array' => thold_cdef_select_usable_names()), 'percent_ds' => array('friendly_name' => __('Percent Datasource'), 'method' => 'drop_array', 'default' => 'NULL', 'description' => __('Second Datasource Item to use as total value to calculate percentage from.'), 'value' => isset($thold_data['percent_ds']) ? $thold_data['percent_ds'] : 0, 'array' => $data_fields2), 'expression' => array('friendly_name' => __('RPN Expression'), 'method' => 'textbox', 'default' => '', 'description' => __('An RPN Expression is an RRDtool Compatible RPN Expression. Syntax includes all functions below in addition to both Device and Data Query replacement expressions such as <span style="color:blue;">|query_ifSpeed|</span>. To use a Data Source in the RPN Expression, you must use the syntax: <span style="color:blue;">|ds:dsname|</span>. For example, <span style="color:blue;">|ds:traffic_in|</span> will get the current value of the traffic_in Data Source for the RRDfile(s) associated with the Graph. Any Data Source for a Graph can be included.<br>Math Operators: <span style="color:blue;">+, -, /, *, %, ^</span><br>Functions: <span style="color:blue;">SIN, COS, TAN, ATAN, SQRT, FLOOR, CEIL, DEG2RAD, RAD2DEG, ABS, EXP, LOG, ATAN, ADNAN</span><br>Flow Operators: <span style="color:blue;">UN, ISINF, IF, LT, LE, GT, GE, EQ, NE</span><br>Comparison Functions: <span style="color:blue;">MAX, MIN, INF, NEGINF, NAN, UNKN, COUNT, PREV</span>%s %s', $replacements, $datasources), 'value' => isset($thold_data['expression']) ? $thold_data['expression'] : '', 'max_length' => '255', 'size' => '80'), 'other_header' => array('friendly_name' => __('Other Settings'), 'method' => 'spacer'), 'notify_warning' => array('friendly_name' => __('Warning Notification List'), 'method' => 'drop_sql', 'description' => __('You may specify choose a Notification List to receive Warnings for this Data Source'), 'value' => isset($thold_data['notify_warning']) ? $thold_data['notify_warning'] : '', 'none_value' => __('None'), 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name'), 'notify_alert' => array('friendly_name' => __('Alert Notification List'), 'method' => 'drop_sql', 'description' => __('You may specify choose a Notification List to receive Alerts for this Data Source'), 'value' => isset($thold_data['notify_alert']) ? $thold_data['notify_alert'] : '', 'none_value' => __('None'), 'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name')); if (read_config_option('thold_alert_snmp') == 'on') { $extra = array('snmp_event_category' => array('friendly_name' => __('SNMP Notification - Event Category'), 'method' => 'textbox', 'description' => __('To allow a NMS to categorize different SNMP notifications more easily please fill in the category SNMP notifications for this template should make use of. E.g.: "disk_usage", "link_utilization", "ping_test", "nokia_firewall_cpu_utilization" ...'), 'value' => isset($thold_data['snmp_event_category']) ? $thold_data['snmp_event_category'] : '', 'default' => '', 'max_length' => '255'), 'snmp_event_severity' => array('friendly_name' => __('SNMP Notification - Alert Event Severity'), 'method' => 'drop_array', 'default' => '3', 'description' => __('Severity to be used for alerts. (Low impact -> Critical impact)'), 'value' => isset($thold_data['snmp_event_severity']) ? $thold_data['snmp_event_severity'] : 3, 'array' => array(1 => __('Low'), 2 => __('Medium'), 3 => __('High'), 4 => __('Critical')))); $form_array += $extra; if (read_config_option('thold_alert_snmp_warning') != 'on') { $extra = array('snmp_event_warning_severity' => array('friendly_name' => __('SNMP Notification - Warning Event Severity'), 'method' => 'drop_array', 'default' => '2', 'description' => __('Severity to be used for warnings. (Low impact -> Critical impact).<br>Note: The severity of warnings has to be equal or lower than the severity being defined for alerts.'), 'value' => isset($thold_data['snmp_event_warning_severity']) ? $thold_data['snmp_event_warning_severity'] : 2, 'array' => array(1 => __('Low'), 2 => __('Medium'), 3 => __('High'), 4 => __('Critical')))); } $form_array += $extra; } if (read_config_option('thold_disable_legacy') != 'on') { $extra = array('notify_accounts' => array('friendly_name' => __('Notify accounts'), 'method' => 'drop_multi', 'description' => __('This is a listing of accounts that will be notified when this Threshold is breached.<br><br><br><br>'), 'array' => $send_notification_array, 'sql' => $sql), 'notify_extra' => array('friendly_name' => __('Alert Emails'), 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => __('You may specify here extra Emails to receive alerts for this data source (comma separated)'), 'value' => isset($thold_data['notify_extra']) ? $thold_data['notify_extra'] : ''), 'notify_warning_extra' => array('friendly_name' => __('Warning Emails'), 'method' => 'textarea', 'textarea_rows' => 3, 'textarea_cols' => 50, 'description' => __('You may specify here extra Emails to receive warnings for this data source (comma separated)'), 'value' => isset($thold_data['notify_warning_extra']) ? $thold_data['notify_warning_extra'] : '')); $form_array += $extra; } else { $extra = array('notify_accounts' => array('method' => 'hidden', 'value' => 'ignore'), 'notify_extra' => array('method' => 'hidden', 'value' => isset($thold_data['notify_extra']) ? $thold_data['notify_extra'] : ''), 'notify_warning_extra' => array('method' => 'hidden', 'value' => isset($thold_data['notify_warning_extra']) ? $thold_data['notify_warning_extra'] : '')); $form_array += $extra; } form_start('thold_templates.php', 'thold'); html_start_box('', '100%', '', '3', 'center', ''); draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array)); form_hidden_box('save', 'edit', ''); form_hidden_box('id', $id, ''); html_end_box(); form_save_button('thold_templates.php?id=' . $id); ?> <script type='text/javascript'> function changeTholdType() { switch($('#thold_type').val()) { case '0': // Hi/Low thold_toggle_hilow(''); thold_toggle_baseline('none'); thold_toggle_time('none'); break; case '1': // Baseline thold_toggle_hilow('none'); thold_toggle_baseline(''); thold_toggle_time('none'); break; case '2': // Time Based thold_toggle_hilow('none'); thold_toggle_baseline('none'); thold_toggle_time(''); break; } } function changeDataType() { switch($('#data_type').val()) { case '0': $('#row_cdef, #row_percent_ds, #row_expression').hide(); break; case '1': $('#row_cdef').show(); $('#row_percent_ds, #row_expression').hide(); break; case '2': $('#row_cdef').hide(); $('#row_percent_ds, #row_expression').show(); break; case '3': $('#row_cdef').hide(); $('#row_percent_ds').hide(); $('#row_expression').show(); break; } } function thold_toggle_hilow(status) { if (status == '') { $('#row_thold_header, #row_thold_hi, #row_thold_low, #row_thold_fail_trigger').show(); $('#row_thold_warning_header, #row_thold_warning_hi').show(); $('#row_thold_warning_low, #row_thold_warning_fail_trigger').show(); }else{ $('#row_thold_header, #row_thold_hi, #row_thold_low, #row_thold_fail_trigger').hide(); $('#row_thold_warning_header, #row_thold_warning_hi').hide(); $('#row_thold_warning_low, #row_thold_warning_fail_trigger').hide(); } } function thold_toggle_baseline(status) { if (status == '') { $('#row_baseline_header, #row_bl_ref_time_range').show(); $('#row_bl_pct_up, #row_bl_pct_down, #row_bl_fail_trigger').show(); }else{ $('#row_baseline_header, #row_bl_ref_time_range').hide(); $('#row_bl_pct_up, #row_bl_pct_down, #row_bl_fail_trigger').hide(); } } function thold_toggle_time(status) { if (status == '') { $('#row_time_header, #row_time_hi, #row_time_low').show(); $('#row_time_fail_trigger, #row_time_fail_length, #row_time_warning_header').show(); $('#row_time_warning_hi, #row_time_warning_low').show(); $('#row_time_warning_fail_trigger, #row_time_warning_fail_length').show(); }else{ $('#row_time_header, #row_time_hi, #row_time_low').hide(); $('#row_time_fail_trigger, #row_time_fail_length, #row_time_warning_header').hide(); $('#row_time_warning_hi, #row_time_warning_low').hide(); $('#row_time_warning_fail_trigger, #row_time_warning_fail_length').hide(); } } changeTholdType(); changeDataType(); if ($('#notify_accounts option').length == 0) { $('#row_notify_accounts').hide(); } if ($('#notify_warning option').length == 0) { $('#row_notify_warning').hide(); } if ($('#notify_alert option').length == 0) { $('#row_notify_alert').hide(); } $('#notify_accounts').multiselect({ minWidth: '400', noneSelectedText: 'Select Users(s)', selectedText: function(numChecked, numTotal, checkedItems) { myReturn = numChecked + ' Users Selected'; $.each(checkedItems, function(index, value) { if (value.value == '0') { myReturn='All Users Selected'; return false; } }); return myReturn; }, checkAllText: 'All', uncheckAllText: 'None', uncheckall: function() { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).prop('checked', true); }); }, open: function() { size = $('#notify_accounts option').length * 20 + 20; if (size > 140) { size = 140; } $('ul.ui-multiselect-checkboxes').css('height', size + 'px'); }, click: function(event, ui) { checked=$(this).multiselect('widget').find('input:checked').length; if (ui.value == '0') { if (ui.checked == true) { $('#host').multiselect('uncheckAll'); $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).prop('checked', true); }); } }else if (checked == 0) { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).click(); }); }else if ($(this).multiselect('widget').find('input:checked:first').val() == '0') { if (checked > 0) { $(this).multiselect('widget').find(':checkbox:first').each(function() { $(this).click(); $(this).prop('disable', true); }); } } } }).multiselectfilter( { label: 'Search', width: '150' }); </script> <?php }