function tholds() { global $config, $device_actions, $item_rows, $thold_classes, $thold_states; /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'name', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string')), 'data_template_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1')); validate_store_request_vars($filters, 'sess_thold'); /* ================= input validation ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } html_start_box(__('Threshold Status'), '100%', '', '3', 'center', ''); form_thold_filter(); html_end_box(); /* build the SQL query and WHERE clause */ if (get_request_var('sort_column') == 'lastread') { $sort = get_request_var('sort_column') . "/1"; } else { $sort = get_request_var('sort_column'); } $limit = ' LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows; $sql_where = ''; /* status filter */ if (get_request_var('status') == '-1') { /* return all rows */ } else { if (get_request_var('status') == '0') { $sql_where = "(td.thold_enabled='off'"; } /*disabled*/ if (get_request_var('status') == '2') { $sql_where = "(td.thold_enabled='on'"; } /* enabled */ if (get_request_var('status') == '1') { $sql_where = "((td.thold_alert!=0 OR td.bl_alert>0)"; } /* breached */ if (get_request_var('status') == '3') { $sql_where = "(((td.thold_alert!=0 AND td.thold_fail_count >= td.thold_fail_trigger) OR (td.bl_alert>0 AND td.bl_fail_count >= td.bl_fail_trigger))"; } /* status */ } if (strlen(get_request_var('filter'))) { $sql_where .= (strlen($sql_where) ? ' AND' : '(') . " td.name LIKE '%" . get_request_var('filter') . "%'"; } /* data template id filter */ if (get_request_var('data_template_id') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : '(') . ' td.data_template_id=' . get_request_var('data_template_id'); } /* host id filter */ if (get_request_var('host_id') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : '(') . ' td.host_id=' . get_request_var('host_id'); } if ($sql_where != '') { $sql_where .= ')'; } $tholds = get_allowed_thresholds($sql_where, $sort . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ", {$rows}", $total_rows); $nav = html_nav_bar('thold_graph.php?action=thold', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 13, 'Thresholds', 'page', 'main'); print $nav; html_start_box('', '100%', '', '4', 'center', ''); $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => '', 'align' => 'left'), 'name' => array('display' => __('Name'), 'sort' => 'ASC', 'align' => 'left'), 'id' => array('display' => __('ID'), 'sort' => 'ASC', 'align' => 'right'), 'thold_type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), 'lastread' => array('display' => __('Current'), 'sort' => 'ASC', 'align' => 'right'), 'nosort4' => array('display' => __('Warn Hi/Lo'), 'sort' => 'ASC', 'align' => 'right'), 'nosort5' => array('display' => __('Alert Hi/Lo'), 'sort' => 'ASC', 'align' => 'right'), 'nosort6' => array('display' => __('BL Hi/Lo'), 'sort' => 'ASC', 'align' => 'right'), 'nosort2' => array('display' => __('Trigger'), 'sort' => 'ASC', 'align' => 'right'), 'nosort3' => array('display' => __('Duration'), 'sort' => 'ASC', 'align' => 'right'), 'repeat_alert' => array('display' => __('Repeat'), 'sort' => 'ASC', 'align' => 'right'), 'thold_alert' => array('display' => __('Triggered'), 'sort' => 'ASC', 'align' => 'right')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'thold_graph.php?action=thold'); $step = read_config_option('poller_interval'); include $config['base_path'] . '/plugins/thold/includes/arrays.php'; $c = 0; $i = 0; if (sizeof($tholds)) { foreach ($tholds as $row) { $c++; $alertstat = 'No'; $bgcolor = 'green'; if ($row['thold_type'] == 0) { if ($row['thold_alert'] != 0) { $alertstat = __('Yes'); if ($row['thold_fail_count'] >= $row['thold_fail_trigger']) { $bgcolor = 'red'; } elseif ($row['thold_warning_fail_count'] >= $row['thold_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } elseif ($row['thold_type'] == 2) { if ($row['thold_alert'] != 0) { $alertstat = 'Yes'; if ($row['thold_fail_count'] >= $row['time_fail_trigger']) { $bgcolor = 'red'; } elseif ($row['thold_warning_fail_count'] >= $row['time_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } else { if ($row['bl_alert'] == 1) { $alertstat = __('Baseline-LOW'); $bgcolor = $row['bl_fail_count'] >= $row['bl_fail_trigger'] ? 'orange' : 'yellow'; } elseif ($row['bl_alert'] == 2) { $alertstat = __('Baseline-HIGH'); $bgcolor = $row['bl_fail_count'] >= $row['bl_fail_trigger'] ? 'orange' : 'yellow'; } } if ($row['thold_enabled'] == 'off') { print "<tr class='selectable " . $thold_states['grey']['class'] . "' id='line" . $row['id'] . "'>\n"; } else { print "<tr class='selectable " . $thold_states[$bgcolor]['class'] . "' id='line" . $row['id'] . "'>\n"; } print "<td width='1%' style='white-space:nowrap;'>"; if (api_user_realm_auth('thold.php')) { print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?action=edit&id=' . $row['id']) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Edit Threshold') . '"></a>'; } if ($row['thold_enabled'] == 'on') { print '<a class="hyperLink" href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold_graph.php?action=disable&id=' . $row['id']) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/disable_thold.png" border="0" alt="" title="' . __('Disable Threshold') . '"></a>'; } else { print '<a class="hyperLink" href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold_graph.php?action=enable&id=' . $row['id']) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/enable_thold.png" border="0" alt="" title="' . __('Enable Threshold') . '"></a>'; } print "<a href='" . htmlspecialchars($config['url_path'] . 'graph.php?local_graph_id=' . $row['local_graph_id'] . '&rra_id=all') . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='" . __('View Graph') . "'></a>"; print "<a class='hyperLink' href='" . htmlspecialchars($config['url_path'] . 'plugins/thold/thold_graph.php?action=log&threshold_id=' . $row['id'] . '&status=-1') . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_log.gif' border='0' alt='' title='" . __('View Threshold History') . "'></a>"; print '</td>'; print "<td class='left nowrap'>" . ($row['name'] != '' ? $row['name'] : 'No name set') . '</td>'; print "<td class='right'>" . $row['id'] . '</td>'; print "<td class='left nowrap'>" . $thold_types[$row['thold_type']] . '</td>'; print "<td class='right'>" . thold_format_number($row['lastread']) . '</td>'; print "<td class='right nowrap'>" . ($row['thold_type'] == 1 ? __('N/A') : ($row['thold_type'] == 2 ? thold_format_number($row['time_warning_hi']) . '/' . thold_format_number($row['time_warning_low']) : thold_format_number($row['thold_warning_hi']) . '/' . thold_format_number($row['thold_warning_low']))) . '</td>'; print "<td class='right'>" . ($row['thold_type'] == 1 ? __('N/A') : ($row['thold_type'] == 2 ? thold_format_number($row['time_hi']) . '/' . thold_format_number($row['time_low']) : thold_format_number($row['thold_hi']) . '/' . thold_format_number($row['thold_low']))) . '</td>'; print "<td class='right'>" . ($row['thold_type'] == 1 ? $row['bl_pct_up'] . (strlen($row['bl_pct_up']) ? '%' : '-') . '/' . $row['bl_pct_down'] . (strlen($row['bl_pct_down']) ? '%' : '-') : __('N/A')) . '</td>'; switch ($row['thold_type']) { case 0: print "<td class='right nowrap'><i>" . plugin_thold_duration_convert($row['local_data_id'], $row['thold_fail_trigger'], 'alert') . '</i></td>'; print "<td class='right'>" . __('N/A') . "</td>"; break; case 1: print "<td class='right nowrap'><i>" . plugin_thold_duration_convert($row['local_data_id'], $row['bl_fail_trigger'], 'alert') . '</i></td>'; print "<td class='right nowrap'>" . $timearray[$row['bl_ref_time_range'] / 300] . '</td>'; break; case 2: print "<td class='right nowrap'><i>" . $row['time_fail_trigger'] . ' Triggers</i></td>'; print "<td class='right nowrap'>" . plugin_thold_duration_convert($row['local_data_id'], $row['time_fail_length'], 'time') . '</td>'; break; default: print "<td class='right'>" . __('N/A') . "</td>"; print "<td class='right'>" . __('N/A') . "</td>"; } print "<td class='right nowrap'>" . ($row['repeat_alert'] == '' ? '' : plugin_thold_duration_convert($row['local_data_id'], $row['repeat_alert'], 'repeat')) . '</td>'; print "<td class='right'>" . $alertstat . '</td>'; form_end_row(); } } else { print '<tr class="even"><td class="center" colspan="13">' . __('No Thresholds') . '</td></tr>'; } html_end_box(false); if (sizeof($tholds)) { print $nav; } thold_legend(); //thold_display_rusage(); }
function tholds() { global $config, $colors, $thold_bgcolors, $device_actions, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("data_template_id")); input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("triggered")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear"])) { kill_session_var("sess_thold_current_page"); kill_session_var("sess_thold_filter"); kill_session_var("sess_thold_data_template_id"); kill_session_var("sess_thold_host_id"); kill_session_var("sess_thold_rows"); kill_session_var("sess_thold_triggered"); kill_session_var("sess_thold_sort_column"); kill_session_var("sess_thold_sort_direction"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["data_template_id"]); unset($_REQUEST["host_id"]); unset($_REQUEST["rows"]); unset($_REQUEST["triggered"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } else { /* if any of the settings changed, reset the page number */ $changed = 0; $changed += thold_request_check_changed('filter', 'sess_thold_filter'); $changed += thold_request_check_changed('data_template_id', 'sess_thold_data_template_id'); $changed += thold_request_check_changed('host_id', 'sess_thold_host_id'); $changed += thold_request_check_changed('rows', 'sess_thold_rows'); $changed += thold_request_check_changed('triggered', 'sess_thold_triggered'); $changed += thold_request_check_changed('sort_column', 'sess_thold_sort_column'); $changed += thold_request_check_changed('sort_direction', 'sess_thold_sort_direction'); if ($changed) { $_REQUEST['page'] = '1'; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_thold_current_page", "1"); load_current_session_value("filter", "sess_thold_filter", ""); load_current_session_value("triggered", "sess_thold_triggered", read_config_option("thold_filter_default")); load_current_session_value("data_template_id", "sess_thold_data_template_id", "-1"); load_current_session_value("host_id", "sess_thold_host_id", "-1"); load_current_session_value("rows", "sess_thold_rows", read_config_option("alert_num_rows")); load_current_session_value("sort_column", "sess_thold_sort_column", "thold_alert"); load_current_session_value("sort_direction", "sess_thold_sort_direction", "DESC"); /* if the number of rows is -1, set it to the default */ if ($_REQUEST["rows"] == -1 || !isset($_REQUEST["rows"])) { $_REQUEST["rows"] = read_config_option("alert_num_rows"); if ($_REQUEST["rows"] < 2) { $_REQUEST["rows"] = 30; } } ?> <script type="text/javascript"> <!-- function applyTHoldFilterChange(objForm) { strURL = '?tab=thold&triggered=' + objForm.triggered.value; strURL = strURL + '&data_template_id=' + objForm.data_template_id.value; strURL = strURL + '&host_id=' + objForm.host_id.value; strURL = strURL + '&rows=' + objForm.rows.value; strURL = strURL + '&filter=' + objForm.filter.value; document.location = strURL; } --> </script> <?php html_start_box("<strong>Threshold Status</strong>", "100%", $colors["header"], "3", "center", ""); form_thold_filter(); html_end_box(); /* build the SQL query and WHERE clause */ if ($_REQUEST['sort_column'] == 'lastread') { $sort = $_REQUEST['sort_column'] . "/1"; } else { $sort = $_REQUEST['sort_column']; } $limit = ' LIMIT ' . $_REQUEST["rows"] * ($_REQUEST['page'] - 1) . "," . $_REQUEST["rows"]; $sql_where = ''; /* triggered filter */ if ($_REQUEST['triggered'] == '-1') { /* return all rows */ } else { if ($_REQUEST['triggered'] == '0') { $sql_where = "WHERE thold_data.thold_enabled='off'"; } /*disabled*/ if ($_REQUEST['triggered'] == '2') { $sql_where = "WHERE thold_data.thold_enabled='on'"; } /* enabled */ if ($_REQUEST['triggered'] == '1') { $sql_where = "WHERE (thold_data.thold_alert!=0 OR thold_data.bl_alert>0)"; } /* breached */ if ($_REQUEST['triggered'] == '3') { $sql_where = "WHERE ((thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger))"; } /* triggered */ } if (strlen($_REQUEST["filter"])) { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " thold_data.name LIKE '%%" . $_REQUEST["filter"] . "%%'"; } /* data template id filter */ if ($_REQUEST['data_template_id'] != '-1') { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " thold_data.data_template=" . $_REQUEST['data_template_id']; } /* host id filter */ if ($_REQUEST['host_id'] != '-1') { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " thold_data.host_id=" . $_REQUEST['host_id']; } /* thold permissions */ $current_user = db_fetch_row('SELECT * FROM user_auth WHERE id=' . $_SESSION['sess_user_id']); $sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']); $total_rows_sql = "SELECT * FROM thold_data\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON ((thold_data.graph_id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=1\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\tOR (thold_data.host_id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\tOR (thold_data.graph_template=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=4\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . "))\r\n\t\t{$sql_where}"; $total_rows = sizeof(db_fetch_assoc($total_rows_sql)); /* get the thold records */ $sql = "SELECT * FROM thold_data\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON ((thold_data.graph_id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=1\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\tOR (thold_data.host_id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\tOR (thold_data.graph_template=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=4\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . "))\r\n\t\t{$sql_where}\r\n\t\tORDER BY {$sort} " . $_REQUEST['sort_direction'] . $limit; $result = db_fetch_assoc($sql); html_start_box('', '100%', $colors['header'], '4', 'center', ''); if ($total_rows) { /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $_REQUEST["rows"], $total_rows, "thold_graph.php?tab=thold"); $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='13'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?filter=" . $_REQUEST["filter"] . "&page=" . ($_REQUEST["page"] - 1)) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tShowing Rows " . ($_REQUEST["rows"] * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < $_REQUEST["rows"] * $_REQUEST["page"] ? $total_rows : $_REQUEST["rows"] * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>"; if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?filter=" . $_REQUEST["filter"] . "&page=" . ($_REQUEST["page"] + 1)) . "'>"; } $nav .= "Next"; if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='13'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tNo Rows Found\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n"; } print $nav; $display_text = array('nosort' => array('Actions', ''), 'name' => array('Name', 'ASC'), 'id' => array('ID', 'ASC'), 'thold_type' => array('Type', 'ASC'), 'nosort2' => array('Trigger', 'ASC'), 'nosort3' => array('Duration', 'ASC'), 'repeat_alert' => array('Repeat', 'ASC'), 'nosort4' => array('Warn Hi/Lo', 'ASC'), 'nosort5' => array('Alert Hi/Lo', 'ASC'), 'nosort6' => array('BL Hi/Lo', 'ASC'), 'lastread' => array('Current', 'ASC'), 'thold_alert' => array('Triggered', 'ASC'), 'thold_enabled' => array('Enabled', 'ASC')); html_header_sort($display_text, $_REQUEST['sort_column'], $_REQUEST['sort_direction']); $timearray = array(1 => '5 Minutes', 2 => '10 Minutes', 3 => '15 Minutes', 4 => '20 Minutes', 6 => '30 Minutes', 8 => '45 Minutes', 12 => 'Hour', 24 => '2 Hours', 36 => '3 Hours', 48 => '4 Hours', 72 => '6 Hours', 96 => '8 Hours', 144 => '12 Hours', 288 => '1 Day', 576 => '2 Days', 2016 => '1 Week', 4032 => '2 Weeks', 8640 => '1 Month'); $c = 0; $i = 0; $types = array('High/Low', 'Baseline Deviation', 'Time Based'); if (count($result)) { foreach ($result as $row) { $c++; $alertstat = 'no'; $bgcolor = 'green'; if ($row['thold_type'] == 0) { if ($row['thold_alert'] != 0) { $alertstat = 'yes'; if ($row['thold_fail_count'] >= $row['thold_fail_trigger']) { $bgcolor = 'red'; } elseif ($row['thold_warning_fail_count'] >= $row['thold_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } elseif ($row['thold_type'] == 2) { if ($row['thold_alert'] != 0) { $alertstat = 'yes'; if ($row['thold_fail_count'] >= $row['time_fail_trigger']) { $bgcolor = 'red'; } elseif ($row['thold_warning_fail_count'] >= $row['time_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } else { if ($row['bl_alert'] == 1) { $alertstat = 'baseline-LOW'; $bgcolor = $row['bl_fail_count'] >= $row['bl_fail_trigger'] ? 'orange' : 'yellow'; } elseif ($row['bl_alert'] == 2) { $alertstat = 'baseline-HIGH'; $bgcolor = $row['bl_fail_count'] >= $row['bl_fail_trigger'] ? 'orange' : 'yellow'; } } if ($row['thold_enabled'] == 'off') { form_alternate_row_color($thold_bgcolors['grey'], $thold_bgcolors['grey'], $i, 'line' . $row["id"]); $i++; } else { form_alternate_row_color($thold_bgcolors[$bgcolor], $thold_bgcolors[$bgcolor], $i, 'line' . $row["id"]); $i++; } print "<td width='1%' style='white-space:nowrap;' nowrap>"; if (api_user_realm_auth('thold_add.php')) { print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?rra=' . $row["rra_id"] . '&view_rrd=' . $row["data_id"]) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="Edit Threshold"></a>'; } if ($row["thold_enabled"] == 'on') { print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?id=' . $row["id"] . '&action=disable') . '"><img src="' . $config['url_path'] . 'plugins/thold/images/disable_thold.png" border="0" alt="" title="Disable Threshold"></a>'; } else { print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?id=' . $row["id"] . '&action=enable') . '"><img src="' . $config['url_path'] . 'plugins/thold/images/enable_thold.png" border="0" alt="" title="Enable Threshold"></a>'; } print "<a href='" . htmlspecialchars($config['url_path'] . "graph.php?local_graph_id=" . $row['graph_id'] . "&rra_id=all") . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='View Graph'></a>"; print "<a href='" . htmlspecialchars($config['url_path'] . "plugins/thold/thold_graph.php?tab=log&threshold_id=" . $row["id"] . "&status=-1") . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_log.gif' border='0' alt='' title='View Threshold History'></a>"; print "</td>"; print "<td width='28%'>" . ($row['name'] != '' ? $row['name'] : 'No name set') . "</td>"; print "<td width='10'>" . $row["id"] . "</td>"; print "<td nowrap style='white-space:nowrap;' width='120'>" . $types[$row['thold_type']] . "</td>"; switch ($row['thold_type']) { case 0: print "<td nowrap style='white-space:nowrap;' width='80'><i>" . plugin_thold_duration_convert($row['rra_id'], $row['thold_fail_trigger'], 'alert') . "</i></td>"; print "<td width='80'>N/A</td>"; break; case 1: print "<td nowrap style='white-space:nowrap;' width='80'><i>" . plugin_thold_duration_convert($row['rra_id'], $row['bl_fail_trigger'], 'alert') . "</i></td>"; print "<td nowrap style='white-space:nowrap;' width='80'>" . $timearray[$row['bl_ref_time_range'] / 300] . "</td>"; break; case 2: print "<td nowrap style='white-space:nowrap;' width='80'><i>" . $row['time_fail_trigger'] . " Triggers</i></td>"; print "<td nowrap style='white-space:nowrap;' width='80'>" . plugin_thold_duration_convert($row['rra_id'], $row['time_fail_length'], 'time') . "</td>"; break; default: print "<td width='80'>N/A</td>"; print "<td width='80'>N/A</td>"; } print "<td nowrap style='white-space:nowrap;' width='80'>" . ($row['repeat_alert'] == '' ? '' : plugin_thold_duration_convert($row['rra_id'], $row['repeat_alert'], 'repeat')) . "</td>"; print "<td nowrap style='white-space:nowrap;' width='80'>" . ($row['thold_type'] == 1 ? "N/A" : ($row['thold_type'] == 2 ? thold_format_number($row['time_warning_hi']) . '/' . thold_format_number($row['time_warning_low']) : thold_format_number($row['thold_warning_hi']) . '/' . thold_format_number($row['thold_warning_low']))) . "</td>"; print "<td width='80'>" . ($row['thold_type'] == 1 ? "N/A" : ($row['thold_type'] == 2 ? thold_format_number($row['time_hi']) . '/' . thold_format_number($row['time_low']) : thold_format_number($row['thold_hi']) . '/' . thold_format_number($row['thold_low']))) . "</td>"; print "<td width='80'>" . ($row['thold_type'] == 1 ? $row['bl_pct_up'] . (strlen($row['bl_pct_up']) ? '%' : '-') . '/' . $row['bl_pct_down'] . (strlen($row['bl_pct_down']) ? '%' : '-') : 'N/A') . "</td>"; print "<td width='80'>" . thold_format_number($row['lastread']) . "</td>"; print "<td width='80'>" . ($row['thold_alert'] ? "yes" : "no") . "</td>"; if ($row['thold_enabled'] == 'off') { print "<td width='40'><b>Disabled</b></td>"; } else { print "<td width='40'>Enabled</td>"; } form_end_row(); } } else { form_alternate_row_color($colors['alternate'], $colors['light'], 0); print '<td colspan=12><center>No Thresholds</center></td></tr>'; } print $nav; html_end_box(false); thold_legend(); //thold_display_rusage(); }