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 }
/** * 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; } }
if (!$ignore) { if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", port_errors); } else { $error_img = ''; } $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } if ($arp_host['device_id'] == $entry['device_id']) { $arp_name = 'Localhost'; } if ($arp_host['port_id'] == $entry['port_id']) { $arp_if = 'Local port'; } $response[] = array('mac_address' => formatMac($entry['mac_address']), 'ipv4_address' => $entry['ipv4_address'], 'hostname' => generate_device_link($entry), 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device' => $arp_name, 'remote_interface' => $arp_if); } //end if unset($ignore); } //end foreach $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
} if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; foreach (dbFetchRows($sql) as $device) { if (device_permitted($device['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: #ffbbbb;'>\n <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />\n <span class=body-date-1>" . truncate($device['location'], 35) . "</span>\n </div>"; } } if ($config['warn']['ifdown']) { $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; foreach (dbFetchRows($sql) as $interface) { if (port_permitted($interface['port_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($interface, shorthost($interface['hostname'])) . "</strong><br />\n <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />\n <strong>" . generate_port_link($interface, makeshortif($interface['ifDescr'])) . "</strong><br />\n <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n </div>"; } } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; 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>"; } }
function alert_details($details) { if (!is_array($details)) { $details = json_decode(gzuncompress($details), true); } $fault_detail = ''; foreach ($details['rule'] as $o => $tmp_alerts) { $fallback = true; $fault_detail .= '#' . ($o + 1) . ': '; if ($tmp_alerts['bill_id']) { $fault_detail .= '<a href="' . generate_bill_url($tmp_alerts) . '">' . $tmp_alerts['bill_name'] . '</a>; '; $fallback = false; } if ($tmp_alerts['port_id']) { $fault_detail .= generate_port_link($tmp_alerts) . '; '; $fallback = false; } if ($fallback === true) { foreach ($tmp_alerts as $k => $v) { if (!empty($v) && $k != 'device_id' && (stristr($k, 'id') || stristr($k, 'desc') || stristr($k, 'msg')) && substr_count($k, '_') <= 1) { $fault_detail .= "{$k} => '{$v}', "; } } $fault_detail = rtrim($fault_detail, ', '); } $fault_detail .= '<br>'; } //end foreach return $fault_detail; }
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); foreach ($entries as $peer) { $peer_ip = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr']; $peer['wide'] = strstr($peer['bgpPeerRemoteAddr'], ':') ? TRUE : FALSE; $boxes[] = array('sev' => 75, 'class' => 'BGP Peer', 'event' => 'Down', 'device_link' => generate_device_link($peer, short_hostname($peer['hostname'])), 'entity_link' => $peer_ip, 'wide' => $peer['wide'], 'time' => formatUptime($peer['bgpPeerFsmEstablishedTime'], 'short-3'), 'location' => $device['location']); } } } // Return boxes array return $boxes; }
* */ include_once "../includes/defaults.inc.php"; include_once "../config.php"; include_once "../includes/definitions.inc.php"; include_once "../includes/common.inc.php"; include_once "../includes/dbFacile.php"; include_once "../includes/rewrites.inc.php"; include_once "includes/functions.inc.php"; include_once "includes/authenticate.inc.php"; include_once "../includes/snmp.inc.php"; if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) { $port = get_port_by_id($_GET['id']); $device = device_by_id_cache($port['device_id']); $title = generate_device_link($device); $title .= " :: Port " . generate_port_link($port); $auth = TRUE; } else { echo "Unauthenticad"; die; } header("Content-type: image/svg+xml"); /********** HTTP GET Based Conf ***********/ $ifnum = @$port['ifIndex']; // BSD / SNMP interface name / number $ifname = htmlentities(@$port['ifDescr']); //Interface name that will be showed on top right of graph $hostname = short_hostname($device['hostname']); if ($_GET['title']) { $ifname = $_GET['title']; }
case 'upkts': case 'nupkts': case 'errors': $port['width'] = '130'; $port['height'] = '30'; $port['from'] = $config['time']['day']; $port['to'] = $config['time']['now']; $port['bg'] = '#' . $bg; $port['graph_type'] = 'port_' . $_GET['optc']; echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;\n text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . '</div>'; print_port_thumbnail($port); echo "<div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 22, '') . '</div> </div>'; break; default: echo $seperator . generate_port_link($port, makeshortif($port['ifDescr'])); $seperator = ', '; break; } //end switch } //end foreach echo '</td></tr>'; $x++; } //end foreach echo '</table></td>'; $i++; } //end foreach echo '</table></div>';
$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>"; } ?>
<?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";
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> '; }
$bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) { $device = device_by_id_cache($port['device_id']); unset($class); $ifname = fixifname($device['ifDescr']); $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); if ($device['os'] == "ios") { if ($port['ifTrunk']) { $vlan = "<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>"; } elseif ($port['ifVlan']) { $vlan = "<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>"; } else { $vlan = ""; } } echo "\n <tr bgcolor='{$bg_colour}'>\n <td width='7'></td>\n <td width='250'><span style='font-weight: bold;' class=interface>" . $customer_name . "</span></td>\n <td width='150'>" . generate_device_link($device) . "</td>\n <td width='100'>" . generate_port_link($port, makeshortif($port['ifDescr'])) . "</td>\n <td width='100'>" . $port['port_descr_speed'] . "</td>\n <td width='100'>" . $port['port_descr_circuit'] . "</td>\n <td>" . $port['port_descr_notes'] . "</td>\n </tr>\n "; unset($customer_name); } echo "<tr bgcolor='{$bg_colour}'><td></td><td colspan=6>"; $graph_array['type'] = "customer_bits"; $graph_array['height'] = "100"; $graph_array['width'] = "220"; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $customer['port_descr_descr']; include "includes/print-graphrow.inc.php"; echo "</tr>"; } echo "</table>";
<?php // FIXME new url format if (is_integer($i / 2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } echo "<tr bgcolor='{$bg_colour}'>"; echo "<td width=200 class=entity-title><a href='routing/vrf/" . $vrf['mplsVpnVrfRouteDistinguisher'] . "/'>" . $vrf['vrf_name'] . "</a></td>"; echo "<td width=150 class=small>" . $vrf['mplsVpnVrfDescription'] . "</td>"; echo "<td width=100 class=small>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>"; echo '<td class="entity">'; foreach (dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?", array($device['device_id'], $vrf['vrf_id'])) as $port) { if ($vars['view'] == "graphs") { $graph_type = "port_" . $vars['graph']; echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: #e9e9e9;'>\n <div style='font-weight: bold;'>" . short_ifname($port['ifDescr']) . "</div>\n <a href='device/" . $device['device_id'] . "/port/" . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $port['ifDescr'] . "</div>\\\n " . $port['ifAlias'] . " \\\n <img src=\\'graph.php?type={$graph_type}&id=" . $port['port_id'] . "&from=" . $config['time']['twoday'] . "&to=" . $config['time']['now'] . "&width=450&height=150\\'>\\\n ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >" . "<img src='graph.php?type={$graph_type}&id=" . $port['port_id'] . "&from=" . $config['time']['twoday'] . "&to=" . $config['time']['now'] . "&width=132&height=40&legend=no'>\n </a>\n <div style='font-size: 9px;'>" . short_port_descr($port['ifAlias']) . "</div>\n </div>"; } else { echo $vrf['port_sep'] . generate_port_link($port, short_ifname($port['ifDescr'])); $vrf['port_sep'] = ", "; } } echo "</td>"; echo "</tr>";
$pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id\n AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); if (!port_permitted($pw_a['port_id'])) { $skip = "yes"; } if (!port_permitted($pw_b['port_id'])) { $skip = "yes"; } if ($skip) { unset($skip); } else { if ($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg = "ffffff"; } echo "<tr style=\"background-color: #{$bg};\"><td rowspan=2 style='font-size:18px; padding:4px;'>" . $pw_a['cpwVcID'] . "</td><td>" . generate_port_link($pw_a) . "</td>\n <td rowspan=2> <img src='images/16/arrow_right.png'> </td>\n <td>" . generate_device_link($peer_device) . "</td><td>" . generate_port_link($pw_b) . "</td></tr>"; echo "<tr style=\"background-color: #{$bg};\"><td colspan=2>" . $pw_a['ifAlias'] . "</td><td>" . $pw_b['ifAlias'] . "</td></tr>"; if ($vars['view'] == "minigraphs") { echo "<tr style=\"background-color: #{$bg};\"><td></td><td colspan=2>"; if ($pw_a) { $pw_a['width'] = "150"; $pw_a['height'] = "30"; $pw_a['from'] = $config['time']['day']; $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); foreach ($types as $graph_type) { $pw_a['graph_type'] = "port_" . $graph_type; generate_port_thumbnail($pw_a); } }
if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) { $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id'])); echo "{$br}<img src='images/16/bricks.png' align=absmiddle> <strong>" . generate_port_link($parent) . " (PAgP)</strong>"; $br = "<br />"; } foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) { if ($higher_if['port_id_high']) { $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']); echo "{$br}<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>"; $br = "<br />"; } } foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) { if ($lower_if['port_id_low']) { $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']); echo "{$br}<img src='images/16/arrow_join.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>"; $br = "<br />"; } } } unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); echo "</td></tr>"; // If we're showing graphs, generate the graph and print the img tags if ($graph_type == "etherlike") { $graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex']) . "-dot3.rrd"; } else { $graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex']) . ".rrd"; } if ($graph_type && is_file($graph_file)) { $type = $graph_type; echo "<tr style='background-color: {$row_colour}; padding: 0px;'><td colspan=7>";
<?php global $config; // FIXME functions! if (!$graph_type) { $graph_type = 'pagp_bits'; } $daily_traffic = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['day'] . '&to=' . $config['time']['now'] . '&width=215&height=100'; $daily_url = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['day'] . '&to=' . $config['time']['now'] . '&width=500&height=150'; $weekly_traffic = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['week'] . '&to=' . $config['time']['now'] . '&width=215&height=100'; $weekly_url = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['week'] . '&to=' . $config['time']['now'] . '&width=500&height=150'; $monthly_traffic = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['month'] . '&to=' . $config['time']['now'] . '&width=215&height=100'; $monthly_url = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['month'] . '&to=' . $config['time']['now'] . '&width=500&height=150'; $yearly_traffic = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['year'] . '&to=' . $config['time']['now'] . '&width=215&height=100'; $yearly_url = 'graph.php?port=' . $port['port_id'] . "&type={$graph_type}&from=" . $config['time']['year'] . '&to=' . $config['time']['now'] . '&width=500&height=150'; echo "<a href='#' onmouseover=\"return overlib('<img src=\\'{$daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\">\n <img src='{$daily_traffic}' border=0></a> "; echo "<a href='#' onmouseover=\"return overlib('<img src=\\'{$weekly_url}\\'>', LEFT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\">\n <img src='{$weekly_traffic}' border=0></a> "; echo "<a href='#' onmouseover=\"return overlib('<img src=\\'{$monthly_url}\\'>', LEFT" . $config['overlib_defaults'] . ", WIDTH, 350);\" onmouseout=\"return nd();\">\n <img src='{$monthly_traffic}' border=0></a> "; echo "<a href='#' onmouseover=\"return overlib('<img src=\\'{$yearly_url}\\'>', LEFT" . $config['overlib_defaults'] . ", WIDTH, 350);\" onmouseout=\"return nd();\">\n <img src='{$yearly_traffic}' border=0></a>"; foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { echo "{$br}<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . ' (PAgP)</strong>'; $br = '<br />'; }
echo $port['port_descr_speed']; ?> "> </div> </div> </fieldset> <div class="form-actions"> <!-- <button class="btn btn-info" style="float: right;"><i class="icon-circle-arrow-left icon-white"></i> <strong>Back to bills</strong></button> //--> <button type="submit" class="btn btn-primary"><i class="icon-ok-sign icon-white"></i> <strong>Add Bill</strong></button> </div> </div> <div class="tab-pane fade in" id="ports"> <?php if (is_array($port)) { $devicebtn = str_replace("list-device", "btn", generate_device_link($port)); $portbtn = str_replace("interface-upup", "btn", generate_port_link($port)); $portalias = empty($port['ifAlias']) ? "" : " - " . $port['ifAlias'] . ""; $devicebtn = str_replace("\">" . $port['hostname'], "\" style=\"color: #000;\"><i class=\"icon-asterisk\"></i> " . $port['hostname'], $devicebtn); $devicebtn = str_replace("overlib('", "overlib('<div style=\\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\\'>", $devicebtn); $devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn); $portbtn = str_replace("\">" . strtolower($port['ifName']), "\" style=\"color: #000;\"><i class=\"icon-random\"></i> " . $port['ifName'] . "" . $portalias, $portbtn); $portbtn = str_replace("overlib('", "overlib('<div style=\\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\\'>", $portbtn); $portbtn = str_replace("<div>',;", "</div></div>',", $portbtn); echo " <fieldset>\n"; echo " <legend>Bill Ports</legend>\n"; echo " <input type=\"hidden\" name=\"port\" value=\"" . $port['port_id'] . "\">\n"; echo " <div class=\"control-group\">\n"; echo " <div class=\"btn-toolbar\">\n"; echo " <div class=\"btn-group\">\n"; echo " " . $devicebtn . "\n"; echo " " . $portbtn . "\n";
<h2>端口权限</h2> <?php if (count($user_permissions['port'])) { foreach (array_keys($user_permissions['port']) as $entity_id) { $port = get_port_by_id($entity_id); $device = device_by_id_cache($port['device_id']); $emptyCheck = true; $count++; $devicebtn = '<button class="btn"><i class="oicon-servers"></i> ' . generate_device_link($device) . '</button>'; if (empty($port['ifAlias'])) { $portalias = ""; } else { $portalias = " - " . $port['ifAlias'] . ""; } $portbtn = '<button class="btn">' . generate_port_link($port, '<i class="oicon-network-ethernet"></i> ' . rewrite_ifname($port['label']) . $portalias) . '</button>'; $del_url = generate_url(array('page' => 'edituser', 'action' => 'perm_del', 'user_id' => $vars['user_id'], 'entity_type' => 'port', 'entity_id' => $entity_id)); echo ' <div class="btn-group" style="margin: 5px;">'; echo ' <button class="btn btn-danger" style="color: #fff;" onclick="location.href=\'' . $del_url . '\';"><i class="icon-minus-sign icon-white"></i> 删除</button>'; echo ' ' . $devicebtn; echo ' ' . $portbtn; echo ' </div>'; } } else { echo '<div class="alert alert-danger">无权限</div>'; } ?> <hr /> <h3>授予新的端口权限</h3>
if ($vlan['state'] == "blocking") { $class = "red"; } elseif ($vlan['state'] == "forwarding") { $class = "green"; } else { $class = "none"; } echo "<td>" . $vlan['cost'] . "</td><td>" . $vlan['priority'] . "</td><td class={$class}>" . $vlan['state'] . "</td>"; $vlan_ports = array(); $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan'])); foreach ($otherports as $otherport) { $vlan_ports[$otherport[ifIndex]] = $otherport; } $otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan'])); foreach ($otherports as $otherport) { $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); } ksort($vlan_ports); echo "<td>"; $vsep = ''; foreach ($vlan_ports as $otherport) { echo $vsep . generate_port_link($otherport, makeshortif($otherport['ifDescr'])); if ($otherport['untagged']) { echo "(U)"; } $vsep = ", "; } echo "</td>"; echo "</tr>"; } echo "</table>";
<?php echo '<table class="table table-striped table-condensed">'; $i = "1"; echo '<thead><th>Local Port</th> <th>Remote Port</th> <th>Remote Device</th> <th>Protocol</th> </thead>'; foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id", array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } echo '<tr bgcolor="' . $bg_colour . '">'; echo '<td><span style="font-weight: bold;">' . generate_port_link($neighbour) . '</span><br />' . $neighbour['ifAlias'] . '</td>'; if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) { $remote_port = get_port_by_id($neighbour['remote_port_id']); $remote_device = device_by_id_cache($remote_port['device_id']); echo "<td>" . generate_port_link($remote_port) . "<br />" . $remote_port['ifAlias'] . "</td>"; echo "<td>" . generate_device_link($remote_device) . "<br />" . $remote_device['hardware'] . "</td>"; } else { echo "<td>" . $neighbour['remote_port'] . "</td>"; echo "<td>" . $neighbour['remote_hostname'] . "\n <br />" . $neighbour['remote_platform'] . "</td>"; } echo "<td>" . strtoupper($neighbour['protocol']) . "</td>"; echo "</tr>"; $i++; } echo "</table>";
<?php if ($_GET['id'] && is_numeric($_GET['id'])) { $atm_vp_id = $_GET['id']; } $vp = dbFetchRow('SELECT * FROM `juniAtmVp` as J, `ports` AS I, `devices` AS D WHERE J.juniAtmVp_id = ? AND I.port_id = J.port_id AND I.device_id = D.device_id', array($atm_vp_id)); if ($auth || port_permitted($vp['port_id'])) { $port = $vp; $device = device_by_id_cache($port['device_id']); $title = generate_device_link($device); $title .= ' :: Port ' . generate_port_link($port); $title .= ' :: VP ' . $vp['vp_id']; $auth = true; $rrd_filename = rrd_name($vp['hostname'], array('vp', $vp['ifIndex'], $vp['vp_id'])); }
echo "" . formatRates($port['adslAturCurrAttainableRate']) . "/" . formatRates($port['adslAtucCurrAttainableRate']); echo "<br />"; $port['graph_type'] = "port_adsl_attainable"; echo generate_port_link($port, "<img src='graph.php?type=" . $port['graph_type'] . "&id=" . $port['port_id'] . "&from=" . $from . "&to=" . $config['time']['now'] . "&width=" . $width . "&height=" . $height . "&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $port['graph_type']); echo "</td><td width=135>"; echo "" . $port['adslAturCurrAtn'] . "dB/" . $port['adslAtucCurrAtn'] . "dB"; echo "<br />"; $port['graph_type'] = "port_adsl_attenuation"; echo generate_port_link($port, "<img src='graph.php?type=" . $port['graph_type'] . "&id=" . $port['port_id'] . "&from=" . $from . "&to=" . $config['time']['now'] . "&width=" . $width . "&height=" . $height . "&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $port['graph_type']); echo "</td><td width=135>"; echo "" . $port['adslAturCurrSnrMgn'] . "dB/" . $port['adslAtucCurrSnrMgn'] . "dB"; echo "<br />"; $port['graph_type'] = "port_adsl_snr"; echo generate_port_link($port, "<img src='graph.php?type=" . $port['graph_type'] . "&id=" . $port['port_id'] . "&from=" . $from . "&to=" . $config['time']['now'] . "&width=" . $width . "&height=" . $height . "&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $port['graph_type']); echo "</td><td width=135>"; echo "" . $port['adslAturCurrOutputPwr'] . "dBm/" . $port['adslAtucCurrOutputPwr'] . "dBm"; echo "<br />"; $port['graph_type'] = "port_adsl_power"; echo generate_port_link($port, "<img src='graph.php?type=" . $port['graph_type'] . "&id=" . $port['port_id'] . "&from=" . $from . "&to=" . $config['time']['now'] . "&width=" . $width . "&height=" . $height . "&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $port['graph_type']); # if ($port['ifDuplex'] != 'unknown') { echo("<span class=small>Duplex " . $port['ifDuplex'] . "</span>"); } else { echo("-"); } # echo("</td><td width=150>"); # echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']); # echo("<br />"); # echo("Sync:".formatRates($port_adsl['adslAtucChanCurrTxRate']) . "/". formatRates($port_adsl['adslAturChanCurrTxRate'])); # echo("<br />"); # echo("Max:".formatRates($port_adsl['adslAtucCurrAttainableRate']) . "/". formatRates($port_adsl['adslAturCurrAttainableRate'])); # echo("</td><td width=150>"); # echo("Atten:".$port_adsl['adslAtucCurrAtn'] . "dB/". $port_adsl['adslAturCurrAtn'] . "dB"); # echo("<br />"); # echo("SNR:".$port_adsl['adslAtucCurrSnrMgn'] . "dB/". $port_adsl['adslAturCurrSnrMgn']. "dB"); echo "</td>";
<?php foreach ($ports as $port) { if (is_integer($row / 2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $speed = humanspeed($port['ifSpeed']); $type = humanmedia($port['ifType']); $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); if ($port['in_errors'] > 0 || $port['out_errors'] > 0) { $error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors); } else { $error_img = ''; } if (port_permitted($port['port_id'], $port['device_id'])) { $port = ifLabel($port, $device); $graph_type = 'port_' . $subformat; if ($_SESSION['widescreen']) { $width = 357; } else { $width = 315; } if ($_SESSION['widescreen']) { $width_div = 438; } else { $width_div = 393; } $graph_array = array();
<?php $hostname = gethostbyid($entry['host']); unset($icon); $icon = geteventicon($entry['message']); if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; } echo '<tr> <td> ' . $entry['datetime'] . ' </td>'; if (!isset($vars['device'])) { $dev = device_by_id_cache($entry['host']); echo '<td> ' . generate_device_link($dev, shorthost($dev['hostname'])) . ' </td>'; } if ($entry['type'] == 'interface') { $this_if = ifLabel(getifbyid($entry['reference'])); $entry['link'] = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>'; } else { $entry['link'] = 'System'; } echo '<td>' . $entry['link'] . '</td>'; echo '<td>' . $entry['message'] . '</td> </tr>';
echo $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($this_port) . '</strong>'; $br = "<br />"; } } } } if (!isset($ports_has_ext['ports_stack_high']) || in_array($port['ifIndex'], $ports_has_ext['ports_stack_high'])) { foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) { if ($lower_if['port_id_low']) { if ($pagp[$device['device_id']][$port['ifIndex']][$lower_if['port_id_low']]) { continue; } // Skip if same PAgP ports $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']); if (is_array($this_port)) { echo $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($this_port) . "</strong>"; $br = "<br />"; } } } } } unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); echo "</td></tr>"; // If we're showing graphs, generate the graph and print the img tags if ($graph_type == "etherlike") { $graph_file = get_port_rrdfilename($port, "dot3", TRUE); } else { $graph_file = get_port_rrdfilename($port, NULL, TRUE); } if ($graph_type && is_file($graph_file)) {
case 'pkts_out': $ma_array = array_sort($ma_array, 'bytes_output_rate', 'SORT_DESC'); break; } foreach ($ma_array as $acc) { $ips = array(); foreach (dbFetchRows("SELECT `ip_address` FROM `ip_mac` WHERE `mac_address` = ? AND `port_id` = ?", array($acc['mac'], $acc['port_id'])) as $ip) { $ips[] = $ip['ip_address']; } unset($name); ///FIXME. Need rewrite, because $addy is array with multiple items. #$name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this? $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ip_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); $arp_name .= " " . generate_port_link($arp_host); } else { unset($arp_if); } if ($name == $addy['ip_address']) { unset($name); } if (dbFetchCell("SELECT COUNT(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ip_address']))) { $peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ip_address'])); } else { unset($peer_info); } if ($peer_info) { $asn = "AS" . $peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; } else {
<span class=list-device-down>Device Down</span> <br /> <span class=body-date-1>' . truncate($device['location'], 20) . '</span>'); ++$count_boxes; } if (is_admin() === true || is_read() === true) { $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit']; } else { $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> // Port down boxes if ($config['warn']['ifdown']) { foreach (dbFetchRows($sql) as $interface) { if (!$interface['deleted']) { $interface = ifNameDescr($interface); generate_front_box('alert alert-danger', generate_device_link($interface, shorthost($interface['hostname'])) . "<br />\n <span class=\"interface-updown\">Port Down</span><br />\n<!-- <img src='graph.php?type=bits&if=" . $interface['port_id'] . '&from=' . $config['time']['day'] . '&to=' . $config['time']['now'] . "&width=100&height=32' /> -->\n " . generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')) . ' <br /> ' . ($interface['ifAlias'] ? '<span class="body-date-1">' . truncate($interface['ifAlias'], 20, '') . '</span>' : '')); ++$count_boxes; } } } /* FIXME service permissions? seem nonexisting now.. */ // Service down boxes if (is_admin() === true || is_read() === true) { $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '2' LIMIT " . $config['front_page_down_box_limit']; $param[] = ''; } else { $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '2' LIMIT " . $config['front_page_down_box_limit']; $param[] = $_SESSION['user_id']; }
$query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; $query .= ' AND D.device_id = I.device_id'; $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); if ($ipv4_host) { $peerhost = $ipv4_host; } else { if ($ipv6_host) { $peerhost = $ipv6_host; } else { unset($peerhost); } } if (is_array($peerhost)) { // $peername = generate_device_link($peerhost); $peername = generate_device_link($peerhost) . ' ' . generate_port_link($peerhost); $peer_url = 'device/device=' . $peer['device_id'] . '/tab=routing/proto=bgp/view=updates/'; } else { // FIXME // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? // if ($peername == $peer['bgpPeerIdentifier']) // { // unset($peername); // } else { // $peername = "<i>".$peername."<i>"; // } } unset($peer_af); unset($sep); foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { $afi = $afisafi['afi'];
/** * Display device inventory hierarchy. * * @param string $ent, $level, $class * @return none * */ function print_ent_physical($ent, $level, $class) { global $device; $ents = dbFetchRows("SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ? ORDER BY `entPhysicalContainedIn`, `entPhysicalIndex`", array($device['device_id'], $ent)); foreach ($ents as $ent) { $link = ''; $text = " <li class='{$class}'>"; /* Currently no icons for: JUNIPER-MIB::jnxFruType.10.1.1.0 = INTEGER: frontPanelModule(8) JUNIPER-MIB::jnxFruType.12.1.0.0 = INTEGER: controlBoard(5) For Geist RCX, IPOMan: outlet relay */ switch ($ent['entPhysicalClass']) { case 'chassis': $text .= '<i class="oicon-database"></i> '; break; case 'module': case 'portInterfaceCard': $text .= '<i class="oicon-drive"></i> '; break; case 'port': $text .= '<i class="oicon-network-ethernet"></i> '; break; case 'container': case 'flexiblePicConcentrator': $text .= '<i class="oicon-box-zipper"></i> '; break; case 'stack': $text .= '<i class="oicon-databases"></i> '; break; case 'fan': case 'airflowSensor': $text .= '<i class="oicon-weather-wind"></i> '; break; case 'powerSupply': case 'powerEntryModule': $text .= '<i class="oicon-plug"></i> '; break; case 'backplane': $text .= '<i class="oicon-zones"></i> '; break; case 'sensor': $text .= '<i class="oicon-asterisk"></i> '; $sensor = dbFetchRow("SELECT * FROM `sensors` AS S\n LEFT JOIN `sensors-state` AS ST ON S.`sensor_id` = ST.`sensor_id`\n WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($device['device_id'], $ent['entPhysicalIndex'], $ent['entPhysicalIndex'])); break; default: $text .= '<i class="oicon-chain"></i> '; } if ($ent['entPhysicalParentRelPos'] > '-1') { $text .= '<strong>' . $ent['entPhysicalParentRelPos'] . '.</strong> '; } $ent_text = ''; if ($ent['ifIndex']) { $interface = get_port_by_ifIndex($device['device_id'], $ent['ifIndex']); $ent['entPhysicalName'] = generate_port_link($interface); } if ($ent['entPhysicalModelName'] && $ent['entPhysicalName']) { $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong> (" . $ent['entPhysicalName'] . ")"; } elseif ($ent['entPhysicalModelName']) { $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong>"; } elseif (is_numeric($ent['entPhysicalName']) && $ent['entPhysicalVendorType']) { $ent_text .= "<strong>" . $ent['entPhysicalName'] . " " . $ent['entPhysicalVendorType'] . "</strong>"; } elseif ($ent['entPhysicalName']) { $ent_text .= "<strong>" . $ent['entPhysicalName'] . "</strong>"; } elseif ($ent['entPhysicalDescr']) { $ent_text .= "<strong>" . $ent['entPhysicalDescr'] . "</strong>"; } $ent_text .= "<br /><div class='small' style='margin-left: 20px;'>" . $ent['entPhysicalDescr']; if ($ent['entPhysicalClass'] == "sensor" && $sensor['sensor_value']) { $ent_text .= ' (' . $sensor['sensor_value'] . ' ' . $sensor['sensor_class'] . ')'; $link = generate_entity_link('sensor', $sensor, $ent_text, NULL, FALSE); } $text .= $link ? $link : $ent_text; if ($ent['entPhysicalSerialNum']) { $text .= ' <span class="text-info">[Serial: ' . $ent['entPhysicalSerialNum'] . ']</span> '; } $text .= "</div>"; echo $text; $count = dbFetchCell("SELECT COUNT(*) FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ?", array($device['device_id'], $ent['entPhysicalIndex'])); if ($count) { echo "<ul>"; print_ent_physical($ent['entPhysicalIndex'], $level + 1, ''); echo "</ul>"; } echo "</li>"; } }
$traverse_ifvlan = true; $otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id', array($device['device_id'], $vlan['vlan_vlan'])); foreach ($otherports as $otherport) { if ($otherport['untagged']) { $traverse_ifvlan = false; } $vlan_ports[$otherport[ifIndex]] = $otherport; } if ($traverse_ifvlan) { $otherports = dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?', array($device['device_id'], $vlan['vlan_vlan'])); foreach ($otherports as $otherport) { $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); } } ksort($vlan_ports); foreach ($vlan_ports as $port) { $port = ifLabel($port, $device); if ($vars['view'] == 'graphs') { echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . "</div>\n <a href='device/device=" . $device['device_id'] . '/tab=port/port=' . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . ' - ' . $port['ifDescr'] . '</div>\\ ' . $port['ifAlias'] . " \\\n <img src=\\'graph.php?type={$graph_type}&id=" . $port['port_id'] . '&from=' . $config['time']['twoday'] . '&to=' . $config['time']['now'] . "&width=450&height=150\\'>\\\n ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >" . "<img src='graph.php?type={$graph_type}&id=" . $port['port_id'] . '&from=' . $config['time']['twoday'] . '&to=' . $config['time']['now'] . "&width=132&height=40&legend=no'>\n </a>\n <div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 22, '') . '</div> </div>'; } else { echo $vlan['port_sep'] . generate_port_link($port, makeshortif($port['label'])); $vlan['port_sep'] = ', '; if ($port['untagged']) { echo '(U)'; } } } //end foreach echo '</td></tr>';