本文整理汇总了PHP中generate_device_link函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_device_link函数的具体用法?PHP generate_device_link怎么用?PHP generate_device_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_device_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_port_list
function print_port_list()
{
global $ports;
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Billed Ports</h3>
</div>
<div class="list-group">
<?php
// Collected Earlier
foreach ($ports as $port) {
$portalias = empty($port['ifAlias']) ? '' : ' - ' . $port['ifAlias'] . '';
?>
<div class="list-group-item">
<?php
echo generate_port_link($port, $port['ifName'] . $portalias);
?>
on <?php
echo generate_device_link($port);
?>
</div>
<?php
}
?>
</div>
</div>
<?php
}
示例2: print_vm_row
function print_vm_row($vm, $device = NULL)
{
echo '<tr>';
echo '<td>';
if (getidbyname($vm['vmwVmDisplayName'])) {
echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
} else {
echo $vm['vmwVmDisplayName'];
}
echo "</td>";
echo '<td>' . $vm['vmwVmState'] . "</td>";
if ($vm['vmwVmGuestOS'] == "E: tools not installed") {
echo '<td class="small">Unknown (VMware Tools not installed)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "E: tools not running") {
echo '<td class="small">Unknown (VMware Tools not running)</td>';
} else {
if ($vm['vmwVmGuestOS'] == "") {
echo '<td class="small"><i>(Unknown)</i></td>';
} elseif (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
echo '<td>' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . "</td>";
} else {
echo '<td>' . $vm['vmwVmGuestOS'] . "</td>";
}
}
}
if ($vm['vmwVmMemSize'] >= 1024) {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize'] / 1024) . " GB</td>";
} else {
echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize']) . " MB</td>";
}
echo '<td>' . $vm['vmwVmCpus'] . " CPU</td>";
}
示例3: print_neighbours
/**
* Display neighbours.
*
* Display pages with device neighbours in some formats.
* Examples:
* print_neighbours() - display all neighbours from all devices
* print_neighbours(array('pagesize' => 99)) - display 99 neighbours from all device
* print_neighbours(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 neighbours from page 3 with pagination header
* print_neighbours(array('pagesize' => 10, 'device' = 4)) - display 10 neighbours for device_id 4
*
* @param array $vars
* @return none
*
*/
function print_neighbours($vars)
{
// Get neighbours array
$neighbours = get_neighbours_array($vars);
if (!$neighbours['count']) {
// There have been no entries returned. Print the warning.
print_warning('<h4>No neighbours found!</h4>');
} else {
// Entries have been returned. Print the table.
$list = array('device' => FALSE);
if ($vars['page'] != 'device') {
$list['device'] = TRUE;
}
if (in_array($vars['graph'], array('bits', 'upkts', 'nupkts', 'pktsize', 'percent', 'errors', 'etherlike', 'fdb_count'))) {
$graph_types = array($vars['graph']);
} else {
$graph_types = array('bits', 'upkts', 'errors');
}
$string = generate_box_open($vars['header']);
$string .= '<table class="table table-striped table-hover table-condensed">' . PHP_EOL;
$cols = array(array(NULL, 'class="state-marker"'), 'device_a' => 'Local Device', 'port_a' => 'Local Port', 'NONE' => NULL, 'device_b' => 'Remote Device', 'port_b' => 'Remote Port', 'protocol' => 'Protocol');
if (!$list['device']) {
unset($cols[0], $cols['device_a']);
}
$string .= get_table_header($cols, $vars);
$string .= ' <tbody>' . PHP_EOL;
foreach ($neighbours['entries'] as $entry) {
$string .= ' <tr class="' . $entry['row_class'] . '">' . PHP_EOL;
if ($list['device']) {
$string .= ' <td class="state-marker"></td>';
$string .= ' <td class="entity">' . generate_device_link($entry, NULL, array('tab' => 'ports', 'view' => 'neighbours')) . '</td>' . PHP_EOL;
}
$string .= ' <td><span class="entity">' . generate_port_link($entry) . '</span><br />' . $entry['ifAlias'] . '</td>' . PHP_EOL;
$string .= ' <td><i class="icon-resize-horizontal text-success"></i></td>' . PHP_EOL;
if (is_numeric($entry['remote_port_id']) && $entry['remote_port_id']) {
$remote_port = get_port_by_id_cache($entry['remote_port_id']);
$remote_device = device_by_id_cache($remote_port['device_id']);
$string .= ' <td><span class="entity">' . generate_device_link($remote_device) . '</span><br />' . $remote_device['hardware'] . '</td>' . PHP_EOL;
$string .= ' <td><span class="entity">' . generate_port_link($remote_port) . '</span><br />' . $remote_port['ifAlias'] . '</td>' . PHP_EOL;
} else {
$string .= ' <td><span class="entity">' . $entry['remote_hostname'] . '</span><br />' . $entry['remote_platform'] . '</td>' . PHP_EOL;
$string .= ' <td><span class="entity">' . $entry['remote_port'] . '</span></td>' . PHP_EOL;
}
$string .= ' <td>' . strtoupper($entry['protocol']) . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
$string .= generate_box_close();
// Print pagination header
if ($neighbours['pagination_html']) {
$string = $neighbours['pagination_html'] . $string . $neighbours['pagination_html'];
}
// Print
echo $string;
}
}
示例4: dbFetchRow
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage graphs
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
if (is_numeric($vars['id'])) {
$sensor = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_id` = ?", array($vars['id']));
if (is_numeric($sensor['device_id']) && ($auth || is_entity_permitted($sensor['sensor_id'], 'sensor') || device_permitted($sensor['device_id']))) {
$device = device_by_id_cache($sensor['device_id']);
$rrd_filename = get_rrd_path($device, get_sensor_rrd($device, $sensor));
$title = generate_device_link($device);
$title .= " :: Sensors :: ";
$auth = TRUE;
}
}
// EOF
示例5: foreach
foreach (dbFetchRows($sql) as $service) {
if (device_permitted($service['device_id'])) {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n <strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />\n <strong>" . $service['service_type'] . "</strong><br />\n <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n </center></div>";
}
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
if (device_permitted($peer['device_id'])) {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n <strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />\n <strong>" . $peer['bgpPeerIdentifier'] . "</strong><br />\n <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n </div>";
}
}
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
$sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'";
foreach (dbFetchRows($sql) as $device) {
if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>\n <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />\n <span class=body-date-1>" . formatUptime($device['attrib_value']) . "</span>\n </div>";
}
}
}
echo "\n\n <div style='clear: both;'>{$errorboxes}</div> <div style='margin: 0px; clear: both;'>\n\n<h3>Recent Syslog Messages</h3>\n\n";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
echo "<table cellspacing=0 cellpadding=2 width=100%>";
foreach (dbFetchRows($sql) as $entry) {
include "includes/print-syslog.inc.php";
}
echo "</table>";
echo "</div>\n\n </td>\n <td bgcolor=#e5e5e5 width=470 valign=top>";
// this stuff can be customised to show whatever you want....
if ($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
unset($seperator);
示例6: foreach
}
foreach (dbFetchRows($sql) as $peer) {
generate_front_box('bgp-down', generate_device_link($peer, shorthost($peer['hostname'])) . "<br />\n <span class=bgp-down>BGP Down</span>\n <span class='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'front-page-bgp-small' : 'front-page-bgp-normal') . "'>" . $peer['bgpPeerIdentifier'] . '</span><br />
<span class=body-date-1>AS' . truncate($peer['bgpPeerRemoteAs'] . ' ' . $peer['astext'], 14, '') . '</span>');
++$count_boxes;
}
}
// Device rebooted boxes
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) {
if (is_admin() === true || is_read() === true) {
$sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
} else {
$sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
}
foreach (dbFetchRows($sql) as $device) {
generate_front_box('device-rebooted', generate_device_link($device, shorthost($device['hostname'])) . '<br />
<span class=device-rebooted>Device Rebooted</span><br />
<span class=body-date-1>' . formatUptime($device['uptime'], 'short') . '</span>');
++$count_boxes;
}
}
if ($count_boxes == 0) {
echo "<h5>Nothing here yet</h5><p class=welcome>This is where status notifications about devices and services would normally go. You might have none\n because you run such a great network, or perhaps you've just started using " . $config['project_name'] . ". If you're new to " . $config['project_name'] . ', you might
want to start by adding one or more devices in the Devices menu.</p>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '
</div>
</div>
示例7: get_status_array
function get_status_array($status)
{
// Mike: I know that there are duplicated variables, but later will remove global
global $config, $cache;
$max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
$max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
$query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
$query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
// Show Device Status
if ($status['devices']) {
$query = 'SELECT * FROM `devices` AS D ';
$query .= 'WHERE D.`status` = 0' . $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
foreach ($entries as $device) {
$boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
}
}
// Uptime
if ($status['uptime']) {
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
$query = 'SELECT * FROM `devices` AS D ';
$query .= 'WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
$query .= $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
foreach ($entries as $device) {
$boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
}
}
}
// Ports Down
if ($status['ports'] || $status['links']) {
// warning about deprecated option: $config['warn']['ifdown']
if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
print_warning("<strong>Config option obsolete</strong>\n Please note that config option <strong>\$config['warn']['ifdown']</strong> is now obsolete.\n Use options: <strong>\$config['frontpage']['device_status']['ports']</strong> and <strong>\$config['frontpage']['device_status']['errors']</strong>\n To remove this message, delete <strong>\$config['warn']['ifdown']</strong> from configuration file.");
}
$query = 'SELECT * FROM `ports` AS I ';
if ($status['links'] && !$status['ports']) {
$query .= 'INNER JOIN `links` as L ON I.`port_id` = L.`local_port_id` ';
}
$query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
$query .= "WHERE I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up' ";
if ($status['links'] && !$status['ports']) {
$query .= ' AND L.`active` = 1 ';
}
$query .= $query_port_permitted;
$query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
$query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
$entries = dbFetchRows($query);
$i = 1;
foreach ($entries as $port) {
if ($i > $max_count) {
// Limit to 200 ports on overview page
break;
}
humanize_port($port);
$boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, short_hostname($port['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
}
}
// Ports Errors (only deltas)
if ($status['errors']) {
foreach ($cache['ports']['errored'] as $port_id) {
$port = get_port_by_id($port_id);
$device = device_by_id_cache($port['device_id']);
humanize_port($port);
if ($port['ifInErrors_delta']) {
$port['string'] .= 'Rx: ' . format_number($port['ifInErrors_delta']);
}
if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
$port['string'] .= ', ';
}
if ($port['ifOutErrors_delta']) {
$port['string'] .= 'Tx: ' . format_number($port['ifOutErrors_delta']);
}
$boxes[] = array('sev' => 75, 'class' => 'Port', 'event' => 'Errors', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => $port['string'], 'location' => $device['location']);
}
}
// Services
if ($status['services']) {
$query = 'SELECT * FROM `services` AS S ';
$query .= 'LEFT JOIN `devices` AS D ON S.device_id = D.device_id ';
$query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
$query .= $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
foreach ($entries as $service) {
$boxes[] = array('sev' => 50, 'class' => 'Service', 'event' => 'Down', 'device_link' => generate_device_link($service, short_hostname($service['hostname'])), 'entity_link' => $service['service_type'], 'time' => formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short'), 'location' => $device['location']);
}
}
// BGP
if ($status['bgp']) {
if (isset($config['enable_bgp']) && $config['enable_bgp']) {
$query = 'SELECT * FROM `devices` AS D ';
$query .= 'LEFT JOIN `bgpPeers` AS B ON B.`device_id` = D.`device_id` ';
$query .= 'LEFT JOIN `bgpPeers-state` AS BS ON B.`bgpPeer_id` = BS.`bgpPeer_id` ';
$query .= "WHERE (`bgpPeerAdminStatus` = 'start' OR `bgpPeerAdminStatus` = 'running') AND `bgpPeerState` != 'established' ";
$query .= $query_device_permitted;
$query .= 'ORDER BY D.`hostname` ASC';
$entries = dbFetchRows($query);
//.........这里部分代码省略.........
示例8: foreach
$x = 1;
foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) {
if ($i % 2) {
if ($x % 2) {
$dev_colour = $list_colour_a_a;
} else {
$dev_colour = $list_colour_a_b;
}
} else {
if ($x % 2) {
$dev_colour = $list_colour_b_b;
} else {
$dev_colour = $list_colour_b_a;
}
}
echo "<tr bgcolor='{$dev_colour}'><td width=150>" . generate_device_link($device, shorthost($device['hostname']));
if ($device['vrf_name'] != $vrf['vrf_name']) {
echo "<a href='#' onmouseover=\" return overlib('Expected Name : " . $vrf['vrf_name'] . '<br />Configured : ' . $device['vrf_name'] . "', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>";
}
echo '</td><td>';
unset($seperator);
foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) {
$port = array_merge($device, $port);
switch ($_GET['optc']) {
case 'bits':
case 'upkts':
case 'nupkts':
case 'errors':
$port['width'] = '130';
$port['height'] = '30';
$port['from'] = $config['time']['day'];
示例9: unset
unset($class);
$port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']);
$port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if ($bg == "#ffffff") {
$bg = "#e5e5e5";
} else {
$bg = "#ffffff";
}
echo "<tr class='iftype'>\n <td><span class=entity-title>" . generate_port_link($port, $port['port_descr_descr']) . "</span>";
# <span class=small style='float: left;'>".generate_device_link($port)." ".generate_port_link($port)." </span>");
if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) {
echo "<span style='float: right;'><a href='device/device=" . $port['device_id'] . "/tab=port/port=" . $port['port_id'] . "/view=macaccounting/'><img src='images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
}
echo "</td>";
echo ' <td style="width: 150px;" class="strong">' . generate_device_link($port) . '</td>
<td style="width: 150px;" class="strong">' . generate_port_link($port, short_ifname($port['ifDescr'])) . '</td>
<td style="width: 75px;">' . $port['port_descr_speed'] . '</td>
<td style="width: 150px;">' . $port['port_descr_circuit'] . '</td>
<td>' . $port['port_descr_notes'] . '</td>';
echo '</tr><tr><td colspan="6">';
$rrdfile = get_port_rrdfilename($port, NULL, TRUE);
if (file_exists($rrdfile)) {
$graph_type = "port_bits";
include "includes/print-interface-graphs.inc.php";
}
echo "</td></tr>";
}
} else {
echo "None found.</td></tr>";
}
示例10: unix_timestamp
<?php
/*
* LibreNMS front page top ports graph
* - Find most utilised ports that have been polled in the last N minutes
*
* Author: Paul Gear
* Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$minutes = 15;
$seconds = $minutes * 60;
$top = $config['front_page_settings']['top']['ports'];
if (is_admin() === true || is_read() === true) {
$query = "\n SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total\n FROM ports as p, devices as d\n WHERE d.device_id = p.device_id\n AND unix_timestamp() - p.poll_time < {$seconds}\n AND ( p.ifInOctets_rate > 0\n OR p.ifOutOctets_rate > 0 )\n ORDER BY total desc\n LIMIT {$top}\n ";
} else {
$query = "\n SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total\n FROM ports as I, devices as d,\n `devices_perms` AS `P`, `ports_perms` AS `PP`\n WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `d`.`device_id`)) AND\n d.device_id = I.device_id\n AND unix_timestamp() - I.poll_time < {$seconds}\n AND ( I.ifInOctets_rate > 0\n OR I.ifOutOctets_rate > 0 )\n ORDER BY total desc\n LIMIT {$top}\n ";
$param[] = array($_SESSION['user_id'], $_SESSION['user_id']);
}
//end if
echo "<strong>Top {$top} ports (last {$minutes} minutes)</strong>\n";
echo "<table class='simple'>\n";
foreach (dbFetchRows($query, $param) as $result) {
echo '<tr class=top10>' . '<td class=top10>' . generate_device_link($result, shorthost($result['hostname'])) . '</td>' . '<td class=top10>' . generate_port_link($result) . '</td>' . '<td class=top10>' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>' . "</tr>\n";
}
echo "</table>\n";
示例11: foreach
foreach ($cache['devices']['hostname'] as $hostname => $id) {
// Reference the cache.
$device =& $cache['devices']['id'][$id];
if ($device['disabled'] == 1 && !$config['web_show_disabled']) {
continue;
}
// Find max poller/discovery times
if ($device['last_polled_timetaken'] > $proc['max']['poller']) {
$proc['max']['poller'] = $device['last_polled_timetaken'];
}
if ($device['last_discovered_timetaken'] > $proc['max']['discovery']) {
$proc['max']['discovery'] = $device['last_discovered_timetaken'];
}
$proc['avg2']['poller'] += pow($device['last_polled_timetaken'], 2);
$proc['avg2']['discovery'] += pow($device['last_discovered_timetaken'], 2);
$poller_table[] = array('html_row_class' => $device['html_row_class'], 'html_tab_colour' => $device['html_tab_colour'], 'device_hostname' => $device['hostname'], 'device_link' => generate_device_link($device), 'last_polled_timetaken' => $device['last_polled_timetaken'], 'last_polled' => $device['last_polled'], 'last_discovered_timetaken' => $device['last_discovered_timetaken'], 'last_discovered' => $device['last_discovered']);
}
// Sort poller table
// sort order: $polled > $discovered > $hostname
$poller_table = array_sort_by($poller_table, 'last_polled_timetaken', SORT_DESC, SORT_NUMERIC, 'last_discovered_timetaken', SORT_DESC, SORT_NUMERIC, 'device_hostname', SORT_ASC, SORT_STRING);
// Print poller table
foreach ($poller_table as $row) {
$proc['time']['poller'] = round($row['last_polled_timetaken'] * 100 / $proc['max']['poller']);
$proc['color']['poller'] = "success";
if ($row['last_polled_timetaken'] > $proc['max']['poller'] * 0.75) {
$proc['color']['poller'] = "danger";
} elseif ($row['last_polled_timetaken'] > $proc['max']['poller'] * 0.5) {
$proc['color']['poller'] = "warning";
} elseif ($row['last_polled_timetaken'] >= $proc['max']['poller'] * 0.25) {
$proc['color']['poller'] = "info";
}
示例12: foreach
$sql = 'SELECT * FROM `bgpPeers` AS B
LEFT JOIN `bgpPeers-state` AS S ON B.bgpPeer_id = S.bgpPeer_id
WHERE `device_id` = ? ' . $where . '
ORDER BY `bgpPeerRemoteAs`, `bgpPeerRemoteAddr`';
foreach (dbFetchRows($sql, array($device['device_id'])) as $peer) {
$peer['bgpLocalAs'] = $device['bgpLocalAs'];
humanize_bgp($peer);
$has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM mac_accounting AS M\n LEFT JOIN `ip_mac` AS I ON M.mac = I.mac_address\n WHERE I.ip_address = ?", array($peer['bgpPeerRemoteAddr']));
unset($peerhost, $peername);
$ip_version = strstr($peer['bgpPeerRemoteAddr'], ':') ? 'ipv6' : 'ipv4';
$peerhost = dbFetchRow('SELECT * FROM ' . $ip_version . '_addresses AS A
LEFT JOIN ports AS I ON A.port_id = I.port_id
LEFT JOIN devices AS D ON I.device_id = D.device_id
WHERE A.' . $ip_version . '_address = ?', array($peer['bgpPeerRemoteAddr']));
if ($peerhost['device_id']) {
$peername = generate_device_link($peerhost, short_hostname($peerhost['hostname']), array('tab' => 'routing', 'proto' => 'bgp'));
$peer['remote_id'] = $peerhost['device_id'];
} else {
$peername = $peer['reverse_dns'];
}
unset($sep);
foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?", array($device['device_id'], $peer['bgpPeerRemoteAddr'])) as $afisafi) {
$afi = $afisafi['afi'];
$safi = $afisafi['safi'];
$this_afisafi = $afi . $safi;
$peer['afi'] .= $sep . $afi . "." . $safi;
$sep = "<br />";
$peer['afisafi'][$this_afisafi] = 1;
// Build a list of valid AFI/SAFI for this peer
}
$graph_type = "bgp_updates";
示例13: foreach
foreach (dbFetchRows($sql, $param) as $alertlog) {
$dev = device_by_id_cache($alertlog['device_id']);
$fault_detail = alert_details($alertlog['details']);
$alert_state = $alertlog['state'];
if ($alert_state == '0') {
$fa_icon = 'check';
$fa_color = 'success';
$text = 'Ok';
} elseif ($alert_state == '1') {
$fa_icon = 'times';
$fa_color = 'danger';
$text = 'Alert';
} elseif ($alert_state == '2') {
$fa_icon = 'info-circle';
$fa_color = 'muted';
$text = 'Ack';
} elseif ($alert_state == '3') {
$fa_icon = 'arrow-down';
$fa_color = 'warning';
$text = 'Worse';
} elseif ($alert_state == '4') {
$fa_icon = 'arrow-up';
$fa_color = 'info';
$text = 'Better';
}
//end if
$response[] = array('id' => $rulei++, 'time_logged' => $alertlog['humandate'], 'details' => '<a class="fa fa-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident' . $rulei . '" data-parent="#alerts"></a>', 'hostname' => '<div class="incident">' . generate_device_link($dev, shorthost($dev['hostname'])) . '<div id="incident' . $rulei . '" class="collapse">' . $fault_detail . '</div></div>', 'alert' => htmlspecialchars($alertlog['alert']), 'status' => "<b><i class='fa fa-" . $fa_icon . " text-" . $fa_color . "'></i> {$text}</b>");
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
示例14: foreach
LIMIT :count
';
}
$common_output[] = '
<h4>Top ' . $interface_count . ' interfaces polled within ' . $interval . ' minutes</h4>
<div class="table-responsive">
<table class="table table-hover table-condensed table-striped bootgrid-table">
<thead>
<tr>
<th class="text-left">Device</th>
<th class="text-left">Interface</th>
<th class="text-left">Total traffic</a></th>
</tr>
</thead>
<tbody>
';
foreach (dbFetchRows($query, $params) as $result) {
$common_output[] = '
<tr>
<td class="text-left">' . generate_device_link($result, shorthost($result['hostname'])) . '</td>
<td class="text-left">' . generate_port_link($result, shorten_interface_type($result['ifName'])) . '</td>
<td class="text-left">' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>
</tr>
';
}
$common_output[] = '
</tbody>
</table>
</div>
';
}
示例15: generate_printersupplies_row
function generate_printersupplies_row($supply, $vars)
{
$graph_type = "printersupply_usage";
$table_cols = 5;
$total = $supply['supply_capacity'];
$perc = $supply['supply_value'];
$graph_array['type'] = $graph_type;
$graph_array['id'] = $supply['supply_id'];
$graph_array['from'] = $GLOBALS['config']['time']['day'];
$graph_array['to'] = $GLOBALS['config']['time']['now'];
$graph_array['height'] = "20";
$graph_array['width'] = "80";
if ($supply['supply_colour'] != '') {
$background = toner_to_colour($supply['supply_colour'], $perc);
} else {
$background = toner_to_colour($supply['supply_descr'], $perc);
}
/// FIXME - popup for printersupply entity.
$output .= '<tr class="' . $supply['html_row_class'] . '">';
$output .= '<td class="state-marker"></td>';
if ($vars['popup'] == TRUE) {
$output .= '<td style="width: 40px; text-align: center;"><i class="' . $GLOBALS['config']['entities']['printersupply']['icon'] . '"></i></td>';
} else {
$output .= '<td style="width: 1px;"></td>';
}
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$output .= '<td class="entity">' . generate_device_link($supply) . '</td>';
$table_cols++;
}
$output .= '<td class="entity">' . generate_entity_link('printersupply', $supply) . '</td>';
if (!isset($vars['supply'])) {
$output .= '<td>' . nicecase($supply['supply_type']) . '</td>';
}
$output .= '<td style="width: 70px;">' . generate_graph_popup($graph_array) . '</td>';
$output .= '<td style="width: 200px;"><a href="' . $link . '">' . print_percentage_bar(400, 20, $perc, $perc . '%', 'ffffff', $background['right'], NULL, "ffffff", $background['left']) . '</a></td>';
$output .= '<td style="width: 50px; text-align: right;"><span class="label">' . $perc . '%</span></td>';
$output .= '</tr>';
if ($vars['view'] == "graphs") {
$output .= '<tr class="' . $supply['html_row_class'] . '">';
$output .= '<td class="state-marker"></td>';
$output .= '<td colspan=' . $table_cols . '>';
unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $supply['supply_id'];
$graph_array['type'] = $graph_type;
$output .= generate_graph_row($graph_array, TRUE);
$output .= "</td></tr>";
}
# endif graphs
return $output;
}