Exemplo n.º 1
0
    $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 => '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 => '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', 5 => '5 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');
$data_fields = array();
$reference_types = get_reference_types($rra, $step, $timearray);
if (isset($thold_item_data['data_template_id'])) {
    $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_item_data['rra_id']);
} else {
    $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=' . $rra);
}
foreach ($temp as $d) {
    if ($d['data_input_field_id'] != 0) {
        $temp2 = db_fetch_assoc('SELECT name FROM data_input_fields WHERE id=' . $d['data_input_field_id']);
    } else {
        $temp2[0]['name'] = $d['data_source_name'];
    }
Exemplo n.º 2
0
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">+, -, /, *, &#37;, ^</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 
}
Exemplo n.º 3
0
function thold_config_settings()
{
    global $tabs, $settings, $item_rows, $config;
    if (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) != 'settings.php') {
        return;
    }
    include './plugins/thold/includes/arrays.php';
    include_once './plugins/thold/thold_functions.php';
    if ($config['cacti_server_os'] == 'unix') {
        $syslog_facil_array = array(LOG_AUTH => 'Auth', LOG_AUTHPRIV => 'Auth Private', LOG_CRON => 'Cron', LOG_DAEMON => 'Daemon', LOG_KERN => 'Kernel', LOG_LOCAL0 => 'Local 0', LOG_LOCAL1 => 'Local 1', LOG_LOCAL2 => 'Local 2', LOG_LOCAL3 => 'Local 3', LOG_LOCAL4 => 'Local 4', LOG_LOCAL5 => 'Local 5', LOG_LOCAL6 => 'Local 6', LOG_LOCAL7 => 'Local 7', LOG_LPR => 'LPR', LOG_MAIL => 'Mail', LOG_NEWS => 'News', LOG_SYSLOG => 'Syslog', LOG_USER => 'User', LOG_UUCP => 'UUCP');
        $default_facility = LOG_DAEMON;
    } else {
        $syslog_facil_array = array(LOG_USER => 'User');
        $default_facility = LOG_USER;
    }
    $tabs['alerts'] = __('Thresholds');
    $settings['alerts'] = array('general_header' => array('friendly_name' => __('General'), 'method' => 'spacer'), 'thold_disable_all' => array('friendly_name' => __('Disable All Thresholds'), 'description' => __('Checking this box will disable Alerting on all Thresholds.  This can be used when it is necessary to perform maintenance on your network.'), 'method' => 'checkbox', 'default' => ''), 'thold_autocreate' => array('friendly_name' => __('Auto Create Thresholds'), 'description' => __('If selected, when running either automation, or when creating/saving a Device, all thresholds associated with the Device Template will be created.'), 'method' => 'checkbox', 'default' => ''), 'thold_disable_legacy' => array('friendly_name' => __('Disable Legacy Notifications'), 'description' => __('Checking this box will disable Legacy Alerting on all Thresholds.  Legacy Alerting is defined as any Specific Email Alerts not associated with a Notification List.'), 'method' => 'checkbox', 'default' => ''), 'thold_filter_default' => array('friendly_name' => __('Default Status'), 'description' => __('Default Threshold Tab filter status.'), 'method' => 'drop_array', 'array' => array('-1' => __('Any'), '0' => __('Disabled'), '2' => __('Enabled'), '1' => __('Breached'), '3' => __('Triggered')), 'default' => 20), 'logging_header' => array('friendly_name' => __('Logging'), 'method' => 'spacer'), 'thold_log_cacti' => array('friendly_name' => __('Log Threshold Breaches'), 'description' => __('Enable logging of all Threshold failures to the Cacti Log.'), 'method' => 'checkbox', 'default' => ''), 'thold_show_datasource' => array('friendly_name' => __('Show Data Source in Log'), 'description' => __('Show the Data Source name in the Log if not present.'), 'method' => 'checkbox', 'default' => ''), 'thold_log_changes' => array('friendly_name' => __('Log Threshold Changes'), 'description' => __('Enable logging of all Threshold changes to the Cacti Log.'), 'method' => 'checkbox', 'default' => ''), 'thold_log_debug' => array('friendly_name' => __('Debug Log'), 'description' => __('Enable logging of debug messages with Thold'), 'method' => 'checkbox', 'default' => ''), 'thold_log_storage' => array('friendly_name' => __('Alert Log Retention'), 'description' => __('Keep Threshold Logs for this number of days.'), 'method' => 'drop_array', 'default' => '31', 'array' => $thold_log_retention), 'daemon_header' => array('friendly_name' => __('Threshold Daemon'), 'method' => 'spacer'), 'thold_daemon_enable' => array('friendly_name' => __('Enable Threshold Daemon'), 'description' => __('Checking this box will enable the use of a dedicated Threshold daemon. This can be used to increase system performace and/or to distribute threshold monitoring to a separate server.'), 'method' => 'checkbox', 'default' => ''), 'thold_max_concurrent_processes' => array('friendly_name' => __('Maximum Concurrent Thold Processes'), 'description' => __('The maximum number of concurrent processes to be handled by the Thold Daemon.'), 'method' => 'textbox', 'size' => 2, 'max_length' => 2, 'default' => read_config_option('concurrent_processes')), 'thold_alerting_header' => array('friendly_name' => __('Alert Presets'), 'method' => 'spacer'), 'alert_exempt' => array('friendly_name' => __('Weekend exemptions'), 'description' => __('If this is checked, thold will not run on weekends.'), 'method' => 'checkbox'), 'alert_trigger' => array('friendly_name' => __('Default Trigger Count'), 'description' => __('Default number of consecutive times the Data Source must be in breach of the Threshold for an Alert to be raised.'), 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 1), 'alert_repeat' => array('friendly_name' => __('Re-Alerting'), 'description' => __('Repeat Alert after specified number of poller cycles.'), 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 12), 'thold_baseline_header' => array('friendly_name' => __('Baseline Presets'), 'method' => 'spacer'), 'alert_bl_timerange_def' => array('friendly_name' => __('Baseline Time Range Default'), 'description' => __('This is the default value used in creating thresholds or templates.'), 'method' => 'drop_array', 'array' => get_reference_types(), 'size' => 12, 'max_length' => 12, 'default' => 86400), 'alert_bl_trigger' => array('friendly_name' => __('Baseline Trigger Count'), 'description' => __('Default number of consecutive times the Data Source must be in breach of the calculated Baseline Threshold for an Alert to be raised.'), 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 2), 'alert_bl_percent_def' => array('friendly_name' => __('Baseline Deviation Percentage'), 'description' => __('This is the default value used in creating thresholds or templates.'), 'method' => 'textbox', 'size' => 3, 'max_length' => 3, 'default' => 20), 'syslog_header' => array('friendly_name' => __('Syslog Settings'), 'method' => 'spacer'), 'alert_syslog' => array('friendly_name' => __('Syslog Support'), 'description' => __('These messages will be sent to your local syslog. If you would like these sent to a remote box, you must setup your local syslog to do so.'), 'method' => 'checkbox'), 'thold_syslog_level' => array('friendly_name' => __('Syslog Level'), 'description' => __('This is the priority level that your syslog messages will be sent as.'), 'method' => 'drop_array', 'default' => LOG_WARNING, 'array' => array(LOG_EMERG => __('Emergency'), LOG_ALERT => __('Alert'), LOG_CRIT => __('Critical'), LOG_ERR => __('Error'), LOG_WARNING => __('Warning'), LOG_NOTICE => __('Notice'), LOG_INFO => __('Info'), LOG_DEBUG => __('Debug'))), 'thold_syslog_facility' => array('friendly_name' => __('Syslog Facility'), 'description' => __('This is the facility level that your syslog messages will be sent as.'), 'method' => 'drop_array', 'default' => $default_facility, 'array' => $syslog_facil_array), 'thold_alerting_header3' => array('friendly_name' => __('SNMP Notification Presets'), 'method' => 'spacer'), 'thold_alert_snmp' => array('friendly_name' => __('SNMP Notifications'), 'description' => __('Threshold status messages (informs/traps) will be sent to SNMP notification receivers. This includes Alerts, Warnings and Restoration traps per default. Note: This feature requires the Cacti SNMPAgent plugin.'), 'method' => 'checkbox', 'default' => '0'), 'thold_alert_snmp_warning' => array('friendly_name' => __('Disable Warning Notifications'), 'description' => __('If this is checked, Thold will not send a notification when a warning threshold has been breached.'), 'method' => 'checkbox'), 'thold_alert_snmp_normal' => array('friendly_name' => __('Disable Restoration Notifications'), 'description' => __('If this is checked, Thold will not send a notfication when the threshold has returned to normal status.'), 'method' => 'checkbox'), 'thold_snmp_event_description' => array('friendly_name' => __('SNMP Event Description'), 'description' => __('You can customize the event description being sent out to the SNMP notification receivers by using additional varbinds. Following variable bindings will be supported:<br>&#060;THRESHOLDNAME&#062; &#060;HOSTNAME&#062; &#060;HOSTIP&#062; &#060;TEMPLATE_ID&#062; &#060;TEMPLATE_NAME&#062; &#060;THR_TYPE&#062; &#060;DS_NAME&#062; &#060;HI&#062; &#060;LOW&#062; &#060;EVENT_CATEGORY&#062; &#060;FAIL_COUNT&#062; &#060;FAIL_DURATION&#062;'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => ''), 'thold_email_header' => array('friendly_name' => __('Emailing Options'), 'method' => 'spacer'), 'thold_email_prio' => array('friendly_name' => __('Send Emails with Urgent Priority'), 'description' => __('Allows you to set e-mails with urgent priority'), 'method' => 'checkbox', 'default' => ''), 'alert_deadnotify' => array('friendly_name' => __('Dead Device Notifications'), 'description' => __('Enable Dead/Recovering host notification'), 'method' => 'checkbox', 'default' => 'on'), 'alert_email' => array('friendly_name' => __('Dead Device Notifications Email'), 'description' => __('This is the Email Address that the Dead Device Notifications will be sent to if the Global Notification List is selected.'), 'method' => 'textbox', 'size' => 80, 'max_length' => 255), 'thold_down_subject' => array('friendly_name' => __('Down Device Subject'), 'description' => __('This is the Email subject that will be used for Down Device Messages.'), 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => __('Device Error: <DESCRIPTION> (<HOSTNAME>) is DOWN')), 'thold_down_text' => array('friendly_name' => __('Down Device Message'), 'description' => __('This is the message that will be displayed as the message body of all UP / Down Device Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '7', 'textarea_cols' => '80', 'default' => __('System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked DOWN : <LAST_FAIL><br>Device Previously UP for: <DOWNTIME><br>NOTE: <NOTES>')), 'thold_up_subject' => array('friendly_name' => __('Recovering Device Subject'), 'description' => __('This is the Email subject that will be used for Recovering Device Messages.'), 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => __('Device Notice: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state')), 'thold_up_text' => array('friendly_name' => __('Recovering Device Message'), 'description' => __('This is the message that will be displayed as the message body of all UP / Down Device Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '7', 'textarea_cols' => '80', 'default' => __('<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked UP: <LAST_FAIL><br>Device Previously DOWN for: <DOWNTIME><br><br>Snmp Info:<br>Name - <SNMP_HOSTNAME><br>Location - <SNMP_LOCATION><br>Uptime - <UPTIMETEXT> (<UPTIME> ms)<br>System - <SNMP_SYSTEM><br><br>NOTE: <NOTES>')), 'thold_from_email' => array('friendly_name' => __('From Email Address'), 'description' => __('This is the Email address that the threshold will appear from.'), 'method' => 'textbox', 'default' => read_config_option('settings_from_email'), 'max_length' => 255), 'thold_from_name' => array('friendly_name' => __('From Name'), 'description' => __('This is the actual name that the threshold will appear from.'), 'method' => 'textbox', 'default' => read_config_option('settings_from_name'), 'max_length' => 255), 'thold_alert_text' => array('friendly_name' => __('Threshold Alert Message'), 'description' => __('This is the message that will be displayed at the top of all Threshold Alerts (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => __('An Alert has been issued that requires your attention. <br><br><strong>Device</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>')), 'thold_warning_text' => array('friendly_name' => __('Threshold Warning Message'), 'description' => __('This is the message that will be displayed at the top of all threshold warnings (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => __('A warning has been issued that requires your attention. <br><br><strong>Device</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>')), 'thold_send_text_only' => array('friendly_name' => __('Send Alerts as Text'), 'description' => __('If checked, this will cause all Alerts to be sent as plain text Emails with no graph.  The default is HTML Emails with the graph embedded in the Email.'), 'method' => 'checkbox', 'default' => ''));
}
Exemplo n.º 4
0
function thold_config_settings()
{
    global $tabs, $settings, $item_rows, $config;
    if (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) != 'settings.php') {
        return;
    }
    include_once "./plugins/thold/thold_functions.php";
    define_syslog_variables();
    if ($config["cacti_server_os"] == "unix") {
        $syslog_facil_array = array(LOG_AUTH => 'Auth', LOG_AUTHPRIV => 'Auth Private', LOG_CRON => 'Cron', LOG_DAEMON => 'Daemon', LOG_KERN => 'Kernel', LOG_LOCAL0 => 'Local 0', LOG_LOCAL1 => 'Local 1', LOG_LOCAL2 => 'Local 2', LOG_LOCAL3 => 'Local 3', LOG_LOCAL4 => 'Local 4', LOG_LOCAL5 => 'Local 5', LOG_LOCAL6 => 'Local 6', LOG_LOCAL7 => 'Local 7', LOG_LPR => 'LPR', LOG_MAIL => 'Mail', LOG_NEWS => 'News', LOG_SYSLOG => 'Syslog', LOG_USER => 'User', LOG_UUCP => 'UUCP');
        $default_facility = LOG_DAEMON;
    } else {
        $syslog_facil_array = array(LOG_USER => 'User');
        $default_facility = LOG_USER;
    }
    $tabs['alerts'] = 'Thresholds';
    $settings['alerts'] = array('general_header' => array('friendly_name' => 'General', 'method' => 'spacer'), 'thold_disable_all' => array('friendly_name' => 'Disable All Thresholds', 'description' => 'Checking this box will disable Alerting on all Thresholds.  This can be used when it is necessary to perform maintenance on your network.', 'method' => 'checkbox', 'default' => 'off'), 'thold_disable_legacy' => array('friendly_name' => 'Disable Legacy Notifications', 'description' => 'Checking this box will disable Legacy Alerting on all Thresholds.  Legacy Alerting is defined as any Specific Email Alerts not associated with a Notification List.', 'method' => 'checkbox', 'default' => ''), 'thold_filter_default' => array('friendly_name' => 'Default Status', 'description' => 'Default Threshold Filter Status', 'method' => 'drop_array', 'array' => array("-1" => "Any", "0" => "Disabled", "2" => "Enabled", "1" => "Breached", "3" => "Triggered"), 'default' => 20), 'alert_base_url' => array('friendly_name' => 'Base URL', 'description' => 'Cacti base URL', 'method' => 'textbox', 'default' => isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) == 'settings.php' ? 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' : '', 'max_length' => 255), 'alert_num_rows' => array('friendly_name' => 'Thresholds Per Page', 'description' => 'Number of thresholds to display per page', 'method' => 'drop_array', 'array' => $item_rows, 'default' => 20), 'thold_log_cacti' => array('friendly_name' => 'Log Threshold Breaches', 'description' => 'Enable logging of all Threshold failures to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_changes' => array('friendly_name' => 'Log Threshold Changes', 'description' => 'Enable logging of all Threshold changes to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_debug' => array('friendly_name' => 'Debug Log', 'description' => 'Enable logging of debug messages with Thold', 'method' => 'checkbox', 'default' => 'off'), 'thold_alerting_header' => array('friendly_name' => 'Default Alerting Options', 'method' => 'spacer'), 'alert_exempt' => array('friendly_name' => 'Weekend exemptions', 'description' => 'If this is checked, thold will not run on weekends.', 'method' => 'checkbox'), 'alert_trigger' => array('friendly_name' => 'Default Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 1), 'alert_repeat' => array('friendly_name' => 'Re-Alerting', 'description' => 'Repeat Alert after specified number of poller cycles.', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 12), 'alert_syslog' => array('friendly_name' => 'Syslog Support', 'description' => 'These messages will be sent to your local syslog. If you would like these sent to a remote box, you must setup your local syslog to do so', 'method' => 'checkbox'), 'thold_syslog_level' => array('friendly_name' => 'Syslog Level', 'description' => 'This is the priority level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => LOG_WARNING, 'array' => array(LOG_EMERG => 'Emergency', LOG_ALERT => 'Alert', LOG_CRIT => 'Critical', LOG_ERR => 'Error', LOG_WARNING => 'Warning', LOG_NOTICE => 'Notice', LOG_INFO => 'Info', LOG_DEBUG => 'Debug')), 'thold_syslog_facility' => array('friendly_name' => 'Syslog Facility', 'description' => 'This is the facility level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => $default_facility, 'array' => $syslog_facil_array), 'thold_email_header' => array('friendly_name' => 'Emailing Options', 'method' => 'spacer'), 'thold_email_prio' => array('friendly_name' => 'Send Emails with Urgent Priority', 'description' => 'Allows you to set e-mails with urgent priority', 'method' => 'checkbox', 'default' => 'off'), 'alert_deadnotify' => array('friendly_name' => 'Dead Hosts Notifications', 'description' => 'Enable Dead/Recovering host notification', 'method' => 'checkbox', 'default' => 'on'), 'alert_email' => array('friendly_name' => 'Dead Host Notifications Email', 'description' => 'This is the Email Address that the Dead Host Notifications will be sent to if the Global Notification List is selected.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255), 'thold_down_subject' => array('friendly_name' => 'Down Host Subject', 'description' => 'This is the Email subject that will be used for Down Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN'), 'thold_down_text' => array('friendly_name' => 'Down Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked DOWN : <LAST_FAIL><br>Host Previously UP for: <DOWNTIME><br>NOTE: <NOTES>'), 'thold_up_subject' => array('friendly_name' => 'Recovering Host Subject', 'description' => 'This is the Email subject that will be used for Recovering Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Notice: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state'), 'thold_up_text' => array('friendly_name' => 'Recovering Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060HOSTNAME&#062  &#060DESCRIPTION&#062 &#060UPTIME&#062  &#060UPTIMETEXT&#062  &#060DOWNTIME&#062 &#060MESSAGE&#062 &#060SUBJECT&#062 &#060DOWN/UP&#062 &#060SNMP_HOSTNAME&#062 &#060SNMP_LOCATION&#062 &#060SNMP_CONTACT&#062 &#060SNMP_SYSTEM&#062 &#060LAST_FAIL&#062 &#060AVAILABILITY&#062 &#060TOT_POLL&#062 &#060FAIL_POLL&#062 &#060CUR_TIME&#062 &#060AVG_TIME&#062 &#060NOTES&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => '<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked UP: <LAST_FAIL><br>Host Previously DOWN for: <DOWNTIME><br><br>Snmp Info:<br>Name - <SNMP_HOSTNAME><br>Location - <SNMP_LOCATION><br>Uptime - <UPTIMETEXT> (<UPTIME> ms)<br>System - <SNMP_SYSTEM><br><br>NOTE: <NOTES>'), 'thold_from_email' => array('friendly_name' => 'From Email Address', 'description' => 'This is the Email address that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_email"), 'max_length' => 255), 'thold_from_name' => array('friendly_name' => 'From Name', 'description' => 'This is the actual name that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_name"), 'max_length' => 255), 'thold_alert_text' => array('friendly_name' => 'Threshold Alert Message', 'description' => 'This is the message that will be displayed at the top of all Threshold Alerts (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'An Alert has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_warning_text' => array('friendly_name' => 'Threshold Warning Message', 'description' => 'This is the message that will be displayed at the top of all threshold warnings (255 Char MAX).  HTML is allowed, but will be removed for text only Emails.  There are several descriptors that may be used.<br>&#060DESCRIPTION&#062 &#060HOSTNAME&#062 &#060TIME&#062 &#060URL&#062 &#060GRAPHID&#062 &#060CURRENTVALUE&#062 &#060THRESHOLDNAME&#062  &#060DSNAME&#062 &#060SUBJECT&#062 &#060GRAPH&#062', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'A warning has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_send_text_only' => array('friendly_name' => 'Send Alerts as Text', 'description' => 'If checked, this will cause all Alerts to be sent as plain text Emails with no graph.  The default is HTML Emails with the graph embedded in the Email.', 'method' => 'checkbox', 'default' => 'off'), 'thold_baseline_header' => array('friendly_name' => 'Default Baseline Settings', 'method' => 'spacer'), 'alert_bl_timerange_def' => array('friendly_name' => 'Baseline Time Range Default', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'drop_array', 'array' => get_reference_types(), 'size' => 12, 'max_length' => 12, 'default' => 86400), 'alert_bl_trigger' => array('friendly_name' => 'Baseline Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the calculated Baseline Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 2), 'alert_bl_percent_def' => array('friendly_name' => 'Baseline Deviation Percentage', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'textbox', 'size' => 3, 'max_length' => 3, 'default' => 20));
}