本文整理汇总了PHP中get_port_by_id_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP get_port_by_id_cache函数的具体用法?PHP get_port_by_id_cache怎么用?PHP get_port_by_id_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_port_by_id_cache函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
开发者ID:Natolumin,项目名称:observium,代码行数:71,代码来源:neighbours.inc.php
示例2: port_by_id_cache
function port_by_id_cache($port_id)
{
return get_port_by_id_cache('port', $port_id);
}
开发者ID:BillTheBest,项目名称:librenms,代码行数:4,代码来源:common.php
示例3: log_event
function log_event($text, $device = NULL, $type = NULL, $reference = NULL, $severity = 6)
{
if (!is_array($device)) {
$device = device_by_id_cache($device);
}
if ($device['ignore'] && $type != 'device') {
return FALSE;
}
// Do not log events if device ignored
if ($type == 'port') {
if (is_array($reference)) {
$port = $reference;
$reference = $port['port_id'];
} else {
$port = get_port_by_id_cache($reference);
}
if ($port['ignore']) {
return FALSE;
}
// Do not log events if interface ignored
}
$severity = priority_string_to_numeric($severity);
// Convert named severities to numeric
if ($type == 'device' && $severity == 5 || isset($_SESSION['username'])) {
$severity = $severity == 6 ? 5 : $severity;
// If severity default, change to notification
if (isset($_SESSION['username'])) {
$text .= ' (用户: ' . $_SESSION['username'] . ')';
} else {
if (is_cli()) {
if (is_cron()) {
$text .= ' (自动运行)';
} else {
$text .= ' (控制台)';
}
}
}
}
$insert = array('device_id' => $device['device_id'] ? $device['device_id'] : "NULL", 'entity_id' => is_numeric($reference) ? $reference : array('NULL'), 'entity_type' => $type ? $type : array('NULL'), 'timestamp' => array("NOW()"), 'severity' => $severity, 'message' => $text);
$id = dbInsert($insert, 'eventlog');
return $id;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:42,代码来源:functions.inc.php
示例4: log_event
function log_event($text, $device = NULL, $type = NULL, $reference = NULL)
{
if (!is_array($device)) {
$device = device_by_id_cache($device);
}
if ($device['ignore'] && $type != 'device') {
return FALSE;
}
// Do not log events if device ignored
if ($type == 'port') {
if (is_array($reference)) {
$port = $reference;
$reference = $port['port_id'];
} else {
$port = get_port_by_id_cache($reference);
}
if ($port['ignore']) {
return FALSE;
}
// Do not log events if interface ignored
}
if ($type == 'device') {
// For events with type 'device' add info about username or cli
if (isset($_SESSION['username'])) {
$text .= ' (by user: ' . $_SESSION['username'] . ')';
} else {
if (is_cli()) {
if (is_cron()) {
$text .= ' (by cron)';
} else {
$text .= ' (by console)';
}
}
}
}
$insert = array('device_id' => $device['device_id'] ? $device['device_id'] : "NULL", 'reference' => $reference ? $reference : "NULL", 'type' => $type ? $type : "NULL", 'timestamp' => array("NOW()"), 'message' => $text);
$id = dbInsert($insert, 'eventlog');
return $id;
}
开发者ID:skive,项目名称:observium,代码行数:39,代码来源:functions.inc.php
示例5: var_dump
var_dump($GLOBALS['cache']['discovery-protocols']);
}
$table_rows = array();
$neighbours_db = dbFetchRows('SELECT * FROM `neighbours` LEFT JOIN `ports` USING(`port_id`) WHERE `device_id` = ?', array($device['device_id']));
foreach ($neighbours_db as $neighbour) {
$local_port_id = $neighbour['port_id'];
$remote_hostname = $neighbour['remote_hostname'];
$remote_port = $neighbour['remote_port'];
print_debug("{$local_port_id} -> {$remote_hostname} -> {$remote_port}");
if (!$valid['neighbours'][$local_port_id][$remote_hostname][$remote_port]) {
dbDelete('neighbours', '`neighbour_id` = ?', array($neighbour['neighbour_id']));
$GLOBALS['module_stats'][$module]['deleted']++;
} else {
$port = get_port_by_id_cache($local_port_id);
if (is_numeric($neighbour['remote_port_id'])) {
$remote_port_array = get_port_by_id_cache($neighbour['remote_port_id']);
$remote_port = $remote_port_array['port_label'];
}
$table_rows[] = array(nicecase($neighbour['protocol']), $port['port_label'], $remote_hostname, $remote_port, truncate($neighbour['remote_platform'], 20), truncate($neighbour['remote_version'], 40));
}
}
echo PHP_EOL;
$table_headers = array('%WProtocol%n', '%WifName%n', '%WRemote: hostname%n', '%Wport%n', '%Wplatform%n', '%Wversion%n');
print_cli_table($table_rows, $table_headers);
$GLOBALS['module_stats'][$module]['status'] = count($valid[$module]);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) {
print_vars($valid[$module]);
}
unset($valid['neighbours']);
echo PHP_EOL;
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:neighbours.inc.php
示例6: dbFetchRows
$query .= 'LEFT JOIN `ports` ON `A`.`port_id` = `ports`.`port_id` ';
$query .= 'WHERE deleted=0 ';
$query .= $where;
$query .= ' ORDER BY A.`ipv4_address` LIMIT 8';
# $debug=1;
// Query addresses
$results = dbFetchRows($query, $param);
if (count($results)) {
$found = 1;
foreach ($results as $result) {
$addr_ports[$result['port_id']][] = $result;
}
echo '<li class="nav-header">IPs found: ' . count($results) . ' (on ' . count($addr_ports) . ' ports)</li>';
# foreach ($addr_ports as $port_id => $result)
foreach ($results as $result) {
$port = get_port_by_id_cache($result['port_id']);
$device = device_by_id_cache($port['device_id']);
echo '<li class="divider" style="margin: 0px;"></li>';
echo '<li>';
echo '<a href="' . generate_port_url($port) . '">';
$descr = $device['hostname'] . ' | ' . rewrite_ifname($port['label']);
$name = $result['ipv4_address'] . '/' . $result['ipv4_prefixlen'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
/// FIXME: once we have alerting, colour this to the sensor's status
$tab_colour = '#194B7F';
// FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?
echo '<dl style="border-left: 10px solid ' . $tab_colour . '; " class="dl-horizontal dl-search">
<dt style="padding-left: 10px; text-align: center;">
<i class="oicon-magnifier-zoom-actual"></i></dt>
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:ajax_search.php
示例7: discover_neighbour
function discover_neighbour($protocol, $local_port_id, $neighbour)
{
$port = get_port_by_id_cache($local_port_id);
print_debug("Discover neighbour: " . $port['device_id'] . " -> {$protocol}, {$local_port_id}, " . implode(', ', $neighbour));
$neighbour['protocol'] = $protocol;
$params = array('protocol', 'remote_port_id', 'remote_hostname', 'remote_port', 'remote_platform', 'remote_version', 'remote_address');
$neighbour_db = dbFetchRow("SELECT * FROM `neighbours` WHERE `port_id` = ? AND `protocol` = ? AND `remote_hostname` = ? AND `remote_port` = ?", array($local_port_id, $protocol, $neighbour['remote_hostname'], $neighbour['remote_port']));
if (!isset($neighbour_db['neighbour_id'])) {
$update = array('port_id' => $local_port_id);
foreach ($params as $param) {
$update[$param] = $neighbour[$param];
if ($neighbour[$param] == NULL) {
$update[$param] = array('NULL');
}
}
$id = dbInsert($update, 'neighbours');
$GLOBALS['module_stats']['neighbours']['added']++;
//echo('+');
} else {
$update = array();
foreach ($params as $param) {
if (dbEscape($neighbour[$param]) != $neighbour_db[$param]) {
$update[$param] = $neighbour[$param];
}
}
if (count($update)) {
dbUpdate($update, 'neighbours', '`neighbour_id` = ?', array($neighbour_db['neighbour_id']));
$GLOBALS['module_stats']['neighbours']['updated']++;
//echo('U');
} else {
$GLOBALS['module_stats']['neighbours']['unchanged']++;
//echo('.');
}
}
$GLOBALS['valid']['neighbours'][$local_port_id][$neighbour['remote_hostname']][$neighbour['remote_port']] = 1;
}
开发者ID:Natolumin,项目名称:observium,代码行数:36,代码来源:functions.inc.php
示例8: generate_port_row
//.........这里部分代码省略.........
foreach (dbFetchColumn('SELECT DISTINCT(`ipv4_network_id`) FROM `ipv4_addresses`
LEFT JOIN `ipv4_networks` USING(`ipv4_network_id`)
WHERE `port_id` = ? AND `ipv4_network` NOT IN (?);', array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
$sql = 'SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv4_addresses` AS A, `ipv4_networks` AS N, `ports` AS P
WHERE A.`port_id` = P.`port_id` AND P.`device_id` != ?
AND A.`ipv4_network_id` = ? AND N.`ipv4_network_id` = A.`ipv4_network_id`
AND P.`ifAdminStatus` = "up"';
$params = array($device['device_id'], $network_id);
foreach (dbFetchRows($sql, $params) as $new) {
if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
continue;
}
$int_links[$new['port_id']] = $new['port_id'];
$int_links_v4[$new['port_id']][] = $new['ipv4_network'];
}
}
}
// Populate links array for devices which share an IPv6 subnet
if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
foreach (dbFetchColumn("SELECT DISTINCT(`ipv6_network_id`) FROM `ipv6_addresses`\n LEFT JOIN `ipv6_networks` USING(`ipv6_network_id`)\n WHERE `port_id` = ? AND `ipv6_network` NOT IN (?);", array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
$sql = "SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv6_addresses` AS A, `ipv6_networks` AS N, `ports` AS P\n WHERE A.`port_id` = P.`port_id` AND P.device_id != ?\n AND A.`ipv6_network_id` = ? AND N.`ipv6_network_id` = A.`ipv6_network_id`\n AND P.`ifAdminStatus` = 'up' AND A.`ipv6_origin` != 'linklayer' AND A.`ipv6_origin` != 'wellknown'";
$params = array($device['device_id'], $network_id);
foreach (dbFetchRows($sql, $params) as $new) {
if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
continue;
}
$int_links[$new['port_id']] = $new['port_id'];
$int_links_v6[$new['port_id']][] = $new['ipv6_network'];
}
}
}
// Output contents of links array
foreach ($int_links as $int_link) {
$link_if = get_port_by_id_cache($int_link);
if (!device_permitted($link_if['device_id'])) {
continue;
}
// Skip not permitted links
$link_dev = device_by_id_cache($link_if['device_id']);
$string .= $br;
if ($int_links_phys[$int_link]) {
$string .= '<a data-alt="Directly connected" class="oicon-connect"></a> ';
} else {
$string .= '<a data-alt="Same subnet" class="oicon-network-hub"></a> ';
}
$string .= '<b>' . generate_port_link($link_if, $link_if['port_label_short']) . ' on ' . generate_device_link($link_dev, short_hostname($link_dev['hostname'])) . '</b>';
## FIXME -- do something fancy here.
if ($int_links_v6[$int_link]) {
$string .= ' ' . overlib_link('', '<span class="label label-success">IPv6</span>', implode("<br />", $int_links_v6[$int_link]), NULL);
}
if ($int_links_v4[$int_link]) {
$string .= ' ' . overlib_link('', '<span class="label label-info">IPv4</span>', implode("<br />", $int_links_v4[$int_link]), NULL);
}
$br = "<br />";
}
// Output content of unknown links array (where ports don't exist in our database, or they weren't matched)
foreach ($int_links_unknown as $int_link) {
// FIXME -- Expose platform and version here.
$string .= '<a data-alt="Directly connected" class="oicon-plug-connect"></a> ';
$string .= '<b><i>' . short_ifname($int_link['remote_port']) . '</i></b> on ';
$string .= '<i><b>' . generate_tooltip_link(NULL, $int_link['remote_hostname'], '<div class="small" style="max-width: 500px;"><b>' . $int_link['remote_platform'] . '</b><br />' . $int_link['remote_version'] . '</div>') . '</b></i>';
$string .= '<br />';
}
}
if (!isset($cache['ports_option']['pseudowires']) || in_array($port['port_id'], $cache['ports_option']['pseudowires'])) {
foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
开发者ID:Natolumin,项目名称:observium,代码行数:67,代码来源:port.inc.php
示例9: print_events
/**
* Display events.
*
* Display pages with device/port/system events on some formats.
* Examples:
* print_events() - display last 10 events from all devices
* print_events(array('pagesize' => 99)) - display last 99 events from all device
* print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header
* print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4
* print_events(array('short' => TRUE)) - show small block with last events
*
* @param array $vars
* @return none
*
*/
function print_events($vars)
{
// Get events array
$events = get_events_array($vars);
if (!$events['count']) {
// There have been no entries returned. Print the warning.
print_warning('<h4>No eventlog entries found!</h4>');
} else {
// Entries have been returned. Print the table.
$list = array('device' => FALSE, 'port' => FALSE);
if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'eventlog') {
$list['device'] = TRUE;
}
if ($events['short'] || !isset($vars['port']) || empty($vars['port'])) {
$list['port'] = TRUE;
}
$string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
if (!$events['short']) {
$string .= ' <thead>' . PHP_EOL;
$string .= ' <tr>' . PHP_EOL;
$string .= ' <th>Date</th>' . PHP_EOL;
if ($list['device']) {
$string .= ' <th>Device</th>' . PHP_EOL;
}
if ($list['port']) {
$string .= ' <th>Entity</th>' . PHP_EOL;
}
$string .= ' <th>Message</th>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' <tbody>' . PHP_EOL;
foreach ($events['entries'] as $entry) {
$icon = geteventicon($entry['message']);
if ($icon) {
$icon = '<img src="images/16/' . $icon . '" />';
}
$string .= ' <tr>' . PHP_EOL;
if ($events['short']) {
$string .= ' <td class="syslog" style="white-space: nowrap">';
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
$string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
} else {
$string .= ' <td style="width: 160px">';
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
}
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
$string .= ' <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
}
if ($list['port']) {
if ($entry['type'] == 'port') {
$this_if = get_port_by_id_cache($entry['reference']);
$entry['link'] = '<span class="entity">' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
} else {
$entry['link'] = ucfirst($entry['type']);
}
if (!$events['short']) {
$string .= ' <td>' . $entry['link'] . '</td>' . PHP_EOL;
}
}
if ($events['short']) {
$string .= ' <td class="syslog">' . $entry['link'] . ' ';
} else {
$string .= ' <td>';
}
$string .= htmlspecialchars($entry['message']) . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
// Print pagination header
if ($events['pagination_html']) {
$string = $events['pagination_html'] . $string . $events['pagination_html'];
}
// Print events
echo $string;
}
}
开发者ID:skive,项目名称:observium,代码行数:95,代码来源:events.inc.php
示例10: log_event
function log_event($text, $device = NULL, $type = NULL, $reference = NULL)
{
if (!is_array($device)) {
$device = device_by_id_cache($device);
}
if ($device['ignore']) {
return FALSE;
}
// Do not log events if device ignored
if ($type == 'interface') {
if (is_array($reference)) {
$port = $reference;
$reference = $port['port_id'];
} else {
$port = get_port_by_id_cache($reference);
}
if ($port['ignore']) {
return FALSE;
}
// Do not log events if interface ignored
}
$insert = array('device_id' => $device['device_id'] ? $device['device_id'] : "NULL", 'reference' => $reference ? $reference : "NULL", 'type' => $type ? $type : "NULL", 'timestamp' => array("NOW()"), 'message' => $text);
$id = dbInsert($insert, 'eventlog');
return $id;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:25,代码来源:functions.php
示例11: get_pseudowires_array
/**
* Params:
*
* pagination, pageno, pagesize
* device, port
*/
function get_pseudowires_array($vars)
{
$array = array();
// With pagination? (display page numbers in header)
$array['pagination'] = isset($vars['pagination']) && $vars['pagination'];
pagination($vars, 0, TRUE);
// Get default pagesize/pageno
$array['pageno'] = $vars['pageno'];
$array['pagesize'] = $vars['pagesize'];
$start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
$pagesize = $array['pagesize'];
// Begin query generate
$param = array();
$where = ' WHERE 1 ';
foreach ($vars as $var => $value) {
if ($value != '') {
switch ($var) {
case 'device':
case 'device_a':
$where .= generate_query_values($value, 'device_id');
break;
case 'port':
case 'port_a':
$where .= generate_query_values($value, 'port_id');
break;
//case 'type':
// $where .= generate_query_values($value, 'type');
// break;
//case 'message':
// $where .= generate_query_values($value, 'message', '%LIKE%');
// break;
}
}
}
// Show pseudowires only for permitted devices and ports
$query_permitted = generate_query_permitted(array('device', 'port'));
$query = 'FROM `pseudowires` ';
$query .= $where . $query_permitted;
$query_count = 'SELECT COUNT(*) ' . $query;
//$query_updated = 'SELECT MAX(`timestamp`) '.$query;
$query = 'SELECT * ' . $query;
//$query .= ' ORDER BY `event_id` DESC ';
$query .= " LIMIT {$start},{$pagesize}";
// Query pseudowires
foreach (dbFetchRows($query, $param) as $entry) {
if ($entry['peer_addr']) {
$peer_addr = $entry['peer_addr'];
} else {
if ($entry['pwMplsPeerLdpID']) {
$peer_addr = preg_replace('/:\\d+$/', '', $pw['pwMplsPeerLdpID']);
}
}
$peer_addr_type = get_ip_version($peer_addr);
if ($peer_addr_type) {
if ($peer_addr_type == 6) {
$peer_addr = Net_IPv6::uncompress($peer_addr, TRUE);
}
$peer_addr_type = 'ipv' . $peer_addr_type;
$entry['peer_addr'] = $peer_addr;
$entry['peer_addr_type'] = $peer_addr_type;
} else {
continue;
// Peer address unknown
}
if (!is_array($cache_pseudowires['ips'][$peer_addr])) {
$cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . generate_query_values($GLOBALS['cache']['ports']['pseudowires'], 'port_id') . ' LIMIT 1;', array($peer_addr));
if (!is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
$cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . $GLOBALS['cache']['where']['ports_permitted'] . ' LIMIT 1;', array($peer_addr));
if (is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
// If we found port on remote device, than both devices in DB and will try to fix real port
$peer_port_tmp = get_port_by_id_cache($cache_pseudowires['ips'][$peer_addr]['port_id']);
$peer_port_fix = dbFetchCell('SELECT `port_id` FROM `pseudowires` WHERE `device_id` = ? AND `pwID` = ? LIMIT 1;', array($peer_port_tmp['device_id'], $entry['pwID']));
if (is_numeric($peer_port_fix)) {
$cache_pseudowires['ips'][$peer_addr]['port_id'] = $peer_port_fix;
}
}
}
//$cache_pseudowires['ips'][$peer_addr]['host'] = $entry['reverse_dns'];
}
$entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id'];
//$entry['peer_port'] = get_port_by_id_cache($entry['peer_port_id']);
//$entry['peer_device_id'] = $entry['peer_port']['device_id'];
//$entry['peer_device'] = device_by_id_cache($entry['peer_device_id']);
$array['entries'][] = $entry;
}
// Query pseudowires count
if ($array['pagination']) {
$array['count'] = dbFetchCell($query_count, $param);
$array['pagination_html'] = pagination($vars, $array['count']);
} else {
$array['count'] = count($array['entries']);
}
// Query for last timestamp
//$array['updated'] = dbFetchCell($query_updated, $param);
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:pseudowires.inc.php
示例12: print_events
//.........这里部分代码省略.........
if ($list['device']) {
$string .= ' <th>设备</th>' . PHP_EOL;
}
if ($list['entity']) {
$string .= ' <th>单位</th>' . PHP_EOL;
}
$string .= ' <th>信息</th>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' <tbody>' . PHP_EOL;
foreach ($events['entries'] as $entry) {
#$icon = geteventicon($entry['message']);
#if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; }
switch ($entry['severity']) {
case "0":
// Emergency
// Emergency
case "1":
// Alert
// Alert
case "2":
// Critical
// Critical
case "3":
// Error
$entry['html_row_class'] = "error";
break;
case "4":
// Warning
$entry['html_row_class'] = "warning";
break;
case "5":
// Notification
$entry['html_row_class'] = "recovery";
break;
case "6":
// Informational
$entry['html_row_class'] = "up";
break;
case "7":
// Debugging
$entry['html_row_class'] = "suppressed";
break;
default:
}
$string .= ' <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
$string .= '<td class="state-marker"></td>' . PHP_EOL;
if ($events['short']) {
$string .= ' <td class="syslog" style="white-space: nowrap">';
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
$string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
} else {
$string .= ' <td style="width: 160px">';
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
}
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
$string .= ' <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
}
if ($list['entity']) {
if ($entry['entity_type'] == 'device' && !$entry['entity_id']) {
$entry['entity_id'] = $entry['device_id'];
}
if ($entry['entity_type'] == 'port') {
$this_if = get_port_by_id_cache($entry['entity_id']);
$entry['link'] = '<span class="entity"><i class="' . $config['entities']['port']['icon'] . '"></i> ' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
} else {
if (!empty($config['entities'][$entry['entity_type']]['icon'])) {
$entry['link'] = '<i class="' . $config['entities'][$entry['entity_type']]['icon'] . '"></i> ' . generate_entity_link($entry['entity_type'], $entry['entity_id']);
} else {
$entry['link'] = nicecase($entry['entity_type']);
}
}
if (!$events['short']) {
$string .= ' <td>' . $entry['link'] . '</td>' . PHP_EOL;
}
}
if ($events['short']) {
$string .= ' <td class="syslog">';
if (strpos($entry['message'], $entry['link']) !== 0) {
$string .= $entry['link'] . ' ';
}
} else {
$string .= ' <td>';
}
$string .= escape_html($entry['message']) . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
// Print pagination header
if ($events['pagination_html']) {
$string = $events['pagination_html'] . $string . $events['pagination_html'];
}
// Print events
echo $string;
}
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:events.inc.php
示例13: get_port_by_index_cache
function get_port_by_index_cache($device, $ifIndex)
{
global $cache;
if (is_array($device) && isset($device['device_id'])) {
$device_id = $device['device_id'];
} else {
if (is_numeric($device)) {
$device_id = $device;
}
}
if (!isset($device_id) || !is_numeric($ifIndex)) {
print_error("无效的参数通过函数 get_port_by_index_cache(). 请报告给开发小组.");
}
if (isset($cache['port_index'][$device_id][$ifIndex]) && is_numeric($cache['port_index'][$device_id][$ifIndex])) {
$id = $cache['port_index'][$device_id][$ifIndex];
} else {
$id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? LIMIT 1", array($device_id, $ifIndex));
if (is_numeric($id)) {
$cache['port_index'][$device_id][$ifIndex] = $id;
}
}
$port = get_port_by_id_cache($id);
if (is_array($port)) {
return $port;
}
return FALSE;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:27,代码来源:common.inc.php
示例14: get_pseudowire_table
function get_pseudowire_table($vars)
{
$sql = generate_pseudowire_query($vars);
$entries = array();
foreach (dbFetchRows($sql) as $entry) {
if (!isset($GLOBALS['cache']['devices']['id'][$entry['device_id']])) {
continue;
}
// Device hostname
$entry['hostname'] = $GLOBALS['cache']['devices']['id'][$entry['device_id']]['hostname'];
// Remote Peer
$peer_addr = $entry['peer_addr'];
$peer_addr_type = get_ip_version($peer_addr);
if ($peer_addr_type && $entry['peer_device_id']) {
if ($peer_addr_type == 6) {
$peer_addr = Net_IPv6::uncompress($peer_addr, TRUE);
}
$peer_addr_type = 'ipv' . $peer_addr_type;
//$entry['peer_addr'] = $peer_addr;
//$entry['peer_addr_type'] = $peer_addr_type;
if (!is_array($cache_pseudowires['ips'][$peer_addr])) {
$cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . generate_query_values($GLOBALS['cache']['ports']['pseudowires'], 'port_id') . ' LIMIT 1;', array($peer_addr));
if (!is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
// Separate entry for find correct port
$cache_pseudowires['ips'][$peer_addr]['port_id_fix'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . $GLOBALS['cache']['where']['ports_permitted'] . ' LIMIT 1;', array($peer_addr));
}
//$cache_pseudowires['ips'][$peer_addr]['host'] = $entry['reverse_dns'];
}
$entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id'];
if (is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id_fix'])) {
// If we found port on remote device, than both devices in DB and will try to fix real port
$peer_port_tmp = get_port_by_id_cache($cache_pseudowires['ips'][$peer_addr]['port_id_fix']);
$peer_port_fix = dbFetchCell('SELECT `port_id` FROM `pseudowires` WHERE `device_id` = ? AND `pwID` = ? LIMIT 1;', array($peer_port_tmp['device_id'], $entry['pwID']));
if (is_numeric($peer_port_fix)) {
$entry['peer_port_id'] = $peer_port_fix;
} else {
$entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id_fix'];
}
}
//r($entry['peer_port_id']);
if ($entry['peer_port_id']) {
$entry['peer_port'] = get_port_by_id_cache($entry['peer_port_id']);
//r($entry['peer_port']);
$entry['peer_device_id'] = $entry['peer_port']['device_id'];
//r($entry['peer_device_id']);
$entry['peer_device'] = device_by_id_cache($entry['peer_device_id']);
}
}
$entry['hostname'] = $GLOBALS['cache']['devices']['id'][$entry['device_id']]['hostname'];
// Attach hostname for sorting
$entries[] = $entry;
}
// Sorting
switch ($vars['sort_order']) {
case 'desc':
$sort_order = SORT_DESC;
$sort_neg = SORT_ASC;
break;
case 'reset':
unset($vars['sort'], $vars['sort_order']);
// no break here
// no break here
default:
$sort_order = SORT_ASC;
$sort_neg = SORT_DESC;
}
switch ($vars['sort']) {
case 'device':
$entries = array_sort_by($entries, 'hostname', $sort_order, SORT_STRING);
break;
case 'pwid':
$entries = array_sort_by($entries, 'pwID', $sort_order, SORT_NUMERIC);
break;
case 'pwtype':
$entries = array_sort_by($entries, 'pwType', $sort_order, SORT_STRING, 'pwPsnType', $sort_order, SORT_STRING);
//$pws = array_sort_by($pws, 'pwType', $sort_order, SORT_STRING);
break;
case 'peer_addr':
$entries = array_sort_by($entries, 'peer_addr', $sort_order, SORT_NUMERIC);
break;
case 'event':
$entries = array_sort_by($entries, 'event', $sort_order, SORT_STRING);
break;
case 'uptime':
$entries = array_sort_by($entries, 'pwUptime', $sort_order, SORT_NUMERIC);
break;
case 'last_change':
$entries = array_sort_by($entries, 'last_change', $sort_neg, SORT_NUMERIC);
break;
case 'status':
$entries = array_sort_by($entries, 'pwOperStatus', $sort_order, SORT_STRING);
break;
default:
// Not sorted
}
return $entries;
}
开发者ID:Natolumin,项目名称:observium,代码行数:97,代码来源:pseudowire.inc.php
示例15: get_port_by_index_cache
function get_port_by_index_cache($device_id, $ifIndex)
{
global $cache;
if (isset($cache['port_index'][$device_id][$ifIndex]) && is_numeric($cache['port_index'][$device_id][$ifIndex])) {
$id = $cache['port_index'][$device_id][$ifIndex];
} else {
$id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? LIMIT 1", array($device_id, $ifIndex));
if (is_numeric($id)) {
$cache['port_index'][$device_id][$ifIndex] = $id;
}
}
$port = get_port_by_id_cache($id);
if (is_array($port)) {
return $port;
}
return FALSE;
}
开发者ID:skive,项目名称:observium,代码行数:17,代码来源:common.inc.php
示例16: foreach
if (!isset($ports_has_ext['ipv6_addresses']) || in_array($port['port_id'], $ports_has_ext['ipv6_addresses'])) {
foreach (dbFetchColumn("SELECT A6.`ipv6_network_id` FROM `ipv6_addresses` AS A6\n LEFT JOIN `ipv6_networks` AS N6 ON A6.`ipv6_network_id` = N6.`ipv6_network_id`\n WHERE `port_id` = ? AND `ipv6_network` NOT IN (?) GROUP BY A6.`ipv6_network_id`", array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
$ipv6_network_id = $net['ipv6_network_id'];
$sql = "SELECT P.`port_id`, P.`device_id` FROM `ipv6_addresses` AS A, `ipv6_networks` AS N, `ports` AS P\n WHERE A.`port_id` = P.`port_id` AND P.device_id != ?\n AND A.`ipv6_network_id` = ? AND N.`ipv6_network_id` = A.`ipv6_network_id`\n AND P.`ifAdminStatus` = 'up' AND A.`ipv6_origin` != 'linklayer' AND A.`ipv6_origin` != 'wellknown'";
$params = array($device['device_id'], $network_id);
foreach (dbFetchRows($sql, $params) as $new) {
if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
continue;
}
$int_links[$new['port_id']] = $new['port_id'];
$int_links_v6[$new['port_id']][] = $new['port_id'];
}
}
}
foreach ($int_links as $int_link) {
$link_if = get_port_by_id_cache($int_link);
$link_dev = device_by_id_cache($link_if['device_id']);
echo $br;
if ($int_links
|
请发表评论