示例#1
0
function form_save()
{
    global $plugins;
    if (isset_request_var('save_component')) {
        /* ================= input validation ================= */
        get_filter_request_var('id');
        get_filter_request_var('mtype');
        get_filter_request_var('minterval');
        if (isset_request_var('name')) {
            set_request_var('name', trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('name'))));
        }
        if (isset_request_var('stime')) {
            set_request_var('stime', trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('stime'))));
        }
        if (isset_request_var('etime')) {
            set_request_var('etime', trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('etime'))));
        }
        /* ==================================================== */
        $save['id'] = get_nfilter_request_var('id');
        $save['name'] = get_nfilter_request_var('name');
        $save['mtype'] = get_nfilter_request_var('mtype');
        $save['stime'] = strtotime(get_nfilter_request_var('stime'));
        $save['etime'] = strtotime(get_nfilter_request_var('etime'));
        $save['minterval'] = get_nfilter_request_var('minterval');
        if (isset_request_var('enabled')) {
            $save['enabled'] = 'on';
        } else {
            $save['enabled'] = '';
        }
        if ($save['mtype'] == 1) {
            $save['minterval'] = 0;
        }
        if ($save['stime'] >= $save['etime']) {
            raise_message(2);
        }
        if (!is_error_message()) {
            $id = sql_save($save, 'plugin_maint_schedules');
            if ($id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        header('Location: maint.php?tab=general&action=edit&header=false&id=' . (empty($id) ? get_request_var('id') : $id));
        exit;
    }
}
示例#2
0
function mactrack_snmp_edit()
{
    global $config, $fields_mactrack_snmp_edit;
    include_once $config['base_path'] . '/plugins/mactrack/lib/mactrack_functions.php';
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('page');
    /* ==================================================== */
    /* clean up rule name */
    if (isset_request_var('name')) {
        set_request_var('name', sanitize_search_string(get_request_var('name')));
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value('page', 'sess_mactrack_edit_current_page', '1');
    load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
    /* display the mactrack snmp option set */
    $snmp_group = array();
    if (!isempty_request_var('id')) {
        $snmp_group = db_fetch_row_prepared('SELECT * FROM mac_track_snmp where id = ?', array(get_request_var('id')));
        $header_label = __('SNMP Option Set [edit: %s]', $snmp_group['name']);
    } else {
        $header_label = __('SNMP Option Set [new]');
    }
    form_start('mactrack_snmp.php', 'mactrack_snmp_group');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_mactrack_snmp_edit, $snmp_group)));
    html_end_box();
    form_hidden_box('id', isset_request_var('id') ? get_request_var('id') : '0', '');
    form_hidden_box('save_component_mactrack_snmp', '1', '');
    if (!isempty_request_var('id')) {
        $items = db_fetch_assoc_prepared('SELECT * FROM mac_track_snmp_items WHERE snmp_id= ? ORDER BY sequence', array(get_request_var('id')));
        html_start_box(__('Mactrack SNMP Options'), '100%', '', '3', 'center', 'mactrack_snmp.php?action=item_edit&id=' . get_request_var('id'));
        print "<tr class='tableHeader'>";
        DrawMatrixHeaderItem(__('Item'), '', 1);
        DrawMatrixHeaderItem(__('Version'), '', 1);
        DrawMatrixHeaderItem(__('Community'), '', 1);
        DrawMatrixHeaderItem(__('Port'), '', 1);
        DrawMatrixHeaderItem(__('Timeout'), '', 1);
        DrawMatrixHeaderItem(__('Retries'), '', 1);
        DrawMatrixHeaderItem(__('Max OIDs'), '', 1);
        DrawMatrixHeaderItem(__('Username'), '', 1);
        DrawMatrixHeaderItem(__('Auth Proto'), '', 1);
        DrawMatrixHeaderItem(__('Priv Proto'), '', 1);
        DrawMatrixHeaderItem(__('Actions'), '', 1);
        print '</tr>';
        $i = 1;
        if (sizeof($items)) {
            foreach ($items as $item) {
                form_alternate_row();
                $form_data = '<td><a class="linkEditMain" href="' . htmlspecialchars('mactrack_snmp.php?action=item_edit&item_id=' . $item['id'] . '&id=' . $item['snmp_id']) . '">Item#' . $i . '</a></td>';
                $form_data .= '<td>' . $item['snmp_version'] . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? __('N/A') : $item['snmp_readstring']) . '</td>';
                $form_data .= '<td>' . $item['snmp_port'] . '</td>';
                $form_data .= '<td>' . $item['snmp_timeout'] . '</td>';
                $form_data .= '<td>' . $item['snmp_retries'] . '</td>';
                $form_data .= '<td>' . $item['max_oids'] . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_username'] : __('N/A')) . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_auth_protocol'] : __('N/A')) . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_priv_protocol'] : __('N/A')) . '</td>';
                $form_data .= '<td class="right">' . ($i < sizeof($items) ? '<a class="remover fa fa-caret-down moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_movedown&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>') . ($i > 1 ? '<a class="remover fa fa-caret-up moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_moveup&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>');
                $form_data .= '<a class="delete deleteMarker fa fa-remove" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_remove&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' . '</td></tr>';
                print $form_data;
                $i++;
            }
        } else {
            print '<tr><td colspan="5"><em>' . __('No SNMP Items') . '</em></td></tr>';
        }
        html_end_box();
    }
    form_save_button('mactrack_snmp.php');
}
示例#3
0
function thold_add_graphs_action_prepare()
{
    global $config;
    $local_graph_id = get_filter_request_var('local_graph_id');
    top_header();
    html_start_box(__('Create Threshold from Template'), '60%', '', '3', 'center', '');
    form_start('thold.php?action=add');
    /* get the valid thold templates
     * remove those hosts that do not have any valid templates
     */
    $templates = '';
    $found_list = '';
    $not_found = '';
    $data_template_id = db_fetch_cell("SELECT dtr.data_template_id\n\t\t FROM data_template_rrd AS dtr\n\t\t LEFT JOIN graph_templates_item AS gti\n\t\t ON gti.task_item_id=dtr.id\n\t\t LEFT JOIN graph_local AS gl\n\t\t ON gl.id=gti.local_graph_id\n\t\t WHERE gl.id={$local_graph_id}");
    if ($data_template_id != '') {
        if (sizeof(db_fetch_assoc("SELECT id FROM thold_template WHERE data_template_id={$data_template_id}"))) {
            $found_list .= '<li>' . get_graph_title($local_graph_id) . '</li>';
            if (strlen($templates)) {
                $templates .= ", {$data_template_id}";
            } else {
                $templates = "{$data_template_id}";
            }
        } else {
            $not_found .= '<li>' . get_graph_title($local_graph_id) . '</li>';
        }
    } else {
        $not_found .= '<li>' . get_graph_title($local_graph_id) . '</li>';
    }
    if (strlen($templates)) {
        $sql = 'SELECT id, name FROM thold_template WHERE data_template_id IN (' . $templates . ') ORDER BY name';
    } else {
        $sql = 'SELECT id, name FROM thold_template ORDER BY name';
    }
    print "<tr><td colspan='2' class='textArea'>\n";
    if (strlen($found_list)) {
        if (strlen($not_found)) {
            print '<p>' . __('The following Graph has no Threshold Templates associated with them.') . '</p>';
            print '<ul>' . $not_found . '</ul>';
        }
        print '<p>' . __('Are you sure you wish to create Thresholds for this Graph?') . '
			<ul>' . $found_list . "</ul>\n\t\t\t</td>\n\t\t</tr>\n";
        if (isset_request_var('tree_id')) {
            get_filter_request_var('tree_id');
        } else {
            set_request_var('tree_id', '');
        }
        if (isset_request_var('leaf_id')) {
            get_filter_request_var('leaf_id');
        } else {
            set_request_var('leaf_id', '');
        }
        $form_array = array('general_header' => array('friendly_name' => __('Available Threshold Templates'), 'method' => 'spacer'), 'thold_template_id' => array('method' => 'drop_sql', 'friendly_name' => __('Select a Threshold Template'), 'description' => '', 'none_value' => __('None'), 'value' => __('None'), 'sql' => $sql), 'usetemplate' => array('method' => 'hidden', 'value' => 1), 'local_graph_id' => array('method' => 'hidden', 'value' => $local_graph_id));
        draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
    } else {
        if (strlen($not_found)) {
            print '<p>' . __('There are no Threshold Templates associated with the following Graph.') . '</p>';
            print '<ul>' . $not_found . '</ul>';
        }
        $form_array = array('general_header' => array('friendly_name' => __('Please select an action'), 'method' => 'spacer'), 'doaction' => array('method' => 'drop_array', 'friendly_name' => __('Threshold Action'), 'description' => __('You may either create a new Threshold Template, or an non-templated Threshold from this screen.'), 'value' => 'None', 'array' => array(1 => __('Create a new Threshold'), 2 => __('Create a Threshold Template'))), 'usetemplate' => array('method' => 'hidden', 'value' => 1), 'local_graph_id' => array('method' => 'hidden', 'value' => $local_graph_id));
        draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
    }
    if (!strlen($not_found)) {
        $save_html = "<input type='submit' value='" . __('Continue') . "'>";
        print "<tr>\n\t\t\t<td colspan='2' class='saveRow'>\n\t\t\t\t<input type='hidden' id='action' value='actions'>\n\t\t\t\t<input type='button' onClick='cactiReturnTo()' value='" . __('Cancel') . "' title='" . __('Cancel') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
    } else {
        $save_html = "<input type='submit' value='" . __('Continue') . "'>";
        print "<tr>\n\t\t\t<td colspan='2' class='saveRow'>\n\t\t\t\t<input type='button' onClick='cactiReturnTo()' value='" . __('Cancel') . "' title='" . __('Cancel') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
    }
    html_end_box();
    print "<script type='text/javascript'>\$(function() { applySkin() ;});</script>";
    bottom_footer();
}
示例#4
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 
}
示例#5
0
function form_actions()
{
    global $colors, $user_actions, $fields_user_edit;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset_request_var('selected_items')) {
        $selected_items = unserialize(stripslashes(get_request_var('selected_items')));
        if (get_request_var('drp_action') == '1') {
            /* delete */
            if (!isset_request_var('delete_type')) {
                set_request_var('delete_type', 2);
            }
            $data_sources_to_act_on = array();
            $graphs_to_act_on = array();
            $devices_to_act_on = array();
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                $selected_items[$i] = sanitize_search_string($selected_items[$i]);
                /* ==================================================== */
                $data_sources = db_fetch_assoc('SELECT
					data_local.id AS local_data_id
					FROM data_local
					WHERE ' . array_to_sql_or($selected_items, 'data_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'");
                if (sizeof($data_sources) > 0) {
                    foreach ($data_sources as $data_source) {
                        $data_sources_to_act_on[] = $data_source['local_data_id'];
                    }
                }
                $graphs = db_fetch_assoc('SELECT
					graph_local.id AS local_graph_id
					FROM graph_local
					WHERE ' . array_to_sql_or($selected_items, 'graph_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'");
                if (sizeof($graphs) > 0) {
                    foreach ($graphs as $graph) {
                        $graphs_to_act_on[] = $graph['local_graph_id'];
                    }
                }
                $devices_to_act_on[] = $selected_items[$i];
            }
            api_data_source_remove_multi($data_sources_to_act_on);
            api_graph_remove_multi($graphs_to_act_on);
            db_execute("DELETE FROM plugin_mikrotik_users WHERE name IN ('" . implode("','", $devices_to_act_on) . "')");
        }
        header('Location: mikrotik_users.php?header=false');
        exit;
    }
    /* setup some variables */
    $user_list = '';
    /* loop through each of the user templates selected on the previous page and get more info about them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match('/^chk_([A-Z0-9]+)$/', $var, $matches)) {
            /* ================= input validation ================= */
            $matches[1] = sanitize_search_string($matches[1]);
            /* ==================================================== */
            $user_list .= '<li>' . $matches[1] . '</li>';
            $user_array[] = $matches[1];
        }
    }
    top_header();
    html_start_box('<strong>' . $user_actions[get_request_var('drp_action')] . '</strong>', '60%', '', '3', 'center', '');
    print "<form action='mikrotik_users.php' autocomplete='off' method='post'>\n";
    if (isset($user_array) && sizeof($user_array)) {
        if (get_request_var('drp_action') == '1') {
            /* delete */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Users(s) and their Graph(s).') . "</p>\n\t\t\t\t\t\t<ul>" . $user_list . "</ul>";
            print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Delete Device(s)') . "'>";
        }
    } else {
        print "<tr><td><span class='textError'>" . __('You must select at least one User.') . "</span></td></tr>\n";
        $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
    }
    print "<tr class='saveRow'>\n\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var("drp_action") . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n";
    html_end_box();
    bottom_footer();
}
示例#6
0
function hmib_summary()
{
    global $device_actions, $item_rows, $config;
    /* ================= input validation ================= */
    get_filter_request_var('htop');
    get_filter_request_var('ptop');
    /* ==================================================== */
    /* clean up sort string */
    if (isset_request_var('sort_column')) {
        set_request_var('sort_column', sanitize_search_string(get_nfilter_request_var('sort_column')));
    }
    /* clean up sort string */
    if (isset_request_var('sort_direction')) {
        set_request_var('sort_direction', sanitize_search_string(get_nfilter_request_var('sort_direction')));
    }
    /* clean up search string */
    if (isset_request_var('filter')) {
        set_request_var('filter', sanitize_search_string(get_nfilter_request_var('filter')));
    }
    /* remember these search fields in session vars so we don't have
     * to keep passing them around
     */
    if (isset_request_var('area') && get_nfilter_request_var('area') == 'processes') {
        if (isset_request_var('clear')) {
            kill_session_var('sess_hmib_proc_top');
            kill_session_var('sess_hmib_proc_filter');
            kill_session_var('sess_hmib_proc_sort_column');
            kill_session_var('sess_hmib_proc_sort_direction');
            unset_request_var('filter');
            unset_request_var('ptop');
            unset_request_var('sort_column');
            unset_request_var('sort_direction');
        }
        if (isset_request_var('sort_column')) {
            $_SESSION['sess_hmib_proc_sort_column'] = get_request_var('sort_column');
            $_SESSION['sess_hmib_proc_sort_direction'] = get_request_var('sort_direction');
        } elseif (!isset($_SESSION['sess_hmib_proc_sort_column'])) {
            $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu';
            $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC';
        }
        if (!isset($_SESSION['sess_hmib_host_sort_column'])) {
            $_SESSION['sess_hmib_host_sort_column'] = 'downHosts';
            $_SESSION['sess_hmib_host_sort_direction'] = 'DESC';
        }
    } elseif (isset_request_var('area') && get_nfilter_request_var('area') == 'hosts') {
        if (isset_request_var('clear')) {
            kill_session_var('sess_hmib_host_top');
            kill_session_var('sess_hmib_host_sort_column');
            kill_session_var('sess_hmib_host_sort_direction');
            unset_request_var('htop');
            unset_request_var('sort_column');
            unset_request_var('sort_direction');
        }
        if (isset_request_var('sort_column')) {
            $_SESSION['sess_hmib_host_sort_column'] = get_request_var('sort_column');
            $_SESSION['sess_hmib_host_sort_direction'] = get_request_var('sort_direction');
        } elseif (!isset($_SESSION['sess_hmib_host_sort_column'])) {
            $_SESSION['sess_hmib_host_sort_column'] = 'downHosts';
            $_SESSION['sess_hmib_host_sort_direction'] = 'DESC';
        }
        if (!isset($_SESSION['sess_hmib_proc_sort_column'])) {
            $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu';
            $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC';
        }
    } else {
        if (!isset($_SESSION['sess_hmib_host_sort_column'])) {
            $_SESSION['sess_hmib_host_sort_column'] = 'downHosts';
            $_SESSION['sess_hmib_host_sort_direction'] = 'DESC';
        }
        if (!isset($_SESSION['sess_hmib_proc_sort_column'])) {
            $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu';
            $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC';
        }
    }
    load_current_session_value('ptop', 'sess_hmib_proc_top', read_config_option('hmib_top_processes'));
    load_current_session_value('htop', 'sess_hmib_host_top', read_config_option('hmib_top_types'));
    load_current_session_value('filter', 'sess_hmib_proc_filter', '');
    /* set some defaults */
    $url = $config['url_path'] . 'plugins/hmib/hmib.php';
    $proc = $config['url_path'] . 'plugins/hmib/images/cog.png';
    $host = $config['url_path'] . 'plugins/hmib/images/server.png';
    $hardw = $config['url_path'] . 'plugins/hmib/images/view_hardware.gif';
    $inven = $config['url_path'] . 'plugins/hmib/images/view_inventory.gif';
    $storage = $config['url_path'] . 'plugins/hmib/images/drive.png';
    $htdq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='137aeab842986a76cf5bdef41b96c9a3'");
    $hcpudq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='0d1ab53fe37487a5d0b9e1d3ee8c1d0d'");
    $hugt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='e8462bbe094e4e9e814d4e681671ea82'");
    $hpgt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='62205afbd4066e5c4700338841e3901e'");
    $htsd = db_fetch_cell("SELECT id\n\t\tFROM host_template\n\t\tWHERE hash='7c13344910097cc599f0d0485305361d'");
    if ($htdq == 0 || $hcpudq == 0 || $hugt == 0 || $hpgt == 0 || $htsd == 0) {
        $templates_missing = true;
    } else {
        $templates_missing = false;
    }
    ?>
	<script type='text/javascript'>
	function applyFilter(objForm) {
		strURL  = '?action=summary&area=hosts&header=false';
		strURL += '&htop=' + $('#htop').val();
		loadPageNoHeader(strURL);
	}

	function clearFilter() {
		strURL = '?area=hosts&clear=true&header=false';
		loadPageNoHeader(strURL);
	}
	</script>
	<?php 
    html_start_box(__('Summary Filter'), '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
			<form name='host_summary'>
			<table class='filterTable'>
				<tr>
					<td>
						<?php 
    print __('Top');
    ?>
					</td>
					<td>
						<select id='htop' onChange='applyFilter()'>
							<option value='-1'<?php 
    if (get_request_var('htop') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('All Records');
    ?>
</option>
							<option value='5'<?php 
    if (get_request_var('htop') == '5') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Records', 5);
    ?>
</option>
							<option value='10'<?php 
    if (get_request_var('htop') == '10') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Record', 10);
    ?>
s</option>
							<option value='15'<?php 
    if (get_request_var('htop') == '15') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Record', 15);
    ?>
s</option>
							<option value='20'<?php 
    if (get_request_var('htop') == '20') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Record', 20);
    ?>
s</option>
						</select>
					</td>
					<td>
						<input type='button' onClick='applyFilter()' value='<?php 
    print __('Go');
    ?>
'>
					</td>
					<td>
						<input type='button' onClick='clearFilter()' value='<?php 
    print __('Clear');
    ?>
' name='clear'>
					</td>
					<td>
						&nbsp;&nbsp;<?php 
    print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs.  See the README for more information.') . '</strong>' : '';
    ?>
					</td>
				</tr>
			</table>
			</form>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    html_start_box(__('Device Type Summary Statistics'), '100%', '', '3', 'center', '');
    if (!isset($_SESSION['sess_hmib_host_top'])) {
        $limit = 'LIMIT ' . read_config_option('hmib_top_types');
    } elseif ($_SESSION['sess_hmib_host_top'] == '-1') {
        $limit = '';
    } else {
        $limit = 'LIMIT ' . $_SESSION['sess_hmib_host_top'];
    }
    $sql = 'SELECT
		hrst.id AS id,
		hrst.name AS name,
		hrst.version AS version,
		hrs.host_type AS host_type,
		SUM(CASE WHEN host_status=3 THEN 1 ELSE 0 END) AS upHosts,
		SUM(CASE WHEN host_status=2 THEN 1 ELSE 0 END) AS recHosts,
		SUM(CASE WHEN host_status=1 THEN 1 ELSE 0 END) AS downHosts,
		SUM(CASE WHEN host_status=0 THEN 1 ELSE 0 END) AS disabledHosts,
		SUM(users) AS users,
		SUM(numCpus) AS cpus,
		AVG(memUsed) AS avgMem,
		MAX(memUsed) AS maxMem,
		AVG(swapUsed) AS avgSwap,
		MAX(swapUsed) AS maxSwap,
		AVG(cpuPercent) AS avgCpuPercent,
		MAX(cpuPercent) AS maxCpuPercent,
		AVG(processes) AS avgProcesses,
		MAX(processes) AS maxProcesses
		FROM plugin_hmib_hrSystem AS hrs
		LEFT JOIN plugin_hmib_hrSystemTypes AS hrst
		ON hrs.host_type=hrst.id
		GROUP BY name, version
		ORDER BY ' . $_SESSION['sess_hmib_host_sort_column'] . ' ' . $_SESSION['sess_hmib_host_sort_direction'] . ' ' . $limit;
    $rows = db_fetch_assoc($sql);
    $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), '(version/1)' => array('display' => __('Version'), 'sort' => 'ASC', 'align' => 'right'), 'upHosts' => array('display' => __('Up'), 'sort' => 'DESC', 'align' => 'right'), 'recHosts' => array('display' => __('Recovering'), 'sort' => 'DESC', 'align' => 'right'), 'downHosts' => array('display' => __('Down'), 'sort' => 'DESC', 'align' => 'right'), 'disabledHosts' => array('display' => __('Disabled'), 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => __('Logins'), 'sort' => 'DESC', 'align' => 'right'), 'cpus' => array('display' => __('CPUS'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpuPercent' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpuPercent' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMem' => array('display' => __('Avg Mem'), 'sort' => 'DESC', 'align' => 'right'), 'maxMem' => array('display' => __('Max Mem'), 'sort' => 'DESC', 'align' => 'right'), 'avgSwap' => array('display' => __('Avg Swap'), 'sort' => 'DESC', 'align' => 'right'), 'maxSwap' => array('display' => __('Max Swap'), 'sort' => 'DESC', 'align' => 'right'), 'avgProcesses' => array('display' => __('Avg Proc'), 'sort' => 'DESC', 'align' => 'right'), 'maxProcesses' => array('display' => __('Max Proc'), 'sort' => 'DESC', 'align' => 'right'));
    html_header_sort($display_text, $_SESSION['sess_hmib_host_sort_column'], $_SESSION['sess_hmib_host_sort_direction'], false, 'hmib.php?action=summary&area=hosts');
    if (sizeof($rows)) {
        foreach ($rows as $row) {
            if (!$templates_missing) {
                $host_id = db_fetch_cell("SELECT id FROM host WHERE host_template_id={$htsd}");
                $graph_url = hmib_get_graph_url($htdq, 0, $host_id, $row['id']);
                $graph_ncpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', $row['cpus'], false);
                $graph_acpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['avgCpuPercent'], 2), false);
                $graph_mcpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['maxCpuPercent'], 2), false);
                $graph_users = hmib_get_graph_template_url($hugt, $row['id'], 0, $row['users'], false);
                $graph_aproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['avgProcesses'], 0), false);
                $graph_mproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['maxProcesses'], 0), false);
            } else {
                $graph_url = '';
                $graph_ncpu = '';
                $graph_acpu = '';
                $graph_mcpu = '';
                $graph_users = '';
                $graph_aproc = '';
                $graph_mproc = '';
            }
            form_alternate_row();
            echo "<td style='white-space:nowrap;' width='120'>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&type=" . $row['id']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=storage&ostype=" . $row['id']) . "'><img src='{$storage}' title='" . __('View Storage') . "' align='absmiddle' alt=''></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=hardware&ostype=" . $row['id']) . "'><img src='{$hardw}' title='" . __('View Hardware') . "' align='absmiddle' alt=''></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&type=" . $row['id']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=software&ostype=" . $row['id']) . "'><img src='{$inven}' title='" . __('View Software Inventory') . "' align='absmiddle' alt=''></a>";
            echo $graph_url;
            echo '</td>';
            $upHosts = hmib_get_device_status_url($row['upHosts'], $row['host_type'], 3);
            $recHosts = hmib_get_device_status_url($row['recHosts'], $row['host_type'], 2);
            $downHosts = hmib_get_device_status_url($row['downHosts'], $row['host_type'], 1);
            $disaHosts = hmib_get_device_status_url($row['disabledHosts'], $row['host_type'], 0);
            echo "<td class='nowrap left'>" . ($row['name'] != '' ? $row['name'] : 'Unknown') . '</td>';
            echo "<td class='nowrap right'>" . $row['version'] . '</td>';
            echo "<td class='nowrap right'>" . $upHosts . '</td>';
            echo "<td class='nowrap right'>" . $recHosts . '</td>';
            echo "<td class='nowrap right'>" . $downHosts . '</td>';
            echo "<td class='nowrap right'>" . $disaHosts . '</td>';
            echo "<td class='nowrap right'>" . $graph_users . '</td>';
            echo "<td class='nowrap right'>" . $graph_ncpu . '</td>';
            echo "<td class='nowrap right'>" . $graph_acpu . ' %</td>';
            echo "<td class='nowrap right'>" . $graph_mcpu . ' %</td>';
            echo "<td class='nowrap right'>" . round($row['avgMem'], 2) . ' %</td>';
            echo "<td class='nowrap right'>" . round($row['maxMem'], 2) . ' %</td>';
            echo "<td class='nowrap right'>" . round($row['avgSwap'], 2) . ' %</td>';
            echo "<td class='nowrap right'>" . round($row['maxSwap'], 2) . ' %</td>';
            echo "<td class='nowrap right'>" . $graph_aproc . '</td>';
            echo "<td class='nowrap right'>" . $graph_mproc . '</td>';
        }
        echo '</tr>';
    } else {
        print '<tr><td colspan="8"><em>' . __('No Device Types') . '</em></td></tr>';
    }
    html_end_box();
    html_start_box(__('Process Summary Filter'), '100%', '', '3', 'center', '');
    ?>
	<script type='text/javascript'>
	function applyProcFilter(objForm) {
		strURL  = '?action=summary&area=processes';
		strURL += '&filter='  + $('#filter').val();
		strURL += '&ptop='    + $('#ptop').val();
		strURL += '&header=false';
		loadPageNoHeader(strURL);
	}

	function clearProc() {
		strURL = '?action=summary&area=processes&clear=true&header=false';
		loadPageNoHeader(strURL);
	}

	$(function() {
		$('#proc_summary').submit(function(event) {
			event.preventDefault();
			applyProcFilter();
		});
	});
	</script>
	<?php 
    ?>
	<tr class='even'>
		<td>
			<form id='proc_summary'>
			<table class='filterTable'>
				<tr>
					<td style='width:55px;'>
						<?php 
    print __('Search');
    ?>
					</td>
					<td>
						<input type='textbox' size='25' id='filter' value='<?php 
    print get_request_var('filter');
    ?>
'>
					</td>
					<td>
						<?php 
    print __('Top');
    ?>
					</td>
					<td>
						<select id='ptop' onChange='applyProcFilter()'>
							<option value='-1'<?php 
    if (get_request_var('ptop') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('All Records');
    ?>
</option>
							<option value='5'<?php 
    if (get_request_var('ptop') == '5') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Records', 5);
    ?>
</option>
							<option value='10'<?php 
    if (get_request_var('ptop') == '10') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Records', 10);
    ?>
</option>
							<option value='15'<?php 
    if (get_request_var('ptop') == '15') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Records', 15);
    ?>
</option>
							<option value='20'<?php 
    if (get_request_var('ptop') == '20') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('%d Records', 20);
    ?>
</option>
						</select>
					</td>
					<td>
						<input type='button' onClick='applyProcFilter(document.proc_summary)' value='<?php 
    print __('Go');
    ?>
'>
					</td>
					<td>
						<input type='button' onClick='clearProc()' value='<?php 
    print __('Clear');
    ?>
'>
					</td>
					<td>
						&nbsp;&nbsp;<?php 
    print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs.  See the README for more information.') . '</strong>' : '';
    ?>
					</td>
				</tr>
			</table>
			</form>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    html_start_box(__('Process Summary Statistics'), '100%', '', '3', 'center', '');
    if (!isset($_SESSION['sess_hmib_proc_top'])) {
        $limit = 'LIMIT ' . read_config_option('hmib_top_processes');
    } elseif ($_SESSION['sess_hmib_proc_top'] == '-1') {
        $limit = '';
    } else {
        $limit = 'LIMIT ' . $_SESSION['sess_hmib_proc_top'];
    }
    if (strlen(get_request_var('filter'))) {
        $sql_where = "AND (hrswr.name LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.path LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.parameters LIKE '%" . get_request_var('filter') . "%')";
    } else {
        $sql_where = '';
    }
    $sql = "SELECT\n\t\thrswr.name AS name,\n\t\tCOUNT(DISTINCT hrswr.path) AS paths,\n\t\tCOUNT(DISTINCT hrswr.host_id) AS numHosts,\n\t\tCOUNT(hrswr.host_id) AS numProcesses,\n\t\tAVG(hrswr.perfCPU) AS avgCpu,\n\t\tMAX(hrswr.perfCPU) AS maxCpu,\n\t\tAVG(hrswr.perfMemory) AS avgMemory,\n\t\tMAX(hrswr.perfMemory) AS maxMemory\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tWHERE hrswr.name!='System Idle Process' AND hrswr.name!=''\n\t\t{$sql_where}\n\t\tGROUP BY hrswr.name\n\t\tORDER BY " . $_SESSION['sess_hmib_proc_sort_column'] . ' ' . $_SESSION['sess_hmib_proc_sort_direction'] . ' ' . $limit;
    $rows = db_fetch_assoc($sql);
    //echo $sql;
    $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Process Name'), 'sort' => 'ASC', 'align' => 'left'), 'paths' => array('display' => __('Num Paths'), 'sort' => 'DESC', 'align' => 'right'), 'numHosts' => array('display' => __('Hosts'), 'sort' => 'DESC', 'align' => 'right'), 'numProcesses' => array('display' => __('Processes'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpu' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpu' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMemory' => array('display' => __('Avg Memory'), 'sort' => 'DESC', 'align' => 'right'), 'maxMemory' => array('display' => __('Max Memory'), 'sort' => 'DESC', 'align' => 'right'));
    html_header_sort($display_text, $_SESSION['sess_hmib_proc_sort_column'], $_SESSION['sess_hmib_proc_sort_direction'], false, 'hmib.php?action=summary&area=processes');
    /* set some defaults */
    $url = $config['url_path'] . 'plugins/hmib/hmib.php';
    $proc = $config['url_path'] . 'plugins/hmib/images/cog.png';
    $host = $config['url_path'] . 'plugins/hmib/images/server.png';
    /* get the data query for the application use */
    $adq = db_fetch_cell("SELECT id\n\t\tFROM snmp_query\n\t\tWHERE hash='6b0ef0fe7f1d85bbb6812801ca15a7c5'");
    if (sizeof($rows)) {
        foreach ($rows as $row) {
            $graph_url = hmib_get_graph_url($adq, 0, 0, $row['name']);
            form_alternate_row();
            echo "<td width='70'>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&process=" . $row['name']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>";
            echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&process=" . $row['name']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>";
            echo $graph_url;
            echo '</td>';
            echo "<td class='left' width='140'>" . $row['name'] . '</td>';
            echo "<td class='right'>" . $row['paths'] . '</td>';
            echo "<td class='right'>" . $row['numHosts'] . '</td>';
            echo "<td class='right'>" . $row['numProcesses'] . '</td>';
            echo "<td class='right'>" . number_format_i18n($row['avgCpu'] / 3600, 0) . ' Hrs</td>';
            echo "<td class='right'>" . number_format_i18n($row['maxCpu'] / 3600, 0) . ' Hrs</td>';
            echo "<td class='right'>" . number_format_i18n($row['avgMemory'] / 1024, 2) . ' MB</td>';
            echo "<td class='right'>" . number_format_i18n($row['maxMemory'] / 1024, 2) . ' MB</td>';
        }
        echo '</tr>';
    } else {
        print '<tr><td><em>' . __('No Processes') . '</em></td></tr>';
    }
    html_end_box();
}
示例#7
0
/** flowview_viewtable() 
 *
 *  This function is will echo the stored table
 *  less any outliers back to the browser.
 */
function flowview_viewtable()
{
    global $config;
    $sessionid = get_request_var('session');
    $flowdata = unserialize(base64_decode(get_request_var('session')));
    foreach ($flowdata['post'] as $item => $value) {
        switch ($item) {
            case 'bytes':
            case 'flows':
            case 'packets':
                break;
            default:
                set_request_var($item, $value);
        }
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    $_SESSION['sess_flows_table'] = 'on';
    include $config['base_path'] . '/plugins/flowview/variables.php';
    $title = get_request_var('title');
    $output = $_SESSION['flowview_flows'][$sessionid]['rawdata'];
    echo parsestatoutput($output, $title, $sessionid);
}
示例#8
0
function syslog_filter($sql_where, $tab)
{
    global $config, $graph_timespans, $graph_timeshifts, $reset_multi, $page_refresh_interval, $item_rows, $trimvals;
    include dirname(__FILE__) . '/config.php';
    $unprocessed = syslog_db_fetch_cell("SELECT COUNT(*) FROM `" . $syslogdb_default . "`.`syslog_incoming`");
    if (isset($_SESSION['sess_current_date1'])) {
        $filter_text = __(' [ Start: \'%s\' to End: \'%s\', Unprocessed Messages: %s ]', $_SESSION['sess_current_date1'], $_SESSION['sess_current_date2'], $unprocessed);
    } else {
        $filter_text = __('[ Unprocessed Messages: %s ]', $unprocessed);
    }
    ?>
	<script type='text/javascript'>

	var date1Open = false;
	var date2Open = false;

	$(function() {
		$('#syslog_form').submit(function(event) {
			event.preventDefault();
			applyFilter();
		});

		$('#host').multiselect({
			noneSelectedText: '<?php 
    print __('Select Device(s)');
    ?>
', 
			selectedText: function(numChecked, numTotal, checkedItems) {
				myReturn = numChecked + ' <?php 
    print __('Devices Selected');
    ?>
';
				$.each(checkedItems, function(index, value) {
					if (value.value == '0') {
						myReturn='<?php 
    print __('All Devices Selected');
    ?>
';
						return false;
					}
				});
				return myReturn;
			},
			checkAllText: '<?php 
    print __('All');
    ?>
', 
			uncheckAllText: '<?php 
    print __('None');
    ?>
',
			uncheckall: function() {
				$(this).multiselect('widget').find(':checkbox:first').each(function() {
					$(this).prop('checked', true);
				});
			},
			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: '<?php 
    print __('Search');
    ?>
', width: '150'
		});

		$('#save').click(function() {
			saveSettings();
		});

		$('#go').click(function() {
			applyFilter();
		});

		$('#clear').click(function() {
			clearFilter();
		});

		$('#startDate').click(function() {
			if (date1Open) {
				date1Open = false;
				$('#date1').datetimepicker('hide');
			}else{
				date1Open = true;
				$('#date1').datetimepicker('show');
			}
		});

		$('#endDate').click(function() {
			if (date2Open) {
				date2Open = false;
				$('#date2').datetimepicker('hide');
			}else{
				date2Open = true;
				$('#date2').datetimepicker('show');
			}
		});

		$('#date1').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$('#date2').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$(window).resize(function() {
			resizeHostSelect();
		});

		resizeHostSelect();
	});

	function resizeHostSelect() {
		position = $('#host').offset();
		$('#host').css('height', ($(window).height()-position.top)+'px');
	}

	function applyTimespan() {
		strURL  = urlPath+'plugins/syslog/syslog.php?header=false&predefined_timespan=' + $('#predefined_timespan').val();
		strURL += '&predefined_timeshift=' + $('#predefined_timeshift').val();
		loadPageNoHeader(strURL);
	}

	function applyFilter() {
		strURL = 'syslog.php?header=false'+
			'&date1='+$('#date1').val()+
			'&date2='+$('#date2').val()+
			'&host='+$('#host').val()+
			'&filter='+$('#filter').val()+
			'&efacility='+$('#efacility').val()+
			'&epriority='+$('#epriority').val()+
			'&eprogram='+$('#eprogram').val()+
			'&rows='+$('#rows').val()+
			'&trimval='+$('#trimval').val()+
			'&removal='+$('#removal').val()+
			'&refresh='+$('#refresh').val();

		loadPageNoHeader(strURL);
	}

	function clearFilter() {
		strURL = 'syslog.php?header=false&clear=true';

		loadPageNoHeader(strURL);
	}

	function saveSettings() {
		strURL = 'syslog.php?action=save'+
			'&trimval='+$('#trimval').val()+
			'&rows='+$('#rows').val()+
			'&removal='+$('#removal').val()+
			'&refresh='+$('#refresh').val()+
			'&efacility='+$('#efacility').val()+
			'&epriority='+$('#epriority').val()+
			'&eprogram='+$('#eprogram').val();

		$.get(strURL, function() {
			$('#text').show().text('Filter Settings Saved').fadeOut(2000);
		});
	}

	function timeshiftFilterLeft() {
		var json = { 
			move_left_x: 1, 
			move_left_y: 1, 
			date1: $('#date1').val(), 
			date2: $('#date2').val(), 
			predefined_timespan: $('#predefined_timespan').val(), 
			predefined_timeshift: $('#predefined_timeshift').val(),
			__csrf_magic: csrfMagicToken
		};
	
		var href = urlPath+'plugins/syslog/syslog.php?action='+pageAction+'&header=false';
		$.post(href, json).done(function(data) {
			$('#main').html(data);
			applySkin();
		});
	}

	function timeshiftFilterRight() {
		var json = { 
			move_right_x: 1, 
			move_right_y: 1, 
			date1: $('#date1').val(), 
			date2: $('#date2').val(), 
			predefined_timespan: $('#predefined_timespan').val(), 
			predefined_timeshift: $('#predefined_timeshift').val(),
			__csrf_magic: csrfMagicToken
		};
	
		var href = urlPath+'plugins/syslog/syslog.php?action='+pageAction+'&header=false';
		$.post(href, json).done(function(data) {
			$('#main').html(data);
			applySkin();
		});
	}

	</script>
	<?php 
    html_start_box(__('Syslog Message Filter %s', $filter_text), '100%', '', '3', 'center', '');
    ?>
		<tr class='even noprint'>
			<td class='noprint'>
			<form id='syslog_form' action='syslog.php'>
				<table class='filterTable'>
					<tr>
						<td>
							<select id='predefined_timespan' onChange='applyTimespan()'>
								<?php 
    if ($_SESSION['custom']) {
        $graph_timespans[GT_CUSTOM] = __('Custom');
        set_request_var('predefined_timespan', GT_CUSTOM);
        $start_val = 0;
        $end_val = sizeof($graph_timespans);
    } else {
        if (isset($graph_timespans[GT_CUSTOM])) {
            asort($graph_timespans);
            array_shift($graph_timespans);
        }
        $start_val = 1;
        $end_val = sizeof($graph_timespans) + 1;
    }
    if (sizeof($graph_timespans) > 0) {
        for ($value = $start_val; $value < $end_val; $value++) {
            print "<option value='{$value}'";
            if (get_request_var('predefined_timespan') == $value) {
                print ' selected';
            }
            print '>' . title_trim($graph_timespans[$value], 40) . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							<?php 
    print __('From');
    ?>
						</td>
						<td>
							<input type='text' id='date1' size='15' value='<?php 
    print isset($_SESSION['sess_current_date1']) ? $_SESSION['sess_current_date1'] : '';
    ?>
'>
						</td>
						<td>
							<i title='<?php 
    print __('Start Date Selector');
    ?>
' class='calendar fa fa-calendar' id='startDate'></i>
						</td>
						<td>
							<?php 
    print __('To');
    ?>
						</td>
						<td>
							<input type='text' id='date2' size='15' value='<?php 
    print isset($_SESSION['sess_current_date2']) ? $_SESSION['sess_current_date2'] : '';
    ?>
'>
						</td>
						<td>
							<i title='<?php 
    print __('End Date Selector');
    ?>
' class='calendar fa fa-calendar' id='endDate'></i>
						</td>
						<td>
							<i title='<?php 
    print __('Shift Time Backward');
    ?>
' onclick='timeshiftFilterLeft()' class='shiftArrow fa fa-backward'></i>
						</td>
						<td>
							<select id='predefined_timeshift' title='<?php 
    print __('Define Shifting Interval');
    ?>
' onChange='applyTimespan()'>
								<?php 
    $start_val = 1;
    $end_val = sizeof($graph_timeshifts) + 1;
    if (sizeof($graph_timeshifts) > 0) {
        for ($shift_value = $start_val; $shift_value < $end_val; $shift_value++) {
            print "<option value='{$shift_value}'";
            if (get_request_var('predefined_timeshift') == $shift_value) {
                print ' selected';
            }
            print '>' . title_trim($graph_timeshifts[$shift_value], 40) . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							<i title='<?php 
    print __('Shift Time Forward');
    ?>
' onclick='timeshiftFilterRight()' class='shiftArrow fa fa-forward'></i>
						</td>
						<td>
							<input id='go' type='button' value='<?php 
    print __('Go');
    ?>
'>
						</td>
						<td>
							<input id='clear' type='button' value='<?php 
    print __('Clear');
    ?>
' title='<?php 
    print __('Return filter values to their user defined defaults');
    ?>
'>
						</td>
						<td>
							<input id='export' type='button' value='<?php 
    print __('Export');
    ?>
' title='<?php 
    print __('Export Records to CSV');
    ?>
'>
						</td>
						<td>
							<input id='save' type='button' value='<?php 
    print __('Save');
    ?>
' title='<?php 
    print __('Save Default Settings');
    ?>
'>
						</td>
						<?php 
    if (api_plugin_user_realm_auth('syslog_alerts.php')) {
        ?>
						<td align='right' style='white-space:nowrap;'>
							<input type='button' value='<?php 
        print __('Alerts');
        ?>
' title='<?php 
        print __('View Syslog Alert Rules');
        ?>
' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_alerts.php";
        ?>
"'>
						</td>
						<td>
							<input type='button' value='<?php 
        print __('Removals');
        ?>
' title='<?php 
        print __('View Syslog Removal Rules');
        ?>
' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_removal.php";
        ?>
"'>
						</td>
						<td>
							<input type='button' value='<?php 
        print __('Reports');
        ?>
' title='<?php 
        print __('View Syslog Reports');
        ?>
' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_reports.php";
        ?>
"'>
						</td>
						<?php 
    }
    ?>
						<td>
							<span id='text'></span>
							<input type='hidden' name='action' value='actions'>
							<input type='hidden' name='syslog_pdt_change' value='false'>
						</td>
					</tr>
				</table>
				<table class='filterTable'>
					<tr>
						<td>
							<input type='text' id='filter' size='30' value='<?php 
    print get_request_var('filter');
    ?>
' onChange='applyFilter()'>
						</td>
						<td class='even'>
							<select id='host' multiple style='width: 150px; overflow: scroll;'>
								<?php 
    if ($tab == 'syslog') {
        ?>
<option id='host_all' value='0'<?php 
        if (get_request_var('host') == 'null' || get_request_var('host') == '0' || $reset_multi) {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('Show All Hosts');
        ?>
</option><?php 
    } else {
        ?>
								<option id='host_all' value='0'<?php 
        if (get_request_var('host') == 'null' || get_request_var('host') == 0 || $reset_multi) {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('Show All Logs');
        ?>
</option>
								<option id='host_none' value='-1'<?php 
        if (get_request_var('host') == '-1') {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('Threshold Logs');
        ?>
</option><?php 
    }
    ?>
								<?php 
    $hosts_where = '';
    $hosts_where = api_plugin_hook_function('syslog_hosts_where', $hosts_where);
    $hosts = syslog_db_fetch_assoc("SELECT host_id, SUBSTRING_INDEX(host,'.',1) AS host FROM `" . $syslogdb_default . "`.`syslog_hosts` {$hosts_where} ORDER BY host");
    $selected = explode(' ', get_request_var('host'));
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            print "<option value='" . $host["host_id"] . "'";
            if (sizeof($selected)) {
                if (in_array($host['host_id'], $selected)) {
                    print ' selected';
                }
            }
            print '>';
            print $host['host'] . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							<select id='rows' onChange='applyFilter()' title='<?php 
    print __('Display Rows');
    ?>
'>
								<option value='-1'<?php 
    if (get_request_var('rows') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Default');
    ?>
</option>
								<?php 
    foreach ($item_rows as $rows => $display_text) {
        print "<option value='" . $rows . "'";
        if (get_request_var('rows') == $rows) {
            print ' selected';
        }
        print '>' . __('%d Messages', $display_text) . "</option>\n";
    }
    ?>
							</select>
						</td>
						<td>
							<select id='trimval' onChange='applyFilter()' title='<?php 
    print __('Message Trim');
    ?>
'>
								<?php 
    foreach ($trimvals as $seconds => $display_text) {
        print "<option value='" . $seconds . "'";
        if (get_request_var('trimval') == $seconds) {
            print ' selected';
        }
        print '>' . $display_text . "</option>\n";
    }
    ?>
							</select>
						</td>
						<td>
							<select id='refresh' onChange='applyFilter()'>
								<?php 
    foreach ($page_refresh_interval as $seconds => $display_text) {
        print "<option value='" . $seconds . "'";
        if (get_request_var('refresh') == $seconds) {
            print ' selected';
        }
        print '>' . $display_text . "</option>\n";
    }
    ?>
							</select>
						</td>
					</tr>
				</table>
				<table class='filterTable'>
					<tr>
						<?php 
    api_plugin_hook('syslog_extend_filter');
    ?>
						<td>
							<select id='eprogram' onChange='applyFilter()' title='<?php 
    print __('Programs to filter on');
    ?>
'>
								<option value='-1'<?php 
    if (get_request_var('eprogram') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('All Programs');
    ?>
</option>
								<?php 
    $eprograms = syslog_db_fetch_assoc('SELECT program_id, program
									FROM `' . $syslogdb_default . '`.`syslog_programs` AS fh
									ORDER BY program');
    if (sizeof($eprograms)) {
        foreach ($eprograms as $eprogram) {
            if (trim($eprogram['program']) == '') {
                $eprogram['program'] = 'unspecified';
            }
            print "<option value='" . $eprogram['program_id'] . "'";
            if (get_request_var('eprogram') == $eprogram['program_id']) {
                print ' selected';
            }
            print '>' . $eprogram['program'] . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							<select id='efacility' onChange='applyFilter()' title='<?php 
    print __('Facilities to filter on');
    ?>
'>
								<option value='-1'<?php 
    if (get_request_var('efacility') == '0') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('All Facilities');
    ?>
</option>
								<?php 
    if (!isset($hostfilter)) {
        $hostfilter = '';
    }
    $efacilities = syslog_db_fetch_assoc('SELECT DISTINCT f.facility_id, f.facility
									FROM `' . $syslogdb_default . '`.`syslog_host_facilities` AS fh
									INNER JOIN `' . $syslogdb_default . '`.`syslog_facilities` AS f
									ON f.facility_id=fh.facility_id ' . (strlen($hostfilter) ? 'WHERE ' : '') . $hostfilter . '
									ORDER BY facility');
    if (sizeof($efacilities)) {
        foreach ($efacilities as $efacility) {
            print "<option value='" . $efacility['facility_id'] . "'";
            if (get_request_var('efacility') == $efacility['facility_id']) {
                print ' selected';
            }
            print '>' . ucfirst($efacility['facility']) . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							<select id='epriority' onChange='applyFilter()' title='<?php 
    print __('Priority Levels');
    ?>
'>
								<option value='-1'<?php 
    if (get_request_var('epriority') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('All Priorities');
    ?>
</option>
								<option value='0'<?php 
    if (get_request_var('epriority') == '0') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Emergency');
    ?>
</option>
								<option value='1'<?php 
    if (get_request_var('epriority') == '1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Critical++');
    ?>
</option>
								<option value='1o'<?php 
    if (get_request_var('epriority') == '1o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Critical');
    ?>
</option>
								<option value='2'<?php 
    if (get_request_var('epriority') == '2') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Alert++');
    ?>
</option>
								<option value='2o'<?php 
    if (get_request_var('epriority') == '2o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Alert');
    ?>
</option>
								<option value='3'<?php 
    if (get_request_var('epriority') == '3') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Error++');
    ?>
</option>
								<option value='3o'<?php 
    if (get_request_var('epriority') == '3o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Error');
    ?>
</option>
								<option value='4'<?php 
    if (get_request_var('epriority') == '4') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Warning++');
    ?>
</option>
								<option value='4o'<?php 
    if (get_request_var('epriority') == '4o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Warning');
    ?>
</option>
								<option value='5'<?php 
    if (get_request_var('epriority') == '5') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Notice++');
    ?>
</option>
								<option value='5o'<?php 
    if (get_request_var('epriority') == '5o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Notice');
    ?>
</option>
								<option value='6'<?php 
    if (get_request_var('epriority') == '6') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Info++');
    ?>
</option>
								<option value='6o'<?php 
    if (get_request_var('epriority') == '6o') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Info');
    ?>
</option>
								<option value='7'<?php 
    if (get_request_var('epriority') == '7') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Debug');
    ?>
</option>
							</select>
						</td>
						<?php 
    if (get_nfilter_request_var('tab') == 'syslog') {
        ?>
						<td>
							<select id='removal' onChange='applyFilter()' title='<?php 
        print __('Removal Handling');
        ?>
'>
								<option value='1'<?php 
        if (get_request_var('removal') == '1') {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('All Records');
        ?>
</option>
								<option value='-1'<?php 
        if (get_request_var('removal') == '-1') {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('Main Records');
        ?>
</option>
								<option value='2'<?php 
        if (get_request_var('removal') == '2') {
            ?>
 selected<?php 
        }
        ?>
><?php 
        print __('Removed Records');
        ?>
</option>
							</select>
						</td>
						<?php 
    } else {
        ?>
						<input type='hidden' id='removal' value='<?php 
        print get_request_var('removal');
        ?>
'>
						<?php 
    }
    ?>
					</tr>
				</table>
			</form>
			</td>
		</tr>
	<?php 
    html_end_box(false);
}
示例#9
0
function template_save_edit()
{
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('thold_type');
    get_filter_request_var('thold_hi');
    get_filter_request_var('thold_low');
    get_filter_request_var('thold_fail_trigger');
    get_filter_request_var('time_hi');
    get_filter_request_var('time_low');
    get_filter_request_var('time_fail_trigger');
    get_filter_request_var('time_fail_length');
    get_filter_request_var('thold_warning_type');
    get_filter_request_var('thold_warning_hi');
    get_filter_request_var('thold_warning_low');
    get_filter_request_var('thold_warning_fail_trigger');
    get_filter_request_var('time_warning_hi');
    get_filter_request_var('time_warning_low');
    get_filter_request_var('time_warning_fail_trigger');
    get_filter_request_var('time_warning_fail_length');
    get_filter_request_var('bl_ref_time_range');
    get_filter_request_var('bl_pct_down');
    get_filter_request_var('bl_pct_up');
    get_filter_request_var('bl_fail_trigger');
    get_filter_request_var('repeat_alert');
    get_filter_request_var('data_type');
    get_filter_request_var('cdef');
    get_filter_request_var('notify_warning');
    get_filter_request_var('notify_alert');
    get_filter_request_var('snmp_event_severity');
    get_filter_request_var('snmp_event_warning_severity');
    /* ==================================================== */
    /* clean up date1 string */
    if (isset_request_var('name')) {
        set_request_var('name', trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('name'))));
    }
    if (isset_request_var('snmp_trap_category')) {
        set_request_var('snmp_event_category', db_qstr(trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('snmp_event_category')))));
    }
    /* save: data_template */
    $save['id'] = get_nfilter_request_var('id');
    $save['hash'] = get_hash_thold_template($save['id']);
    $save['name'] = get_nfilter_request_var('name');
    $save['thold_type'] = get_nfilter_request_var('thold_type');
    // High / Low
    $save['thold_hi'] = get_nfilter_request_var('thold_hi');
    $save['thold_low'] = get_nfilter_request_var('thold_low');
    $save['thold_fail_trigger'] = get_nfilter_request_var('thold_fail_trigger');
    // Time Based
    $save['time_hi'] = get_nfilter_request_var('time_hi');
    $save['time_low'] = get_nfilter_request_var('time_low');
    $save['time_fail_trigger'] = get_nfilter_request_var('time_fail_trigger');
    $save['time_fail_length'] = get_nfilter_request_var('time_fail_length');
    if (isset_request_var('thold_fail_trigger') && get_nfilter_request_var('thold_fail_trigger') != '') {
        $save['thold_fail_trigger'] = get_nfilter_request_var('thold_fail_trigger');
    } else {
        $alert_trigger = read_config_option('alert_trigger');
        if ($alert_trigger != '' && is_numeric($alert_trigger)) {
            $save['thold_fail_trigger'] = $alert_trigger;
        } else {
            $save['thold_fail_trigger'] = 5;
        }
    }
    /***  Warnings  ***/
    // High / Low Warnings
    $save['thold_warning_hi'] = get_nfilter_request_var('thold_warning_hi');
    $save['thold_warning_low'] = get_nfilter_request_var('thold_warning_low');
    $save['thold_warning_fail_trigger'] = get_nfilter_request_var('thold_warning_fail_trigger');
    // Time Based Warnings
    $save['time_warning_hi'] = get_nfilter_request_var('time_warning_hi');
    $save['time_warning_low'] = get_nfilter_request_var('time_warning_low');
    $save['time_warning_fail_trigger'] = get_nfilter_request_var('time_warning_fail_trigger');
    $save['time_warning_fail_length'] = get_nfilter_request_var('time_warning_fail_length');
    if (isset_request_var('thold_warning_fail_trigger') && get_nfilter_request_var('thold_warning_fail_trigger') != '') {
        $save['thold_warning_fail_trigger'] = get_nfilter_request_var('thold_warning_fail_trigger');
    } else {
        $alert_trigger = read_config_option('alert_trigger');
        if ($alert_trigger != '' && is_numeric($alert_trigger)) {
            $save['thold_warning_fail_trigger'] = $alert_trigger;
        } else {
            $save['thold_warning_fail_trigger'] = 5;
        }
    }
    $save['thold_enabled'] = isset_request_var('thold_enabled') ? 'on' : 'off';
    $save['exempt'] = isset_request_var('exempt') ? 'on' : '';
    $save['restored_alert'] = isset_request_var('restored_alert') ? 'on' : '';
    if (isset_request_var('bl_ref_time_range') && get_nfilter_request_var('bl_ref_time_range') != '') {
        $save['bl_ref_time_range'] = get_nfilter_request_var('bl_ref_time_range');
    } else {
        $alert_bl_timerange_def = read_config_option('alert_bl_timerange_def');
        if ($alert_bl_timerange_def != '' && is_numeric($alert_bl_timerange_def)) {
            $save['bl_ref_time_range'] = $alert_bl_timerange_def;
        } else {
            $save['bl_ref_time_range'] = 10800;
        }
    }
    $save['bl_pct_down'] = get_nfilter_request_var('bl_pct_down');
    $save['bl_pct_up'] = get_nfilter_request_var('bl_pct_up');
    if (isset_request_var('bl_fail_trigger') && get_nfilter_request_var('bl_fail_trigger') != '') {
        $save['bl_fail_trigger'] = get_nfilter_request_var('bl_fail_trigger');
    } else {
        $alert_bl_trigger = read_config_option('alert_bl_trigger');
        if ($alert_bl_trigger != '' && is_numeric($alert_bl_trigger)) {
            $save['bl_fail_trigger'] = $alert_bl_trigger;
        } else {
            $save['bl_fail_trigger'] = 3;
        }
    }
    if (isset_request_var('repeat_alert') && get_nfilter_request_var('repeat_alert') != '') {
        $save['repeat_alert'] = get_nfilter_request_var('repeat_alert');
    } else {
        $alert_repeat = read_config_option('alert_repeat');
        if ($alert_repeat != '' && is_numeric($alert_repeat)) {
            $save['repeat_alert'] = $alert_repeat;
        } else {
            $save['repeat_alert'] = 12;
        }
    }
    if (isset_request_var('snmp_event_category')) {
        $save['snmp_event_category'] = get_nfilter_request_var('snmp_event_category');
        $save['snmp_event_severity'] = get_nfilter_request_var('snmp_event_severity');
    }
    if (isset_request_var('snmp_event_warning_severity')) {
        if (get_nfilter_request_var('snmp_event_warning_severity') > get_nfilter_request_var('snmp_event_severity')) {
            $save['snmp_event_warning_severity'] = get_nfilter_request_var('snmp_event_severity');
        } else {
            $save['snmp_event_warning_severity'] = get_nfilter_request_var('snmp_event_warning_severity');
        }
    }
    $save['notify_extra'] = get_nfilter_request_var('notify_extra');
    $save['notify_warning_extra'] = get_nfilter_request_var('notify_warning_extra');
    $save['notify_warning'] = get_nfilter_request_var('notify_warning');
    $save['notify_alert'] = get_nfilter_request_var('notify_alert');
    $save['cdef'] = get_nfilter_request_var('cdef');
    $save['data_type'] = get_nfilter_request_var('data_type');
    $save['percent_ds'] = get_nfilter_request_var('percent_ds');
    $save['expression'] = get_nfilter_request_var('expression');
    if (!is_error_message()) {
        $id = sql_save($save, 'thold_template');
        if ($id) {
            raise_message(1);
            if (isset_request_var('notify_accounts') && is_array(get_nfilter_request_var('notify_accounts'))) {
                thold_save_template_contacts($id, get_nfilter_request_var('notify_accounts'));
            } elseif (!isset_request_var('notify_accounts')) {
                thold_save_template_contacts($id, array());
            }
            thold_template_update_thresholds($id);
            plugin_thold_log_changes($id, 'modified_template', $save);
        } else {
            raise_message(2);
        }
    }
    if (is_error_message() || isempty_request_var('id')) {
        header('Location: thold_templates.php?header=false&action=edit&id=' . (empty($id) ? get_request_var('id') : $id));
    } else {
        header('Location: thold_templates.php?header=false');
    }
}
示例#10
0
function thold_graph_button($data)
{
    global $config;
    $local_graph_id = $data[1]['local_graph_id'];
    $rra_id = $data[1]['rra'];
    if (isset_request_var('view_type') && !isempty_request_var('view_type')) {
        $view_type = get_request_var('view_type');
    } else {
        set_request_var('view_type', '');
        $view_type = read_config_option('dataquery_type');
    }
    if (isset_request_var('graph_start') && !isempty_request_var('graph_start')) {
        $start = get_request_var('graph_start');
    } else {
        set_request_var('graph_start', '');
        $start = time() - 3600;
    }
    if (isset_request_var('graph_end') && !isempty_request_var('graph_end')) {
        $end = get_request_var('graph_end');
    } else {
        set_request_var('graph_end', '');
        $end = time();
    }
    if (!isset($_SESSION['sess_config_array']['thold_draw_vrules'])) {
        $_SESSION['sess_config_array']['thold_draw_vrules'] = 'off';
    }
    $url = $_SERVER['REQUEST_URI'];
    $url = str_replace('&thold_vrule=on', '', $url);
    $url = str_replace('&thold_vrule=off', '', $url);
    if (!substr_count($url, '?')) {
        $separator = '?';
    } else {
        $separator = '&';
    }
    if (api_user_realm_auth('thold_graph.php')) {
        print '<a class="hyperLink" href="' . $url . $separator . 'thold_vrule=' . ($_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? 'off' : 'on') . '"><img src="' . $config['url_path'] . 'plugins/thold/images/reddot.png" border="0" alt="" title="' . __('Toggle Threshold VRULES %s', $_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? __('Off') : __('On')) . '" style="padding: 3px;"></a><br>';
    }
    // Add Threshold Creation button
    if (api_user_realm_auth('thold.php')) {
        if (isset_request_var('tree_id')) {
            get_filter_request_var('tree_id');
        }
        if (isset_request_var('leaf_id')) {
            get_filter_request_var('leaf_id');
        }
        print '<a class="hyperLink" href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?action=add' . '&usetemplate=1&local_graph_id=' . $local_graph_id) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Create Threshold') . '" style="padding: 3px;"></a><br>';
    }
}
示例#11
0
function save_thold()
{
    global $banner;
    $host_id = get_filter_request_var('host_id');
    $local_data_id = get_filter_request_var('local_data_id');
    $local_graph_id = get_filter_request_var('local_graph_id');
    $data_template_rrd_id = get_filter_request_var('data_template_rrd_id');
    $template_enabled = isset_request_var('template_enabled') && get_nfilter_request_var('template_enabled') == 'on' ? 'on' : '';
    if ($template_enabled == 'on') {
        if (!thold_user_auth_threshold($local_data_id)) {
            $banner = "<span class='textError'>" . __('Permission Denied') . "</span>";
            $_SESSION['thold_message'] = $banner;
            raise_message('thold_message');
            return;
        }
        $data = db_fetch_row_prepared('SELECT id, thold_template_id 
			FROM thold_data 
			WHERE local_data_id = ?
			AND data_template_rrd_id = ?', array($local_data_id, $data_template_rrd_id));
        thold_template_update_threshold($data['id'], $data['thold_template_id']);
        $banner = "<span class='textInfo'>" . __('Record Updated') . "</span>";
        plugin_thold_log_changes($data['id'], 'modified', array('id' => $data['id'], 'template_enabled' => 'on'));
        $_SESSION['thold_message'] = $banner;
        raise_message('thold_message');
        return get_filter_request_var('id');
    }
    if (isset_request_var('id')) {
        /* Do Some error Checks */
        $banner = "<span class='textError'>";
        if (get_filter_request_var('thold_type') == 0 && get_filter_request_var('thold_hi', FILTER_VALIDATE_FLOAT) == '' && get_filter_request_var('thold_low', FILTER_VALIDATE_FLOAT) == '' && get_filter_request_var('thold_fail_trigger') != 0) {
            $banner .= __('You must specify either &quot;High Alert Threshold&quot; or &quot;Low Alert Threshold&quot; or both!<br>RECORD NOT UPDATED!</span>');
            $_SESSION['thold_message'] = $banner;
            raise_message('thold_message');
            return get_filter_request_var('id');
        }
        if (get_filter_request_var('thold_type') == 0 && get_filter_request_var('thold_warning_hi', FILTER_VALIDATE_FLOAT) == '' && get_filter_request_var('thold_warning_low', FILTER_VALIDATE_FLOAT) == '' && get_filter_request_var('thold_warning_fail_trigger') != 0) {
            $banner .= __('You must specify either &quot;High Warning Threshold&quot; or &quot;Low Warning Threshold&quot; or both!<br>RECORD NOT UPDATED!</span>');
            $_SESSION['thold_message'] = $banner;
            raise_message('thold_message');
            return get_filter_request_var('id');
        }
        if (get_filter_request_var('thold_type') == 0 && get_filter_request_var('thold_hi', FILTER_VALIDATE_FLOAT) != '' && get_filter_request_var('thold_low', FILTER_VALIDATE_FLOAT) != '' && round(get_filter_request_var('thold_low'), 4) >= round(get_filter_request_var('thold_hi'), 4)) {
            $banner .= __('Impossible thresholds: &quot;High Threshold&quot; smaller than or equal to &quot;Low Threshold&quot;<br>RECORD NOT UPDATED!</span>');
            $_SESSION['thold_message'] = $banner;
            raise_message('thold_message');
            return get_filter_request_var('id');
        }
        if (get_filter_request_var('thold_type') == 0 && get_filter_request_var('thold_warning_hi', FILTER_VALIDATE_FLOAT) != '' && get_filter_request_var('thold_warning_low', FILTER_VALIDATE_FLOAT) != '' && round(get_filter_request_var('thold_warning_low'), 4) >= round(get_filter_request_var('thold_warning_hi'), 4)) {
            $banner .= __('Impossible thresholds: &quot;High Warning Threshold&quot; smaller than or equal to &quot;Low Warning Threshold&quot;<br>RECORD NOT UPDATED!</span>');
            $_SESSION['thold_message'] = $banner;
            raise_message('thold_message');
            return get_filter_request_var('id');
        }
        if (get_filter_request_var('thold_type') == 1) {
            $banner .= __('With baseline thresholds enabled.');
            if (!thold_mandatory_field_ok('bl_ref_time_range', 'Time reference in the past')) {
                $banner .= '</span>';
                $_SESSION['thold_message'] = $banner;
                raise_message('thold_message');
                return get_filter_request_var('id');
            }
            if (isempty_request_var('bl_pct_down') && isempty_request_var('bl_pct_up')) {
                $banner .= __('You must specify either &quot;Baseline Deviation UP&quot; or &quot;Baseline Deviation DOWN&quot; or both!<br>RECORD NOT UPDATED!</span>');
                $_SESSION['thold_message'] = $banner;
                raise_message('thold_message');
                return get_filter_request_var('id');
            }
        }
    }
    $save = array();
    if (isset_request_var('id')) {
        $save['id'] = get_filter_request_var('id');
    } else {
        $save['id'] = '0';
        $save['thold_template_id'] = '';
    }
    get_filter_request_var('thold_hi', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('thold_low', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('thold_fail_trigger');
    get_filter_request_var('thold_warning_hi', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('thold_warning_low', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('thold_warning_fail_trigger');
    get_filter_request_var('repeat_alert');
    get_filter_request_var('cdef');
    get_filter_request_var('local_data_id');
    get_filter_request_var('data_template_rrd_id');
    get_filter_request_var('thold_type');
    get_filter_request_var('time_hi', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('time_low', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('time_fail_trigger');
    get_filter_request_var('time_fail_length');
    get_filter_request_var('time_warning_hi', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('time_warning_low', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('time_warning_fail_trigger');
    get_filter_request_var('time_warning_fail_length');
    get_filter_request_var('data_type');
    get_filter_request_var('notify_warning');
    get_filter_request_var('notify_alert');
    get_filter_request_var('bl_ref_time_range');
    get_filter_request_var('bl_pct_down', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('bl_pct_up', FILTER_VALIDATE_FLOAT);
    get_filter_request_var('bl_fail_trigger');
    if (isset_request_var('snmp_event_category')) {
        set_request_var('snmp_event_category', trim(str_replace(array("\\", "'", '"'), '', get_nfilter_request_var('snmp_event_category'))));
    }
    if (isset_request_var('snmp_event_severity')) {
        get_filter_request_var('snmp_event_severity');
    }
    if (isset_request_var('snmp_event_warning_severity')) {
        get_filter_request_var('snmp_event_warning_severity');
    }
    if (!isempty_request_var('name')) {
        $name = str_replace(array("\\", '"', "'"), '', get_nfilter_request_var('name'));
    } elseif (isset_request_var('data_template_rrd_id')) {
        $data_source_name = db_fetch_cell_prepared('SELECT data_source_name FROM data_template_rrd WHERE id = ?', array(get_request_var('data_template_rrd_id')));
        $data_template = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE id = ?', array(get_request_var('data_template_id')));
        $local_data_id = get_request_var('local_data_id');
        $local_graph_id = get_request_var('local_graph_id');
        $name = thold_format_name($data_template, $local_graph_id, $local_data_id, $data_source_name);
    }
    $save['name'] = trim_round_request_var('name');
    $save['host_id'] = $host_id;
    $save['data_template_rrd_id'] = get_request_var('data_template_rrd_id');
    $save['local_data_id'] = get_request_var('local_data_id');
    $save['thold_enabled'] = isset_request_var('thold_enabled') ? 'on' : 'off';
    $save['exempt'] = isset_request_var('exempt') ? 'on' : '';
    $save['restored_alert'] = isset_request_var('restored_alert') ? 'on' : '';
    $save['thold_type'] = get_request_var('thold_type');
    $save['template_enabled'] = isset_request_var('template_enabled') ? 'on' : '';
    // High / Low
    $save['thold_hi'] = trim_round_request_var('thold_hi', 4);
    $save['thold_low'] = trim_round_request_var('thold_low', 4);
    $save['thold_fail_trigger'] = isempty_request_var('thold_fail_trigger') ? read_config_option('alert_trigger') : get_nfilter_request_var('thold_fail_trigger');
    // Time Based
    $save['time_hi'] = trim_round_request_var('time_hi', 4);
    $save['time_low'] = trim_round_request_var('time_low', 4);
    $save['time_fail_trigger'] = isempty_request_var('time_fail_trigger') ? read_config_option('thold_warning_time_fail_trigger') : get_nfilter_request_var('time_fail_trigger');
    $save['time_fail_length'] = isempty_request_var('time_fail_length') ? read_config_option('thold_warning_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1 : get_nfilter_request_var('time_fail_length');
    // Warning High / Low
    $save['thold_warning_hi'] = trim_round_request_var('thold_warning_hi', 4);
    $save['thold_warning_low'] = trim_round_request_var('thold_warning_low', 4);
    $save['thold_warning_fail_trigger'] = isempty_request_var('thold_warning_fail_trigger') ? read_config_option('alert_trigger') : get_nfilter_request_var('thold_warning_fail_trigger');
    // Warning Time Based
    $save['time_warning_hi'] = trim_round_request_var('time_warning_hi', 4);
    $save['time_warning_low'] = trim_round_request_var('time_warning_low', 4);
    $save['time_warning_fail_trigger'] = isempty_request_var('time_warning_fail_trigger') ? read_config_option('thold_warning_time_fail_trigger') : get_nfilter_request_var('time_warning_fail_trigger');
    $save['time_warning_fail_length'] = isempty_request_var('time_warning_fail_length') ? read_config_option('thold_warning_time_fail_length') > 0 ? read_config_option('thold_warning_time_fail_length') : 1 : get_nfilter_request_var('time_warning_fail_length');
    // Baseline
    $save['bl_thold_valid'] = '0';
    $save['bl_ref_time_range'] = isempty_request_var('bl_ref_time_range') ? read_config_option('alert_bl_timerange_def') : get_nfilter_request_var('bl_ref_time_range');
    $save['bl_pct_down'] = trim_round_request_var('bl_pct_down');
    $save['bl_pct_up'] = trim_round_request_var('bl_pct_up');
    $save['bl_fail_trigger'] = isempty_request_var('bl_fail_trigger') ? read_config_option("alert_bl_trigger") : get_nfilter_request_var('bl_fail_trigger');
    $save['repeat_alert'] = trim_round_request_var('repeat_alert');
    // Notification
    $save['notify_extra'] = trim_round_request_var('notify_extra');
    $save['notify_warning_extra'] = trim_round_request_var('notify_warning_extra');
    $save['notify_warning'] = trim_round_request_var('notify_warning');
    $save['notify_alert'] = trim_round_request_var('notify_alert');
    // Data Manipulation
    $save['data_type'] = get_nfilter_request_var('data_type');
    if (isset_request_var('percent_ds')) {
        $save['percent_ds'] = get_nfilter_request_var('percent_ds');
    } else {
        $save['percent_ds'] = '';
    }
    $save['cdef'] = trim_round_request_var('cdef');
    if (isset_request_var('expression')) {
        $save['expression'] = get_nfilter_request_var('expression');
    } else {
        $save['expression'] = '';
    }
    // SNMP Information
    $save['snmp_event_category'] = trim_round_request_var('snmp_event_category');
    $save['snmp_event_severity'] = isset_request_var('snmp_event_severity') ? get_nfilter_request_var('snmp_event_severity') : 4;
    $save['snmp_event_warning_severity'] = isset_request_var('snmp_event_warning_severity') ? get_nfilter_request_var('snmp_event_warning_severity') : 3;
    /* Get the Data Template, Graph Template, and Graph */
    $rrdsql = db_fetch_row('SELECT id, data_template_id 
		FROM data_template_rrd 
		WHERE local_data_id=' . $save['local_data_id'] . ' 
		ORDER BY id');
    $rrdlookup = $rrdsql['id'];
    $grapharr = db_fetch_row("SELECT local_graph_id, graph_template_id \n\t\tFROM graph_templates_item \n\t\tWHERE task_item_id={$rrdlookup} \n\t\tAND local_graph_id <> '' \n\t\tLIMIT 1");
    $save['local_graph_id'] = $grapharr['local_graph_id'];
    $save['graph_template_id'] = $grapharr['graph_template_id'];
    $save['data_template_id'] = $rrdsql['data_template_id'];
    if (!thold_user_auth_threshold($save['local_data_id'])) {
        $banner = "<span class='textError'>Permission Denied</span>";
        $_SESSION['thold_message'] = $banner;
        raise_message('thold_message');
        return '';
    }
    $id = sql_save($save, 'thold_data');
    if (isset_request_var('notify_accounts') && is_array(get_nfilter_request_var('notify_accounts'))) {
        thold_save_threshold_contacts($id, get_nfilter_request_var('notify_accounts'));
    } elseif (!isset_request_var('notify_accounts')) {
        thold_save_threshold_contacts($id, array());
    }
    if ($id) {
        plugin_thold_log_changes($id, 'modified', $save);
        $thold = db_fetch_row_prepared('SELECT * FROM thold_data WHERE id= ?', array($id));
        if ($thold['thold_type'] == 1) {
            thold_check_threshold($thold);
        }
        set_request_var('id', $id);
    } else {
        set_request_var('id', '0');
    }
    $banner = "<span class='textInfo'>" . __('Record Updated') . "</span>";
    $_SESSION['thold_message'] = $banner;
    raise_message('thold_message');
    return $id;
}
示例#12
0
 if (isset_request_var('device_name')) {
     $device = get_nfilter_request_var('device_name');
 } else {
     $device = db_fetch_cell("SELECT folder FROM plugin_flowview_devices ORDER BY id LIMIT 1");
     $_POST['device_name'] = $device;
 }
 $timespan = 0;
 if (isset_request_var('predefined_timespan') && get_filter_request_var('predefined_timespan') > 0) {
     $timespan = get_request_var('predefined_timespan');
     set_request_var('predefined_timespan', $timespan);
     $span = array();
     get_timespan($span, time(), $timespan, read_user_setting('first_weekdayid'));
     $_POST['date1'] = $date1 = $span['current_value_date1'];
     $_POST['date2'] = $date2 = $span['current_value_date2'];
 } else {
     set_request_var('predefined_timespan', '0');
     $timespan = 0;
     $date1 = date('Y-m-d H:i:s', time() - 8 * 3600);
     if (isset_request_var('date1')) {
         $date1 = get_nfilter_request_var('date1');
     }
     $date2 = date('Y-m-d H:i:s');
     if (isset_request_var('date2')) {
         $date2 = get_nfilter_request_var('date2');
     }
 }
 $tos_fields = '';
 if (isset_request_var('tos_fields')) {
     $tos_fields = get_nfilter_request_var('tos_fields');
 }
 $tcp_flags = '';