本文整理汇总了PHP中get_colored_device_status函数的典型用法代码示例。如果您正苦于以下问题:PHP get_colored_device_status函数的具体用法?PHP get_colored_device_status怎么用?PHP get_colored_device_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_colored_device_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: host
//.........这里部分代码省略.........
html_start_box("", "100%", $colors["header"], "3", "center", "");
$total_rows = db_fetch_cell("select
COUNT(host.id)
from host
$sql_where");
$sortby = $_REQUEST["sort_column"];
if ($sortby=="hostname") {
$sortby = "INET_ATON(hostname)";
}
$host_graphs = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id"), "host_id", "graphs");
$host_data_sources = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id"), "host_id", "data_sources");
$sql_query = "SELECT
host.id,
host.disabled,
host.status,
host.hostname,
host.description,
host.min_time,
host.max_time,
host.cur_time,
host.avg_time,
host.availability
FROM host
$sql_where
ORDER BY " . $sortby . " " . $_REQUEST["sort_direction"] . "
LIMIT " . (read_config_option("num_rows_device")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_device");
//print $sql_query;
$hosts = db_fetch_assoc($sql_query);
/* generate page list */
$url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"]);
$nav = "<tr bgcolor='#" . $colors["header"] . "'>
<td colspan='9'>
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td align='left' class='textHeaderDark'>
<strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>
</td>\n
<td align='center' class='textHeaderDark'>
Showing Rows " . ((read_config_option("num_rows_device")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_device")) || ($total_rows < (read_config_option("num_rows_device")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_device")*$_REQUEST["page"])) . " of $total_rows [$url_page_select]
</td>\n
<td align='right' class='textHeaderDark'>
<strong>"; if (($_REQUEST["page"] * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>
</td>\n
</tr>
</table>
</td>
</tr>\n";
print $nav;
$display_text = array(
"description" => array("Description", "ASC"),
"nosort1" => array("Graphs", "ASC"),
"nosort2" => array("Data Sources", "ASC"),
"status" => array("Status", "ASC"),
"hostname" => array("Hostname", "ASC"),
"cur_time" => array("Current (ms)", "DESC"),
"avg_time" => array("Average (ms)", "DESC"),
"availability" => array("Availability", "ASC"));
html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
$i = 0;
if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $host["id"]); $i++;
form_selectable_cell("<a class='linkEditMain' href='host.php?action=edit&id=" . $host["id"] . "'>" .
(strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]) : $host["description"]) . "</a>", $host["id"], 250);
form_selectable_cell((isset($host_graphs[$host["id"]]) ? $host_graphs[$host["id"]] : 0), $host["id"]);
form_selectable_cell((isset($host_data_sources[$host["id"]]) ? $host_data_sources[$host["id"]] : 0), $host["id"]);
form_selectable_cell(get_colored_device_status(($host["disabled"] == "on" ? true : false), $host["status"]), $host["id"]);
form_selectable_cell((strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["hostname"]) : $host["hostname"]), $host["id"]);
form_selectable_cell(round(($host["cur_time"]), 2), $host["id"]);
form_selectable_cell(round(($host["avg_time"]), 2), $host["id"]);
form_selectable_cell(round($host["availability"], 2), $host["id"]);
form_checkbox_cell($host["description"], $host["id"]);
form_end_row();
}
/* put the nav bar on the bottom as well */
print $nav;
}else{
print "<tr><td><em>No Hosts</em></td></tr>";
}
html_end_box(false);
/* add a list of tree names to the actions dropdown */
add_tree_names_to_actions_array();
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($device_actions);
}
示例2: mactrack_format_device_row
function mactrack_format_device_row($device, $actions = false)
{
global $config, $colors, $mactrack_device_types;
/* viewer level */
if ($actions) {
$row = "<a href='" . htmlspecialchars($config['url_path'] . "plugins/mactrack/mactrack_interfaces.php?device_id=" . $device['device_id'] . "&issues=0&page=1") . "'><img src='" . $config['url_path'] . "plugins/mactrack/images/view_interfaces.gif' alt='' onMouseOver='style.cursor=\"pointer\"' title='View Interfaces' align='middle' border='0'></a>";
/* admin level */
if (mactrack_authorized(2121)) {
if ($device["disabled"] == '') {
$row .= "<img id='r_" . $device["device_id"] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_device.gif' alt='' onMouseOver='style.cursor=\"pointer\"' onClick='scan_device(" . $device["device_id"] . ")' title='Rescan Device' align='middle' border='0'>";
} else {
$row .= "<img src='" . $config['url_path'] . "plugins/mactrack/images/view_none.gif' alt='' align='middle' border='0'>";
}
}
print "<td style='width:40px;'>" . $row . "</td>";
//, $device["device_id"]);
}
form_selectable_cell("<a class='linkEditMain' href='mactrack_devices.php?action=edit&device_id=" . $device['device_id'] . "'>" . (strlen($_REQUEST['filter']) ? preg_replace("/(" . preg_quote($_REQUEST['filter']) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device['device_name']) : $device['device_name']) . "</a>", $device["device_id"]);
form_selectable_cell($device["site_name"], $device["device_id"]);
form_selectable_cell(get_colored_device_status($device["disabled"] == "on" ? true : false, $device["snmp_status"]), $device["device_id"]);
form_selectable_cell(strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["hostname"]) : $device["hostname"], $device["device_id"]);
form_selectable_cell($device["device_type"] == '' ? 'Not Detected' : $device["device_type"], $device["device_id"]);
form_selectable_cell($device["scan_type"] == "1" ? "N/A" : $device["ips_total"], $device["device_id"]);
form_selectable_cell($device["scan_type"] == "3" ? "N/A" : $device["ports_total"], $device["device_id"]);
form_selectable_cell($device["scan_type"] == "3" ? "N/A" : $device["ports_active"], $device["device_id"]);
form_selectable_cell($device["scan_type"] == "3" ? "N/A" : $device["ports_trunk"], $device["device_id"]);
form_selectable_cell($device["scan_type"] == "3" ? "N/A" : $device["macs_active"], $device["device_id"]);
form_selectable_cell(number_format($device["last_runduration"], 1), $device["device_id"]);
form_checkbox_cell($device["device_name"], $device["device_id"]);
form_end_row();
}
示例3: hosts
//.........这里部分代码省略.........
strURL = '?header=false&action=edit&id=<?php
print get_request_var('id');
?>
'
strURL += '&rows=' + $('#rows').val();
strURL += '&host_template_id=' + $('#host_template_id').val();
strURL += '&associated=' + $('#associated').is(':checked');
strURL += '&filter=' + $('#filter').val();
loadPageNoHeader(strURL);
}
function clearFilter() {
strURL = 'notify_lists.php?header=false&action=edit&id=<?php
print get_request_var('id');
?>
&clearf=true'
loadPageNoHeader(strURL);
}
$(function() {
$('#form_devices').submit(function(event) {
event.preventDefault();
applyFilter();
});
});
</script>
</td>
</tr>
<?php
html_end_box();
/* form the 'where' clause for our main sql query */
if (strlen(get_request_var('filter'))) {
$sql_where = "WHERE (host.hostname LIKE '%" . get_request_var('filter') . "%' OR host.description LIKE '%" . get_request_var('filter') . "%')";
} else {
$sql_where = '';
}
if (get_request_var('host_template_id') == '-1') {
/* Show all items */
} elseif (get_request_var('host_template_id') == '0') {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=0';
} elseif (!isempty_request_var('host_template_id')) {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=' . get_request_var('host_template_id');
}
if (get_request_var('associated') == 'false') {
/* Show all items */
} else {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (host.thold_send_email>1 AND host.thold_host_email=' . get_request_var('id') . ')';
}
$total_rows = db_fetch_cell("select\n\t\tCOUNT(host.id)\n\t\tfrom host\n\t\t{$sql_where}");
$host_graphs = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id'), 'host_id', 'graphs');
$host_data_sources = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id'), 'host_id', 'data_sources');
$sql_query = "SELECT *\n\t\tFROM host {$sql_where}\n\t\tLIMIT " . $rows * (get_request_var('page') - 1) . ',' . $rows;
$hosts = db_fetch_assoc($sql_query);
$nav = html_nav_bar('notify_lists.php?action=edit&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 10, __('Devices'), 'page', 'main');
form_start('notify_lists.php', 'chk');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array(__('Description'), __('ID'), __('Associated Lists'), __('Graphs'), __('Data Sources'), __('Status'), __('Hostname'));
html_header_checkbox($display_text);
if (sizeof($hosts)) {
foreach ($hosts as $host) {
form_alternate_row('line' . $host['id'], true);
form_selectable_cell(filter_value($host['description'], get_request_var('filter')), $host['id'], 250);
form_selectable_cell(round($host['id'], 2), $host['id']);
if ($host['thold_send_email'] == 0) {
form_selectable_cell('<span style="color:blue;font-weight:bold;">' . __('Disabled') . '</span>', $host['id']);
} elseif ($host['thold_send_email'] == 1) {
form_selectable_cell('<span style="color:purple;font-weight:bold;">' . __('Global List') . '</span>', $host['id']);
} elseif ($host['thold_host_email'] == get_request_var('id')) {
if ($host['thold_send_email'] == 2) {
form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('Current List Only') . '</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('Current and Global List(s)') . '</span>', $host['id']);
}
} elseif ($host['thold_host_email'] == '0') {
form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('None') . '</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:red;font-weight:bold;">' . db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . get_request_var('id')) . '</span>', $host['id']);
}
form_selectable_cell(isset($host_graphs[$host['id']]) ? $host_graphs[$host['id']] : 0, $host['id']);
form_selectable_cell(isset($host_data_sources[$host['id']]) ? $host_data_sources[$host['id']] : 0, $host['id']);
form_selectable_cell(get_colored_device_status($host['disabled'] == 'on' ? true : false, $host['status']), $host['id']);
form_selectable_cell(filter_value($host['hostname'], get_request_var('filter')), $host['id']);
form_checkbox_cell($host['description'], $host['id']);
form_end_row();
}
} else {
print '<tr><td><em>' . __('No Associated Devices Found') . '</em></td></tr>';
}
html_end_box(false);
if (sizeof($hosts)) {
print $nav;
}
form_hidden_box('tab', 'hosts', '');
form_hidden_box('id', get_request_var('id'), '');
form_hidden_box('save_associate', '1', '');
draw_actions_dropdown($assoc_actions);
form_end();
}
示例4: tholds_old
//.........这里部分代码省略.........
'>
</form>
</td>
</tr>
<?php
html_end_box();
/* form the 'where' clause for our main sql query */
if (strlen(get_request_var_request("filter"))) {
$sql_where = "WHERE (host.hostname LIKE '%%" . get_request_var_request("filter") . "%%' OR host.description LIKE '%%" . get_request_var_request("filter") . "%%')";
} else {
$sql_where = "";
}
if (get_request_var_request("host_template_id") == "-1") {
/* Show all items */
} elseif (get_request_var_request("host_template_id") == "0") {
$sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " host.host_template_id=0";
} elseif (!empty($_REQUEST["host_template_id"])) {
$sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " host.host_template_id=" . get_request_var_request("host_template_id");
}
if (get_request_var_request("associated") == "false") {
/* Show all items */
} else {
$sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " (host.thold_send_email>1 AND host.thold_host_email=" . get_request_var_request("id") . ")";
}
/* print checkbox form for validation */
print "<form name='chk' method='post' action='notify_lists.php?action=edit&tab=hosts&id=" . get_request_var_request("id") . "'>\n";
html_start_box("", "100%", $colors["header"], "3", "center", "");
$total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM host\n\t\t{$sql_where}");
$host_graphs = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id"), "host_id", "graphs");
$host_data_sources = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id"), "host_id", "data_sources");
$sql_query = "SELECT * \n\t\tFROM host {$sql_where} \n\t\tLIMIT " . get_request_var_request("rows") * (get_request_var_request("page") - 1) . "," . get_request_var_request("rows");
$hosts = db_fetch_assoc($sql_query);
/* generate page list */
if ($total_rows > 0) {
$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, get_request_var_request("rows"), $total_rows, "notify_lists.php?action=edit&tab=hosts&id=" . get_request_var_request('id'));
$nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t<td colspan='8'>\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t<strong><< ";
if (get_request_var_request("page") > 1) {
$nav .= "<a class='linkOverDark' href='" . htmlspecialchars("notify_lists.php?action=edit&id=" . get_request_var_request("id") . "&page=" . (get_request_var_request("page") - 1)) . "'>";
}
$nav .= "Previous";
if (get_request_var_request("page") > 1) {
$nav .= "</a>";
}
$nav .= "</strong>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\tShowing Rows " . (get_request_var_request("rows") * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < get_request_var_request("rows") * get_request_var_request("page") ? $total_rows : get_request_var_request("rows") * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t\t<strong>";
if (get_request_var_request("page") * get_request_var_request("rows") < $total_rows) {
$nav .= "<a class='linkOverDark' href='" . htmlspecialchars("notify_lists.php?action=edit&id=" . get_request_var_request("id") . "&page=" . (get_request_var_request("page") + 1)) . "'>";
}
$nav .= "Next";
if (get_request_var_request("page") * get_request_var_request("rows") < $total_rows) {
$nav .= "</a>";
}
$nav .= " >></strong>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
} else {
$nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t<td colspan='8'>\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
}
print $nav;
$display_text = array("Description", "ID", "Associated Lists", "Graphs", "Data Sources", "Status", "Hostname");
html_header_checkbox($display_text);
$i = 0;
if (sizeof($hosts)) {
foreach ($hosts as $host) {
form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $host["id"]);
$i++;
form_selectable_cell(strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($host["description"])) : htmlspecialchars($host["description"]), $host["id"], 250);
form_selectable_cell(round($host["id"], 2), $host["id"]);
if ($host['thold_send_email'] == 0) {
form_selectable_cell('<span style="color:blue;font-weight:bold;">Disabled</span>', $host['id']);
} elseif ($host['thold_send_email'] == 1) {
form_selectable_cell('<span style="color:purple;font-weight:bold;">Global List</span>', $host['id']);
} elseif ($host['thold_host_email'] == get_request_var_request('id')) {
if ($host['thold_send_email'] == 2) {
form_selectable_cell('<span style="color:green;font-weight:bold;">Current List Only</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:green;font-weight:bold;">Current and Global List(s)</span>', $host['id']);
}
} elseif ($host['thold_host_email'] == '0') {
form_selectable_cell('<span style="color:green;font-weight:bold;">None</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:red;font-weight:bold;">' . db_fetch_cell("SELECT name FROM plugin_notification_lists WHERE id=" . get_request_var_request('id')) . '</span>', $host['id']);
}
form_selectable_cell(isset($host_graphs[$host["id"]]) ? $host_graphs[$host["id"]] : 0, $host["id"]);
form_selectable_cell(isset($host_data_sources[$host["id"]]) ? $host_data_sources[$host["id"]] : 0, $host["id"]);
form_selectable_cell(get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]), $host["id"]);
form_selectable_cell(strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($host["hostname"])) : htmlspecialchars($host["hostname"]), $host["id"]);
form_checkbox_cell($host["description"], $host["id"]);
form_end_row();
}
/* put the nav bar on the bottom as well */
print $nav;
} else {
print "<tr><td><em>No Associated Hosts Found</em></td></tr>";
}
html_end_box(false);
form_hidden_box("action", "edit");
form_hidden_box("id", get_request_var_request("id"));
form_hidden_box("save_associate", "1");
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($assoc_actions);
print "</form>\n";
}
示例5: device
//.........这里部分代码省略.........
html_start_box("", "100", $colors["header"], "0", "center", "");
$total_rows = db_fetch_cell("select
COUNT(device.id)
from device
$sql_where");
if (get_request_var_request("rows") == "-1") {
$rows = read_config_option("num_rows_device");
}else{
$rows = get_request_var_request("rows");
}
$sortby = $_REQUEST["sort_column"];
if ($sortby=="hostname") {
$sortby = "INET_ATON(hostname)";
}
$device_graphs = array_rekey(db_fetch_assoc("SELECT device_id, count(*) as graphs FROM graph_local GROUP BY device_id"), "device_id", "graphs");
$device_data_sources = array_rekey(db_fetch_assoc("SELECT device_id, count(*) as data_sources FROM data_local GROUP BY device_id"), "device_id", "data_sources");
$sql_query = "SELECT device.*, poller.description AS poller, sites.name AS site
FROM device
LEFT JOIN poller
ON device.poller_id=poller.id
LEFT JOIN sites
ON device.site_id=sites.id
$sql_where
ORDER BY " . $sortby . " " . get_request_var_request("sort_direction") . "
LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows;
//print $sql_query;
$devices = db_fetch_assoc($sql_query);
/* generate page list navigation */
$nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $rows, $total_rows, 13, "devices.php");
print $nav;
html_end_box(false);
$display_text = array(
"description" => array(__("Description"), "ASC"),
"device.hostname" => array(__("Hostname"), "ASC"),
"id" => array(__("ID"), "ASC"),
"nosort1" => array(__("Graphs"), "ASC"),
"nosort2" => array(__("Data Sources"), "ASC"),
"status" => array(__("Status"), "ASC"),
"status_event_count" => array(__("Event Count"), "ASC"),
"cur_time" => array(__("Current (ms)"), "DESC"),
"avg_time" => array(__("Average (ms)"), "DESC"),
"availability" => array(__("Availability"), "ASC"),
"polling_time" => array(__("Poll Time"), "DESC"));
html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));
if (sizeof($devices) > 0) {
foreach ($devices as $device) {
$spanextra = "";
if($device["disabled"] != CHECKED && $device["status"] == DEVICE_DOWN) {
$date = __date("D, " . date_time_format() . " T", strtotime($device['status_fail_date']));
$spanextra = 'title="' . __("Down since %s with error: '%s'", $date, $device['status_last_error']) . '"';
}
form_alternate_row_color('line' . $device["id"], true);
form_selectable_cell("<a style='white-space:nowrap;' class='linkEditMain' href='" . htmlspecialchars("devices.php?action=edit&id=" . $device["id"]) . "'>" .
(strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span class=\"filter\">\\1</span>", $device["description"]) : $device["description"]) . "</a>", $device["id"]);
form_selectable_cell((strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span class=\"filter\">\\1</span>", $device["hostname"]) : $device["hostname"]), $device["id"]);
form_selectable_cell(round(($device["id"]), 2), $device["id"]);
form_selectable_cell((isset($device_graphs[$device["id"]]) ? $device_graphs[$device["id"]] : 0), $device["id"]);
form_selectable_cell((isset($device_data_sources[$device["id"]]) ? $device_data_sources[$device["id"]] : 0), $device["id"]);
form_selectable_cell( "<span $spanextra>".get_colored_device_status(($device["disabled"] == CHECKED ? true : false), $device["status"]) . "</span>", $device["id"]);
form_selectable_cell(round(($device["status_event_count"]), 2), $device["id"]);
form_selectable_cell(round(($device["cur_time"]), 2), $device["id"]);
form_selectable_cell(round(($device["avg_time"]), 2), $device["id"]);
form_selectable_cell(round($device["availability"], 2), $device["id"]);
form_selectable_cell(round($device["polling_time"], 2), $device["id"]);
form_checkbox_cell($device["description"], $device["id"]);
form_end_row();
}
form_end_table();
/* put the nav bar on the bottom as well */
print $nav;
}else{
print "<tr><td><em>" . __("No Hosts") . "</em></td></tr>";
}
print "</table>\n";
/* add a list of tree names to the actions dropdown */
$device_actions = array_merge($device_actions, api_tree_add_tree_names_to_actions_array());
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($device_actions);
print "</form>\n";
}
示例6: mactrack_view_devices
//.........这里部分代码省略.........
}else{
$nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'>
<td colspan='22'>
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td align='center' class='textHeaderDark'>
No Rows Found
</td>\n
</tr>
</table>
</td>
</tr>\n";
}
}else{
$nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 13, "mactrack_view_sites.php");
}
print $nav;
$display_text = array(
"nosort" => array("Actions", ""),
"device_name" => array("Device Name", "ASC"),
"site_name" => array("Site Name", "ASC"),
"snmp_status" => array("Status", "ASC"),
"hostname" => array("Hostname", "ASC"),
"device_type" => array("Device Type", "ASC"),
"ips_total" => array("Total IP's", "DESC"),
"ports_total" => array("User Ports", "DESC"),
"ports_active" => array("User Ports Up", "DESC"),
"ports_trunk" => array("Trunk Ports", "DESC"),
"macs_active" => array("Active Macs", "DESC"),
"vlans_total" => array("Total VLAN's", "DESC"),
"last_runduration" => array("Last Duration", "DESC"));
html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
$i = 0;
if (sizeof($devices) > 0) {
foreach ($devices as $device) {
$hostinfo["hostname"] = $device["hostname"];
$hostinfo["user"] = $device["user_name"];
switch($device["term_type"]) {
case 0:
$hostinfo["transport"] = "none";
break;
case 1:
$hostinfo["transport"] = "telnet";
break;
case 2:
$hostinfo["transport"] = "ssh";
break;
case 3:
$hostinfo["transport"] = "http";
break;
case 4:
$hostinfo["transport"] = "https";
break;
}
form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
?>
<td width=100>
<?php if (mactrack_authorized(2121)) {?>
<a href='<?php print $webroot . "plugins/mactrack/mactrack_devices.php?action=edit&device_id=" . $device['device_id'];?>' title='Edit Device'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/edit_object.png'></a>
<?php api_plugin_hook_function('remote_link', $hostinfo); } ?>
<?php if ($device["host_id"] > 0) {?>
<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_graphs.php?action=preview&report=graphs&style=selective&graph_list=&host_id=" . $device["host_id"] . "&graph_template_id=0&filter=";?>' title='View Graphs'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_graphs.gif'></a>
<?php }else{?>
<img title='Device Not Mapped to Cacti Device' border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_graphs_disabled.gif'>
<?php }?>
<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $_REQUEST["site_id"] . "&device_id=" . $device['device_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a>
<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $_REQUEST["site_id"] . "&device=" . $device['device_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a>
</td>
<td width=150>
<?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["device_name"]) : $device["device_name"]) . "</strong>";?>
</td>
<td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["site_name"]) : $device["site_name"]);?></td>
<td><?php print get_colored_device_status(($device["disabled"] == "on" ? true : false), $device["snmp_status"]);?></td>
<td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["hostname"]) : $device["hostname"]);?></td>
<td><?php print $device["device_type"];?></td>
<td><?php print ($device["scan_type"] == "1" ? "N/A" : $device["ips_total"]);?></td>
<td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_total"]);?></td>
<td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_active"]);?></td>
<td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_trunk"]);?></td>
<td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["macs_active"]);?></td>
<td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["vlans_total"]);?></td>
<td><?php print number_format($device["last_runduration"], 1);?></td>
</tr>
<?php
}
}else{
print "<tr><td colspan='10'><em>No MacTrack Devices</em></td></tr>";
}
print $nav;
html_end_box(false);
mactrack_display_stats();
}
示例7: hmib_devices
//.........这里部分代码省略.........
<?php
html_end_box();
if (get_request_var('rows') == '-1') {
$num_rows = read_config_option('num_rows_table');
} else {
$num_rows = get_request_var('rows');
}
$limit = ' LIMIT ' . $num_rows * (get_request_var('page') - 1) . ',' . $num_rows;
$sql_where = '';
if (get_request_var('template') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' host.host_template_id=' . get_request_var('template');
}
if (get_request_var('status') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . get_request_var('status');
}
if (get_request_var('type') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_type=' . get_request_var('type');
}
if (get_request_var('process') != '' && get_request_var('process') != '-1') {
$sql_join = 'INNER JOIN plugin_hmib_hrSWRun AS hrswr ON host.id=hrswr.host_id';
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " hrswr.name='" . get_request_var('process') . "'";
} else {
$sql_join = '';
}
if (get_request_var('filter') != '') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " host.description LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thost.hostname LIKE '%" . get_request_var('filter') . "%'";
}
$sql = "SELECT hrs.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_hmib_hrSystem AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' ' . $limit;
$rows = db_fetch_assoc($sql);
$total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_hmib_hrSystem AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}");
$nav = html_nav_bar('hmib.php?action=devices', MAX_DISPLAY_PAGES, get_request_var('page'), $num_rows, $total_rows, 16, __('Devices'), 'page', 'main');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => __('Hostname'), 'sort' => 'ASC', 'align' => 'left'), 'host_status' => array('display' => __('Status'), 'sort' => 'DESC', 'align' => 'right'), 'uptime' => array('display' => __('Uptime(d:h:m)'), 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => __('Users'), 'sort' => 'DESC', 'align' => 'right'), 'cpuPercent' => array('display' => __('CPU %'), 'sort' => 'DESC', 'align' => 'right'), 'numCpus' => array('display' => __('CPUs'), 'sort' => 'DESC', 'align' => 'right'), 'processes' => array('display' => __('Processes'), 'sort' => 'DESC', 'align' => 'right'), 'memSize' => array('display' => __('Total Mem'), 'sort' => 'DESC', 'align' => 'right'), 'memUsed' => array('display' => __('Used Mem'), 'sort' => 'DESC', 'align' => 'right'), 'swapSize' => array('display' => __('Total Swap'), 'sort' => 'DESC', 'align' => 'right'), 'swapUsed' => array('display' => __('Used Swap'), 'sort' => 'DESC', 'align' => 'right'));
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'hmib.php?action=devices');
/* 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';
$dashboard = $config['url_path'] . 'plugins/hmib/images/view_dashboard.gif';
$graphs = $config['url_path'] . 'plugins/hmib/images/view_graphs.gif';
$nographs = $config['url_path'] . 'plugins/hmib/images/view_graphs_disabled.gif';
$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'");
if (sizeof($rows)) {
foreach ($rows as $row) {
$days = intval($row['uptime'] / (60 * 60 * 24 * 100));
$remainder = $row['uptime'] % (60 * 60 * 24 * 100);
$hours = intval($remainder / (60 * 60 * 100));
$remainder = $remainder % (60 * 60 * 100);
$minutes = intval($remainder / (60 * 100));
$found = db_fetch_cell('SELECT COUNT(*) FROM graph_local WHERE host_id=' . $row['host_id']);
form_alternate_row();
echo "<td width='120'>";
//echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle'></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=storage&reset=1&device=" . $row['host_id']) . "'><img src='{$storage}' title='" . __('View Storage') . "' align='absmiddle' alt=''></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=hardware&reset=1&device=" . $row['host_id']) . "'><img src='{$hardw}' title='" . __('View Hardware') . "' align='absmiddle' alt=''></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=running&reset=1&device=" . $row['host_id']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=software&reset=1&device=" . $row['host_id']) . "'><img src='{$inven}' title='" . __('View Software Inventory') . "' align='absmiddle' alt=''></a>";
if ($found) {
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host_id=" . $row['host_id'] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='" . __('View Graphs') . "' align='absmiddle' alt=''></a>";
} else {
echo "<img src='{$nographs}' title='" . __('No Graphs Defined') . "' align='absmiddle' alt=''>";
}
$graph_cpu = hmib_get_graph_url($hcpudq, 0, $row['host_id'], '', $row['numCpus'], false);
$graph_cpup = hmib_get_graph_url($hcpudq, 0, $row['host_id'], '', round($row['cpuPercent'], 2) . ' %', false);
$graph_users = hmib_get_graph_template_url($hugt, 0, $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['users'], false);
$graph_aproc = hmib_get_graph_template_url($hpgt, 0, $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['processes'], false);
if (api_plugin_user_realm_auth('host.php')) {
$host_url = "<a href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='" . __('Edit Device') . "'>" . $row['hostname'] . '</a>';
} else {
$host_url = $row['hostname'];
}
echo '</td>';
echo "<td class='nowrap left'>" . $row['description'] . ' [' . $host_url . ']' . '</td>';
echo "<td class='nowrap right'>" . get_colored_device_status($row['disabled'] == 'on' ? true : false, $row['host_status']) . '</td>';
echo "<td class='nowrap right'>" . hmib_format_uptime($days, $hours, $minutes) . '</td>';
echo "<td class='nowrap right'>" . $graph_users . '</td>';
echo "<td class='nowrap right'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpup) . '</td>';
echo "<td class='nowrap right'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpu) . '</td>';
echo "<td class='nowrap right'>" . $graph_aproc . '</td>';
echo "<td class='nowrap right'>" . hmib_memory($row['memSize']) . '</td>';
echo "<td class='nowrap right'>" . ($row['host_status'] < 2 ? 'N/A' : round($row['memUsed'], 0)) . ' %</td>';
echo "<td class='nowrap right'>" . hmib_memory($row['swapSize']) . '</td>';
echo "<td class='nowrap right'>" . ($row['host_status'] < 2 ? 'N/A' : round($row['swapUsed'], 0)) . ' %</td>';
}
echo '</tr>';
} else {
print '<tr><td><em>' . __('No Devices Found') . '</em></td></tr>';
}
html_end_box(false);
if (sizeof($rows)) {
print $nav;
}
}
示例8: thold_hosts
//.........这里部分代码省略.........
'>
</td>
</tr>
</table>
<input type='hidden' id='page' value='<?php
print get_request_var('page');
?>
'>
<input type='hidden' id='id' value='<?php
print get_request_var('id');
?>
'>
</form>
</td>
</tr>
<?php
html_end_box();
/* form the 'where' clause for our main sql query */
if (strlen(get_request_var('filter'))) {
$sql_where = "WHERE (h.hostname LIKE '%" . get_request_var('filter') . "%' \n\t\t\tOR h.description LIKE '%" . get_request_var('filter') . "%')";
} else {
$sql_where = '';
}
if (get_request_var('host_template_id') == '-1') {
/* Show all items */
} elseif (get_request_var('host_template_id') == '0') {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' h.host_template_id=0';
} elseif (!isempty_request_var('host_template_id')) {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' h.host_template_id=' . get_request_var('host_template_id');
}
if (get_request_var('associated') == 'false') {
/* Show all items */
} else {
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' type=1 AND schedule=' . get_request_var('id');
}
if (get_request_var('id')) {
$total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(DISTINCT h.id)\n\t\t\tFROM host AS h\n\t\t\tLEFT JOIN (SELECT DISTINCT host_id FROM thold_data) AS td \n\t\t\tON h.id=td.host_id\n\t\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\t\tON h.id=pmh.host\n\t\t\tAND pmh.schedule=" . get_request_var('id') . "\n\t\t\t{$sql_where}");
} else {
$total_rows = 0;
}
$sortby = get_request_var('sort_column');
if ($sortby == 'hostname') {
$sortby = 'INET_ATON(hostname)';
}
if (get_request_var('id')) {
$sql_query = 'SELECT h.*, pmh.type, graphs, data_sources, tholds,
(SELECT schedule FROM plugin_maint_hosts WHERE host=h.id AND schedule=' . get_request_var('id') . ") AS associated \n\t\t\tFROM host as h\n\t\t\tLEFT JOIN (SELECT COUNT(id) AS tholds, host_id FROM thold_data GROUP BY host_id) AS td\n\t\t\tON td.host_id=h.id\n\t\t\tLEFT JOIN (SELECT COUNT(id) AS graphs, host_id FROM graph_local GROUP BY host_id) AS gl\n\t\t\tON gl.host_id=h.id\n\t\t\tLEFT JOIN (SELECT COUNT(id) AS data_sources, host_id FROM data_local GROUP BY host_id) AS dl\n\t\t\ton dl.host_id=h.id\n\t\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\t\tON pmh.host=h.id\n\t\t\tAND pmh.schedule=" . get_request_var('id') . "\n\t\t\t{$sql_where} \n\t\t\tGROUP BY h.id\n\t ORDER BY " . $sortby . ' ' . get_request_var('sort_direction') . '
LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows;
$hosts = db_fetch_assoc($sql_query);
} else {
$hosts = array();
}
$display_text = array('description' => array('display' => __('Description'), 'align' => 'left', 'sort' => 'ASC'), 'id' => array('display' => __('ID'), 'align' => 'right', 'sort' => 'asc'), 'nosort' => array('display' => __('Associated Schedules'), 'align' => 'left', 'sort' => ''), 'graphs' => array('display' => __('Graphs'), 'align' => 'right', 'sort' => 'desc'), 'data_sources' => array('display' => __('Data Sources'), 'align' => 'right', 'sort' => 'desc'), 'tholds' => array('display' => __('Thresholds'), 'align' => 'right', 'sort' => 'desc'), 'nosort1' => array('display' => __('Status'), 'align' => 'center', 'sort' => ''), 'hostname' => array('display' => __('Hostname'), 'align' => 'left', 'sort' => 'desc'));
/* generate page list */
$nav = html_nav_bar('maint.php?action=edit&tab=hosts&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 13, __('Devices'), 'page', 'main');
form_start('maint.php', 'chk');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'maint.php?action=edit&tab=hosts&id=' . get_request_var('id'));
if (sizeof($hosts)) {
foreach ($hosts as $host) {
form_alternate_row('line' . $host['id']);
form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['description'])) : htmlspecialchars($host['description']), $host['id'], 250);
form_selectable_cell(number_format_i18n($host['id']), $host['id'], '', 'text-align:right');
if ($host['associated'] != '') {
$names = '<span class="deviceUp">' . __('Current Schedule') . '</span>';
} else {
$names = '';
}
if (sizeof($lists = db_fetch_assoc('SELECT name FROM plugin_maint_schedules INNER JOIN plugin_maint_hosts ON plugin_maint_schedules.id=plugin_maint_hosts.schedule WHERE type=1 AND host=' . $host['id'] . ' AND plugin_maint_schedules.id != ' . get_request_var('id')))) {
foreach ($lists as $name) {
$names .= (strlen($names) ? ', ' : '') . "<span class='deviceRecovering'>" . $name['name'] . '</span>';
}
}
if ($names == '') {
form_selectable_cell('<span class="deviceUnknown">' . __('No Schedules') . '</span>', $host['id']);
} else {
form_selectable_cell($names, $host['id']);
}
form_selectable_cell(number_format_i18n($host['graphs']), $host['id'], '', 'text-align:right');
form_selectable_cell(number_format_i18n($host['data_sources']), $host['id'], '', 'text-align:right');
form_selectable_cell(number_format_i18n($host['tholds']), $host['id'], '', 'text-align:right');
form_selectable_cell(get_colored_device_status($host['disabled'] == 'on' ? true : false, $host['status']), $host['id'], '', 'text-align:center');
form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname']), $host['id']);
form_checkbox_cell($host['description'], $host['id']);
form_end_row();
}
} else {
print "<tr><td colspan='8'><em>" . __('No Associated Devices Found') . "</em></td></tr>";
}
html_end_box(false);
if (sizeof($hosts)) {
print $nav;
}
form_hidden_box('id', get_request_var('id'), '');
form_hidden_box('save_hosts', '1', '');
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($assoc_actions);
form_end();
}
示例9: host
function host()
{
$current_page = get_get_var_number("page", "1");
$menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "clear_stats" => "Clear Statistics", "change_snmp_opts" => "Change SNMP Options", "change_avail_opts" => "Change Availability Options", "change_poller" => "Change Poller");
$filter_array = array();
/* search field: device template */
if (isset_get_var("search_device_template")) {
$filter_array["=host_template_id"] = get_get_var("search_device_template");
}
/* search field: device status */
if (isset_get_var("search_status")) {
$filter_array["=status"] = get_get_var("search_status");
}
/* search field: filter (searches device description and hostname) */
if (isset_get_var("search_filter")) {
$filter_array["%filter"] = array("hostname" => get_get_var("search_filter"), "description" => get_get_var("search_filter"));
}
/* get a list of all devices on this page */
$devices = api_device_list($filter_array, "description", "asc", read_config_option("num_rows_device") * ($current_page - 1), read_config_option("num_rows_device"));
/* get the total number of devices on all pages */
$total_rows = api_device_total_get($filter_array);
/* generate page list */
$url_string = build_get_url_string(array("search_device_template", "search_status", "search_filter"));
$url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "devices.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
form_start("devices.php");
$box_id = "1";
html_start_box("<strong>" . _("Devices") . "</strong>", "devices.php?action=edit", $url_page_select);
html_header_checkbox(array(_("Description"), _("Status"), _("Hostname"), _("Current (ms)"), _("Average (ms)"), _("Availability")), $box_id);
$i = 0;
if (sizeof($devices) > 0) {
foreach ($devices as $host) {
?>
<tr class="item" id="box-<?php
echo $box_id;
?>
-row-<?php
echo $host["id"];
?>
" onClick="display_row_select('<?php
echo $box_id;
?>
',document.forms[0],'box-<?php
echo $box_id;
?>
-row-<?php
echo $host["id"];
?>
', 'box-<?php
echo $box_id;
?>
-chk-<?php
echo $host["id"];
?>
')" onMouseOver="display_row_hover('box-<?php
echo $box_id;
?>
-row-<?php
echo $host["id"];
?>
')" onMouseOut="display_row_clear('box-<?php
echo $box_id;
?>
-row-<?php
echo $host["id"];
?>
')">
<td class="title">
<a onClick="display_row_block('box-<?php
echo $box_id;
?>
-row-<?php
echo $host["id"];
?>
')" href="devices.php?action=edit&id=<?php
echo $host["id"];
?>
"><span id="box-<?php
echo $box_id;
?>
-text-<?php
echo $host["id"];
?>
"><?php
echo html_highlight_words(get_get_var("search_filter"), $host["description"]);
?>
</span></a>
</td>
<td>
<?php
echo get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]);
?>
</td>
<td>
<?php
echo html_highlight_words(get_get_var("search_filter"), $host["hostname"]);
?>
</td>
<td>
<?php
echo round($host["cur_time"], 2);
//.........这里部分代码省略.........
示例10: mactrack_format_device_row
function mactrack_format_device_row($device, $actions = false)
{
global $config, $mactrack_device_types;
/* viewer level */
if ($actions) {
$row = "<a href='" . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_interfaces.php?device_id=' . $device['device_id'] . '&issues=0&page=1') . "'><img src='" . $config['url_path'] . "plugins/mactrack/images/view_interfaces.gif' alt='' title='" . __('View Interfaces') . "' align='middle' border='0'></a>";
/* admin level */
if (api_user_realm_auth('mactrack_sites.php')) {
if ($device['disabled'] == '') {
$row .= "<img id='r_" . $device['device_id'] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_device.gif' alt='' onClick='scan_device(" . $device['device_id'] . ")' title='" . __('Rescan Device') . "' align='middle' border='0'>";
} else {
$row .= "<img src='" . $config['url_path'] . "plugins/mactrack/images/view_none.gif' alt='' align='middle' border='0'>";
}
}
print "<td style='width:40px;'>" . $row . "</td>";
}
form_selectable_cell(filter_value($device['device_name'], get_request_var('filter'), "mactrack_devices.php?action=edit&device_id=" . $device['device_id']), $device['device_id']);
form_selectable_cell($device['site_name'], $device['device_id']);
form_selectable_cell(get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']), $device['device_id']);
form_selectable_cell(filter_value($device['hostname'], get_request_var('filter')), $device['device_id']);
form_selectable_cell($device['device_type'] == '' ? __('Not Detected') : $device['device_type'], $device['device_id']);
form_selectable_cell($device['scan_type'] == '1' ? __('N/A') : $device['ips_total'], $device['device_id']);
form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_total'], $device['device_id']);
form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_active'], $device['device_id']);
form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_trunk'], $device['device_id']);
form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['macs_active'], $device['device_id']);
form_selectable_cell(number_format($device['last_runduration'], 1), $device['device_id']);
form_checkbox_cell($device['device_name'], $device['device_id']);
form_end_row();
}
示例11: mactrack_view_devices
//.........这里部分代码省略.........
' title='<?php
print __('View Graphs');
?>
'><img border='0' src='<?php
print $webroot;
?>
images/view_graphs.gif'></a>
<?php
} else {
?>
<img title='<?php
print __('Device Not Mapped to Cacti Device');
?>
' border='0' src='<?php
print $webroot;
?>
images/view_graphs_disabled.gif'>
<?php
}
?>
<a href='<?php
print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . get_request_var('site_id') . '&device_id=' . $device['device_id']);
?>
' title='<?php
print __('View MAC Addresses');
?>
'><img border='0' src='<?php
print $webroot;
?>
images/view_macs.gif'></a>
<a href='<?php
print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . get_request_var('site_id') . '&device=' . $device['device_id']);
?>
' title='<?php
print __('View Interfaces');
?>
'><img border='0' src='<?php
print $webroot;
?>
images/view_interfaces.gif'></a>
</td>
<td class='hyperLink'>
<?php
print filter_value($device['device_name'], get_request_var('filter'));
?>
</td>
<td><?php
print filter_value($device['site_name'], get_request_var('filter'));
?>
<td><?php
print get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']);
?>
</td>
<td><?php
print filter_value($device['hostname'], get_request_var('filter'));
?>
<td><?php
print $device['device_type'];
?>
</td)>
<td><?php
print $device['scan_type'] == '1' ? __('N/A') : number_format_i18n($device['ips_total']);
?>
</td>
<td><?php
print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_total']);
?>
</td>
<td><?php
print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_active']);
?>
</td>
<td><?php
print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_trunk']);
?>
</td>
<td><?php
print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['macs_active']);
?>
</td>
<td><?php
print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['vlans_total']);
?>
</td>
<td><?php
print number_format($device['last_runduration'], 1);
?>
</td>
</tr>
<?php
}
} else {
print '<tr><td colspan="10"><em>' . __('No MacTrack Devices') . '</em></td></tr>';
}
html_end_box(false);
if (sizeof($devices)) {
print $nav;
mactrack_display_stats();
}
}
示例12: host
//.........这里部分代码省略.........
} else {
$sql_where .= " and (host.status=" . $_REQUEST["host_status"] . " AND host.disabled = '')";
}
if ($_REQUEST["host_template_id"] == "-1") {
/* Show all items */
} elseif ($_REQUEST["host_template_id"] == "0") {
$sql_where .= " and host.host_template_id=0";
} elseif (!empty($_REQUEST["host_template_id"])) {
$sql_where .= " and host.host_template_id=" . $_REQUEST["host_template_id"];
}
html_start_box("", "98%", $colors["header"], "3", "center", "");
$total_rows = db_fetch_cell("select\n\t\tCOUNT(host.id)\n\t\tfrom host\n\t\t{$sql_where}");
$sortby = $_REQUEST["sort_column"];
if ($sortby == "hostname") {
$sortby = "INET_ATON(hostname)";
}
$hosts = db_fetch_assoc("SELECT\n\t\thost.id,\n\t\thost.disabled,\n\t\thost.status,\n\t\thost.hostname,\n\t\thost.description,\n\t\thost.min_time,\n\t\thost.max_time,\n\t\thost.cur_time,\n\t\thost.avg_time,\n\t\thost.availability\n\t\tFROM host\n\t\t{$sql_where}\n\t\tORDER BY " . $sortby . " " . $_REQUEST["sort_direction"] . "\n\t\tLIMIT " . read_config_option("num_rows_device") * ($_REQUEST["page"] - 1) . "," . read_config_option("num_rows_device"));
/* generate page list */
$url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"]);
$nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='7'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< ";
if ($_REQUEST["page"] > 1) {
$nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"] - 1) . "'>";
}
$nav .= "Previous";
if ($_REQUEST["page"] > 1) {
$nav .= "</a>";
}
$nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . (read_config_option("num_rows_device") * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < read_config_option("num_rows_device") * $_REQUEST["page"] ? $total_rows : read_config_option("num_rows_device") * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>";
if ($_REQUEST["page"] * read_config_option("num_rows_device") < $total_rows) {
$nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"] + 1) . "'>";
}
$nav .= "Next";
if ($_REQUEST["page"] * read_config_option("num_rows_device") < $total_rows) {
$nav .= "</a>";
}
$nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n";
print $nav;
$display_text = array("description" => array("Description", "ASC"), "status" => array("Status", "ASC"), "hostname" => array("Hostname", "ASC"), "cur_time" => array("Current (ms)", "DESC"), "avg_time" => array("Average (ms)", "DESC"), "availability" => array("Availability", "ASC"));
html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
$i = 0;
if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
form_alternate_row_color($colors["alternate"], $colors["light"], $i);
$i++;
?>
<td width=250>
<a class="linkEditMain" href="host.php?action=edit&id=<?php
print $host["id"];
?>
"><?php
print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]);
?>
</a>
</td>
<td><?php
print get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]);
?>
</td>
<td><?php
print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["hostname"]);
?>
</td>
<td><?php
print round($host["cur_time"], 2);
?>
</td>
<td><?php
print round($host["avg_time"], 2);
?>
</td>
<td><?php
print round($host["availability"], 2);
?>
%</td>
<td style="<?php
print get_checkbox_style();
?>
" width="1%" align="right">
<input type='checkbox' style='margin: 0px;' name='chk_<?php
print $host["id"];
?>
' title="<?php
print $host["description"];
?>
">
</td>
</tr>
<?php
}
/* put the nav bar on the bottom as well */
print $nav;
} else {
print "<tr><td><em>No Hosts</em></td></tr>";
}
html_end_box(false);
/* add a list of tree names to the actions dropdown */
add_tree_names_to_actions_array();
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($device_actions);
}
示例13: graph_perms_edit
//.........这里部分代码省略.........
}
/* print checkbox form for validation */
print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id')) . "'>\n";
html_start_box('', '100%', '', '3', 'center', '');
$total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(host.id)\n\t\t\tFROM host\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3)\n\t\t\t{$sql_where}");
$host_graphs = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id'), 'host_id', 'graphs');
$host_data_sources = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id'), 'host_id', 'data_sources');
$sql_query = "SELECT host.*, user_auth_perms.user_id\n\t\t\tFROM host \n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3)\n\t\t\t{$sql_where} \n\t\t\tORDER BY description\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
$hosts = db_fetch_assoc($sql_query);
$nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Devices', 'page', 'main');
print $nav;
$display_text = array('Description', 'ID', 'Effective Policy', 'Graphs', 'Data Sources', 'Status', 'Hostname');
html_header_checkbox($display_text, false);
if (sizeof($hosts)) {
foreach ($hosts as $host) {
form_alternate_row('line' . $host['id'], true);
form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['description'])) : htmlspecialchars($host['description']), $host['id']);
form_selectable_cell(round($host['id'], 2), $host['id']);
if (empty($host['user_id']) || $host['user_id'] == NULL) {
if ($policy['policy_hosts'] == 1) {
form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
}
} else {
if ($policy['policy_hosts'] == 1) {
form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
} else {
form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $host['id']);
}
}
form_selectable_cell(isset($host_graphs[$host['id']]) ? $host_graphs[$host['id']] : 0, $host['id']);
form_selectable_cell(isset($host_data_sources[$host['id']]) ? $host_data_sources[$host['id']] : 0, $host['id']);
form_selectable_cell(get_colored_device_status($host['disabled'] == 'on' ? true : false, $host['status']), $host['id']);
form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname']), $host['id']);
form_checkbox_cell($host['description'], $host['id']);
form_end_row();
}
/* put the nav bar on the bottom as well */
print $nav;
} else {
print '<tr><td><em>No Matching Devices Found</em></td></tr>';
}
html_end_box(false);
form_hidden_box('action', 'user_edit', '');
form_hidden_box('tab', $tab, '');
form_hidden_box('id', get_request_var_request('id'), '');
form_hidden_box('associate_host', '1', '');
if ($policy['policy_hosts'] == 1) {
$assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
} else {
$assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
}
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($assoc_actions);
print '</form>';
break;
case 'permste':
process_template_request_vars();
template_filter($header_label);
/* print checkbox form for validation */
print "<form name='policy' method='post' action='user_admin.php'>\n";
/* box: device permissions */
html_start_box('<strong>Default Graph Template Policy</strong>', '100%', '', '3', 'center', '');
?>
<tr class='even'>
示例14: mikrotik_devices
//.........这里部分代码省略.........
$limit = " LIMIT " . $num_rows * (get_request_var_request("page") - 1) . "," . $num_rows;
$sql_where = "";
if ($_REQUEST["status"] != "-1") {
$sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrs.host_status=" . $_REQUEST["status"];
}
$sql_join = "";
if ($_REQUEST["filter"] != "") {
$sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.description LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thost.hostname LIKE '%" . $_REQUEST["filter"] . "%'";
}
$sql = "SELECT hrs.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit;
//echo $sql;
$rows = db_fetch_assoc($sql);
$total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}");
if ($total_rows > 0) {
/* generate page list */
$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, $num_rows, $total_rows, "mikrotik.php" . "?action=devices");
$nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< ";
if (get_request_var_request("page") > 1) {
$nav .= "<a class='linkOverDark' href='" . htmlspecialchars("mikrotik.php" . "?action=devices&page=" . (get_request_var_request("page") - 1)) . "'>";
}
$nav .= "Previous";
if (get_request_var_request("page") > 1) {
$nav .= "</a>";
}
$nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . ($num_rows * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < $num_rows || $total_rows < $num_rows * get_request_var_request("page") ? $total_rows : $num_rows * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>";
if (get_request_var_request("page") * $num_rows < $total_rows) {
$nav .= "<a class='linkOverDark' href='" . htmlspecialchars("mikrotik.php" . "?action=devices&page=" . (get_request_var_request("page") + 1)) . "'>";
}
$nav .= "Next";
if (get_request_var_request("page") * $num_rows < $total_rows) {
$nav .= "</a>";
}
$nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n";
} else {
$nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n";
}
print $nav;
$display_text = array("nosort" => array("Actions", array("ASC", "left")), "description" => array("Name", array("ASC", "left")), "host_status" => array("Status", array("DESC", "right")), "uptime" => array("Uptime(d:h:m)", array("DESC", "right")), "users" => array("Users", array("DESC", "right")), "cpuPercent" => array("CPU %", array("DESC", "right")), "numCpus" => array("CPUs", array("DESC", "right")), "processes" => array("Processes", array("DESC", "right")), "memSize" => array("Total Mem", array("DESC", "right")), "memUsed" => array("Used Mem", array("DESC", "right")), "diskSize" => array("Total Disk", array("DESC", "right")), "diskUsed" => array("Used Disk", array("DESC", "right")));
mikrotik_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=devices");
/* set some defaults */
$url = $config["url_path"] . "plugins/mikrotik/mikrotik.php";
$users = $config["url_path"] . "plugins/mikrotik/images/view_users.gif";
$host = $config["url_path"] . "plugins/mikrotik/images/view_hosts.gif";
$trees = $config["url_path"] . "plugins/mikrotik/images/view_trees.gif";
$dashboard = $config["url_path"] . "plugins/mikrotik/images/view_dashboard.gif";
$graphs = $config["url_path"] . "plugins/mikrotik/images/view_graphs.gif";
$nographs = $config["url_path"] . "plugins/mikrotik/images/view_graphs_disabled.gif";
$hcpudq = read_config_option("mikrotik_dq_host_cpu");
$i = 0;
if (sizeof($rows)) {
foreach ($rows as $row) {
$days = intval($row["uptime"] / (60 * 60 * 24 * 100));
$remainder = $row["uptime"] % (60 * 60 * 24 * 100);
$hours = intval($remainder / (60 * 60 * 100));
$remainder = $remainder % (60 * 60 * 100);
$minutes = intval($remainder / (60 * 100));
$found = db_fetch_cell("SELECT COUNT(*) FROM graph_local WHERE host_id=" . $row["host_id"]);
form_alternate_row_color($colors["alternate"], $colors["light"], $i);
$i++;
echo "<td width='100' align='left'>";
//echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row["host_id"]) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0'></a>";
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row["host_id"]) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0'></a>";
if ($found) {
echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host=" . $row["host_id"] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0'></a>";
} else {
echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>";
}
$graph_cpu = mikrotik_get_graph_url($hcpudq, $row["host_id"], "", $row["numCpus"], false);
$graph_cpup = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_cpu"), $row["host_id"], round($row["cpuPercent"], 2), false);
$graph_users = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_users"), $row["host_id"], $row["users"], false);
$graph_aproc = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_processes"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : $row["processes"], false);
$graph_disk = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_disk"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : round($row["diskUsed"], 2), false);
$graph_mem = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_memory"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : round($row["memUsed"], 2), false);
$graph_upt = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_uptime"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : mikrotik_format_uptime($days, $hours, $minutes), false);
if (api_plugin_user_realm_auth('host.php')) {
$host_url = "<a href='" . htmlspecialchars($config["url_path"] . "host.php?action=edit&id=" . $row["host_id"]) . "' title='Edit Hosts'>" . $row["hostname"] . "</a>";
} else {
$host_url = $row["hostname"];
}
echo "</td>";
echo "<td style='white-space:nowrap;' align='left' width='200'><strong>" . $row["description"] . "</strong> [" . $host_url . "]" . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . get_colored_device_status($row["disabled"] == "on" ? true : false, $row["host_status"]) . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . $graph_upt . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . $graph_users . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . ($row["host_status"] < 2 ? "N/A" : $graph_cpup) . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . ($row["host_status"] < 2 ? "N/A" : $graph_cpu) . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . $graph_aproc . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . mikrotik_memory($row["memSize"]) . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . $graph_mem . " %</td>";
echo "<td style='white-space:nowrap;' align='right'>" . mikrotik_memory($row["diskSize"]) . "</td>";
echo "<td style='white-space:nowrap;' align='right'>" . $graph_disk . " %</td>";
}
echo "</tr>";
print $nav;
} else {
print "<tr><td><em>No Devices Found</em></td></tr>";
}
html_end_box();
}
示例15: mikrotik_devices
//.........这里部分代码省略.........
$num_rows = get_request_var_request('rows');
}
$limit = ' LIMIT ' . $num_rows * (get_request_var_request('page') - 1) . ',' . $num_rows;
$sql_where = '';
if ($_REQUEST['status'] != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . $_REQUEST['status'];
}
$sql_join = '';
if ($_REQUEST['filter'] != '') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " h.description LIKE '%" . $_REQUEST['filter'] . "%' OR\n\t\t\th.hostname LIKE '%" . $_REQUEST['filter'] . "%'";
}
$sql = "SELECT hrs.*, h.hostname, h.description, h.disabled, trees.trees, queues.queues\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h \n\t\tON h.id=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS trees FROM plugin_mikrotik_trees GROUP BY host_id) AS trees\n\t\tON trees.hid=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS queues FROM plugin_mikrotik_queues GROUP BY host_id) AS queues\n\t\tON queues.hid=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit;
//echo $sql;
$rows = db_fetch_assoc($sql);
$total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h\n\t\tON h.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}");
$nav = html_nav_bar('mikrotik.php?action=devices', MAX_DISPLAY_PAGES, get_request_var_request('page'), $num_rows, $total_rows, 15, 'Devices', 'page', 'main');
print $nav;
$display_text = array('nosort' => array('display' => 'Actions', 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => 'Name', 'sort' => 'ASC', 'align' => 'left'), 'host_status' => array('display' => 'Status', 'sort' => 'DESC', 'align' => 'center'), 'firmwareVersion' => array('display' => 'FW Ver', 'sort' => 'DESC', 'align' => 'right'), 'licVersion' => array('display' => 'Lic Ver', 'sort' => 'DESC', 'align' => 'right'), 'uptime' => array('display' => 'Uptime(d:h:m)', 'sort' => 'DESC', 'align' => 'right'), 'trees' => array('display' => 'Trees', 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => 'Users', 'sort' => 'DESC', 'align' => 'right'), 'cpuPercent' => array('display' => 'CPU %', 'sort' => 'DESC', 'align' => 'right'), 'numCpus' => array('display' => 'CPUs', 'sort' => 'DESC', 'align' => 'right'), 'processes' => array('display' => 'Processes', 'sort' => 'DESC', 'align' => 'right'), 'memSize' => array('display' => 'Total Mem', 'sort' => 'DESC', 'align' => 'right'), 'memUsed' => array('display' => 'Used Mem', 'sort' => 'DESC', 'align' => 'right'), 'diskSize' => array('display' => 'Total Disk', 'sort' => 'DESC', 'align' => 'right'), 'diskUsed' => array('display' => 'Used Disk', 'sort' => 'DESC', 'align' => 'right'));
html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 'false');
/* set some defaults */
$url = $config['url_path'] . 'plugins/mikrotik/mikrotik.php';
$users = $config['url_path'] . 'plugins/mikrotik/images/view_users.gif';
$usersn = $config['url_path'] . 'plugins/mikrotik/images/view_users_none.gif';
$host = $config['url_path'] . 'plugins/mikrotik/images/view_hosts.gif';
$trees = $config['url_path'] . 'plugins/mikrotik/images/view_trees.gif';
$treesn = $config['url_path'] . 'plugins/mikrotik/images/view_trees_none.gif';
$queues = $config['url_path'] . 'plugins/mikrotik/images/view_queues.gif';
$queuesn = $config['url_path'] . 'plugins/mikrotik/images/view_queues_none.gif';
$interfaces = $config['url_path'] . 'plugins/mikrotik/images/view_interfaces.gif';
$dashboard = $config['url_path'] . 'plugins/mikrotik/images/view_dashboard.gif';
$graphs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs.gif';
$nographs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs_disabled.gif';
$hcpudq = read_config_option('mikrotik_dq_host_cpu');
if (sizeof($rows)) {
foreach ($rows as $row) {
$days = intval($row['uptime'] / (60 * 60 * 24 * 100));
$remainder = $row['uptime'] % (60 * 60 * 24 * 100);
$hours = intval($remainder / (60 * 60 * 100));
$remainder = $remainder % (60 * 60 * 100);
$minutes = intval($remainder / (60 * 100));
$found = db_fetch_cell('SELECT COUNT(*) FROM graph_local WHERE host_id=' . $row['host_id']);
form_alternate_row();
echo "<td style='white-space:nowrap;min-width:115px;text-align:left;'>";
//echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>";
if ($row['users'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row['host_id']) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$usersn}' title='No Users Found' align='absmiddle' alt=''>";
}
if ($row['queues'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=queues&reset=1&device=" . $row['host_id']) . "'><img src='{$queues}' title='View Simple Queue' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$queuesn}' title='No Simple Queues Found' align='absmiddle' alt=''>";
}
if ($row['trees'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row['host_id']) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$treesn}' title='No Queue Trees Found' align='absmiddle' alt=''>";
}
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=interfaces&reset=1&device=" . $row['host_id']) . "'><img src='{$interfaces}' title='View Interfaces' align='absmiddle' border='0' alt=''></a>";
if ($found) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host_id=" . $row['host_id'] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>";
}
$graph_cpu = mikrotik_get_graph_url($hcpudq, $row['host_id'], '', $row['numCpus'], false);
$graph_cpup = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7df474393f58bae8e8d6b85f10efad71'), $row['host_id'], round($row['cpuPercent'], 2), false);
$graph_users = mikrotik_get_graph_template_url(mikrotik_template_by_hash('99e37ff13139f586d257ba9a637d7340'), $row['host_id'], empty($rows['users']) ? '-' : $row['users'], false);
$graph_aproc = mikrotik_get_graph_template_url(mikrotik_template_by_hash('e797d967db24fd86341a8aa8c60fa9e0'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['processes'], false);
$graph_disk = mikrotik_get_graph_template_url(mikrotik_template_by_hash('0ece13b90785aa04d1f554a093685948'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['diskUsed'], 2), false);
$graph_mem = mikrotik_get_graph_template_url(mikrotik_template_by_hash('4396ae857c4f9bc5ed1f26b5361e42d9'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['memUsed'], 2), false);
$graph_upt = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7d8dc3050621a2cb937cac3895bc5d5b'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : mikrotik_format_uptime($days, $hours, $minutes), false);
if (api_plugin_user_realm_auth('host.php')) {
$host_url = "<a class='hyperLink' href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='Edit Hosts'>" . $row['hostname'] . '</a>';
} else {
$host_url = $row['hostname'];
}
echo '</td>';
echo "<td style='text-align:left;white-space:nowrap;'><strong>" . (strlen($_REQUEST['filter']) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $row['description'] . '</strong> [' . $host_url . ']') : $row['description'] . '</strong> [' . $host_url . ']') . '</td>';
echo "<td style='text-align:center;'>" . get_colored_device_status($row['disabled'] == 'on' ? true : false, $row['host_status']) . '</td>';
echo "<td style='text-align:right;'>" . $row['firmwareVersion'] . '</td>';
echo "<td style='text-align:right;'>" . $row['licVersion'] . '</td>';
echo "<td style='text-align:right;'>" . $graph_upt . '</td>';
echo "<td style='text-align:right;'>" . (!empty($row['trees']) ? $row['trees'] : '-') . '</td>';
echo "<td style='text-align:right;'>" . $graph_users . '</td>';
echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpup) . '</td>';
echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpu) . '</td>';
echo "<td style='text-align:right;'>" . $graph_aproc . '</td>';
echo "<td style='text-align:right;'>" . mikrotik_memory($row['memSize']) . '</td>';
echo "<td style='text-align:right;'>" . $graph_mem . ' %</td>';
echo "<td style='text-align:right;'>" . mikrotik_memory($row['diskSize']) . '</td>';
echo "<td style='text-align:right;'>" . $graph_disk . ' %</td>';
form_end_row();
}
print $nav;
} else {
print '<tr><td colspan="5"><em>No Devices Found</em></td></tr>';
}
html_end_box();
}