$ipv4_addresses = array(); foreach ($existing_data as $data) { $ipv4_addresses[] = $data['ipv4_address']; } $arp_table = array(); $insert_data = array(); foreach ($arp_data as $ip => $data) { if (isset($data['ipNetToPhysicalPhysAddress'])) { $raw_mac = $data['ipNetToPhysicalPhysAddress']; list($if, $ipv, $ip) = explode('.', $ip, 3); } elseif (isset($data['ipNetToMediaPhysAddress'])) { $raw_mac = $data['ipNetToMediaPhysAddress']; list($if, $ip) = explode('.', $ip, 2); $ipv = 'ipv4'; } $interface = get_port_by_index_cache($device['device_id'], $if); $port_id = $interface['port_id']; if (!empty($ip) && $ipv === 'ipv4' && $raw_mac != '0:0:0:0:0:0' && !isset($arp_table[$port_id][$ip])) { $mac = implode(array_map('zeropad', explode(':', $raw_mac))); $arp_table[$port_id][$ip] = $mac; $index = array_search($ip, $ipv4_addresses); if ($index !== false) { $old_mac = $existing_data[$index]['mac_address']; if ($mac != $old_mac && $mac != '') { d_echo("Changed mac address for {$ip} from {$old_mac} to {$mac}\n"); log_event("MAC change: {$ip} : " . mac_clean_to_readable($old_mac) . ' -> ' . mac_clean_to_readable($mac), $device, 'interface', $port_id); dbUpdate(array('mac_address' => $mac), 'ipv4_mac', 'port_id=? AND ipv4_address=? AND context_name=?', array($port_id, $ip, $context)); } d_echo(null, '.'); } elseif (isset($interface['port_id'])) { d_echo(null, '+');
$this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']); if (is_array($this_port)) { 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);
#/usr/bin/snmpbulkwalk -v2c -c kglk5g3l454@988 -OQUs -m BRIDGE-MIB -M /opt/observium/mibs/ udp:sw2.ahf:161 dot1dStpPortEntry #/usr/bin/snmpbulkwalk -v2c -c kglk5g3l454@988 -OQUs -m BRIDGE-MIB -M /opt/observium/mibs/ udp:sw2.ahf:161 dot1dBasePortEntry // FIXME - do this only when vlan type == ethernet? if (is_numeric($vlan_id) && ($vlan_id < 1002 || $vlan_id > 1105)) { if ($device['os_group'] == "cisco" || $device['os'] == "ios") { # Probably does not work with snmpv3. I have no real idea about what this code is really doing $vlan_device = array_merge($device, array('community' => $device['community'] . "@" . $vlan_id)); $vlan_data = snmpwalk_cache_oid($vlan_device, "dot1dStpPortEntry", array(), "BRIDGE-MIB:Q-BRIDGE-MIB"); $vlan_data = snmpwalk_cache_oid($vlan_device, "dot1dBasePortEntry", $vlan_data, "BRIDGE-MIB:Q-BRIDGE-MIB"); } echo "VLAN {$vlan_id} \n"; if ($vlan_data) { echo str_pad("dot1d id", 10) . str_pad("ifIndex", 10) . str_pad("Port Name", 25) . str_pad("Priority", 10) . str_pad("State", 15) . str_pad("Cost", 10) . "\n"; } foreach ($vlan_data as $vlan_port_id => $vlan_port) { $port = get_port_by_index_cache($device, $vlan_port['dot1dBasePortIfIndex']); echo str_pad($vlan_port_id, 10) . str_pad($vlan_port['dot1dBasePortIfIndex'], 10) . str_pad($port['ifDescr'], 25) . str_pad($vlan_port['dot1dStpPortPriority'], 10) . str_pad($vlan_port['dot1dStpPortState'], 15) . str_pad($vlan_port['dot1dStpPortPathCost'], 10); $db_w = array('device_id' => $device['device_id'], 'port_id' => $port['port_id'], 'vlan' => $vlan_id); $db_a['baseport'] = $vlan_port_id; $db_a['priority'] = isset($vlan_port['dot1dStpPortPriority']) ? $vlan_port['dot1dStpPortPriority'] : 0; $db_a['state'] = isset($vlan_port['dot1dStpPortState']) ? $vlan_port['dot1dStpPortState'] : "unknown"; $db_a['cost'] = isset($vlan_port['dot1dStpPortPathCost']) ? $vlan_port['dot1dStpPortPathCost'] : 0; $from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?", array($device['device_id'], $port['port_id'], $vlan_id)); if ($from_db['port_vlan_id']) { dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", array($from_db['port_vlan_id'])); echo "Updated"; } else { dbInsert(array_merge($db_w, $db_a), 'ports_vlans'); echo "Inserted"; } echo "\n";
$port_db[$db_port['eigrp_vpn'] . '-' . $db_port['eigrp_as'] . '-' . $db_port['eigrp_ifIndex']] = $db_port; } if (OBS_DEBUG && count($port_db)) { print_vars($port_db); } $device_context = $device; if (!count($port_db) && !preg_match('/[a-z](60|65|76)\\d{2}/i', $device['hardware'])) { // Since I'm not sure that this MIB supported on other platforms, set retry to 0 for speedup $device_context['snmp_retries'] = 0; } $ports_poll = snmpwalk_cache_oid($device_context, 'CEigrpInterfaceEntry', array(), 'CISCO-EIGRP-MIB'); unset($device_context); foreach ($ports_poll as $id => $eigrp_port) { list($vpn, $as, $ifIndex) = explode('.', $id); echo "{$vpn} {$as} {$ifIndex}" . PHP_EOL; $port = get_port_by_index_cache($device['device_id'], $ifIndex); if (is_array($port_db[$vpn . '-' . $as . '-' . $ifIndex])) { $eigrp_update = NULL; if ($port['port_id'] != $port_db[$vpn . '-' . $as . '-' . $ifIndex]['port_id']) { $eigrp_update['port_id'] = $port['port_id']; } if ($eigrp_port['cEigrpAuthMode'] != $port_db[$vpn . '-' . $as . '-' . $ifIndex]['eigrp_authmode']) { $eigrp_update['eigrp_authmode'] = $eigrp_port['cEigrpAuthMode']; } if ($eigrp_port['cEigrpMeanSrtt'] != $port_db[$vpn . '-' . $as . '-' . $ifIndex]['eigrp_MeanSrtt']) { $eigrp_update['eigrp_MeanSrtt'] = $eigrp_port['cEigrpMeanSrtt']; } if (is_array($eigrp_update)) { dbUpdate($eigrp_update, 'eigrp_ports', '`eigrp_port_id` = ?', array($port_db[$vpn . '-' . $as . '-' . $ifIndex]['eigrp_port_id'])); } unset($eigrp_update);
<?php echo "Port Stacks: "; $query = "SELECT * FROM `ports_stack` WHERE `device_id` = ?"; foreach (dbFetchRows($query, array($device['device_id'])) as $entry) { $stack_db_array[$entry['port_id_high']][$entry['port_id_low']]['ifStackStatus'] = $entry['ifStackStatus']; } $stack_poll_array = snmpwalk_cache_twopart_oid($device, "ifStackStatus", array()); foreach ($stack_poll_array as $port_id_high => $entry_high) { $port_high = get_port_by_index_cache($device, $port_id_high); if ($port_high['ifType'] == 'propVirtual') { continue; } //Skip stacking on Vlan ports (F.u. Cisco SB) foreach ($entry_high as $port_id_low => $entry_low) { $port_low = get_port_by_index_cache($device, $port_id_low); if ($port_low['ifType'] == 'propVirtual') { continue; } //Skip stacking on Vlan ports (F.u. Cisco SB) $ifStackStatus = $entry_low['ifStackStatus']; if (isset($stack_db_array[$port_id_high][$port_id_low])) { if ($stack_db_array[$port_id_high][$port_id_low]['ifStackStatus'] == $ifStackStatus) { echo "."; } else { $update_array = array('ifStackStatus' => $ifStackStatus); dbUpdate($update_array, 'ports_stack', "`device_id` = ? AND `port_id_high` = ? AND `port_id_low` = ?", array($device['device_id'], $port_id_high, $port_id_low)); echo "U"; } unset($stack_db_array[$port_id_high][$port_id_low]); } else {
} else { dbInsert(array('device_id' => $device['device_id'], 'vlan_domain' => $vtpdomain_id, 'vlan_vlan' => $vlan_id, 'vlan_name' => $vlan['dot1qVlanStaticName'], 'vlan_type' => array('NULL')), 'vlans'); $module_stats[$vlan_id]['V'] = '+'; } $device['vlans'][$vtpdomain_id][$vlan_id] = $vlan_id; //Set Q-BRIDGE ports Vlan table (not work on FTOS for now) if ($device['os'] != 'ftos') { $parts = explode(' ', $vlan['dot1qVlanStaticEgressPorts']); $binary = ''; foreach ($parts as $part) { $binary .= zeropad(base_convert($part, 16, 2), 8); } $length = strlen($binary); for ($i = 0; $i < $length; $i++) { if ($binary[$i]) { $port = get_port_by_index_cache($device, $i + $vlan_ifindex_min); if (isset($ports_vlans_db[$port['port_id']][$vlan_id])) { $ports_vlans[$port['port_id']][$vlan_id] = $ports_vlans_db[$port['port_id']][$vlan_id]['port_vlan_id']; $module_stats[$vlan_id]['P'] = '.'; } else { $db_w = array('device_id' => $device['device_id'], 'port_id' => $port['port_id'], 'vlan' => $vlan_id); $id = dbInsert($db_w, 'ports_vlans'); $module_stats[$vlan_id]['P'] = '+'; $ports_vlans[$port['port_id']][$vlan_id] = $id; } } } } } echo PHP_EOL; // EOF
$stateoid = '.1.3.6.1.4.1.9.9.500.1.2.1.1.6.' . $index; $statedescr = 'Switch ' . $entry['cswSwitchNumCurrent'] . ' stacking state'; if ($stack_count === 1 && $entry['cswSwitchNumCurrent'] == 1 && $stackredundant == 'false' && $ports_down === 2 && $entry['cswSwitchRole'] == 'master' && $entry['cswSwitchState'] == 'ready') { // Heh, on IOS 15.x stacking is always enabled and does not have any way to detect if stack module exists and stacking is configured $stack_count = 0; print_debug("Stacking exists, but not configured and not active."); break; // exit foreach } if (!empty($entry['cswSwitchRole'])) { discover_status($device, $roleoid, "cswSwitchRole.{$index}", 'cisco-stackwise-member-state', $roledescr, $entry['cswSwitchRole'], array('entPhysicalClass' => 'stack', 'entPhysicalIndex' => $index)); discover_status($device, $stateoid, "cswSwitchState.{$index}", 'cisco-stackwise-switch-state', $statedescr, $entry['cswSwitchState'], array('entPhysicalClass' => 'stack', 'entPhysicalIndex' => $index)); } } if ($stack_count) { $oid = '.1.3.6.1.4.1.9.9.500.1.1.3.0'; $descr = 'Stack is redundant'; discover_status($device, $oid, "cswRingRedundant.0", 'cisco-stackwise-redundant-state', $descr, $stackredundant, array('entPhysicalClass' => 'stack')); foreach ($stackportoper as $index => $entry) { $oid = '.1.3.6.1.4.1.9.9.500.1.2.2.1.1.' . $index; $port = get_port_by_index_cache($device, $index); $descr = 'Stackport ' . $port['port_label']; if (!empty($entry['cswStackPortOperStatus'])) { $options = array('entPhysicalClass' => 'port', 'entPhysicalIndex' => $index, 'measured_class' => 'port', 'measured_entity' => $port['port_id']); discover_status($device, $oid, "cswStackPortOperStatus.{$index}", 'cisco-stackwise-port-oper-state', $descr, $entry['cswStackPortOperStatus'], $options); } } } } unset($device_tmp); // EOF
// JUNIPER-DOM-MIB # jnxDomCurrentTxLaserOutputPower[508] -507 0.01 dbm if ($device['os'] == "junos" || $device['os_group'] == "junose") { echo "JUNIPER-DOM-MIB (TX) "; $oids = snmpwalk_cache_oid($device, "jnxDomCurrentTxLaserOutputPower", array(), "JUNIPER-DOM-MIB", mib_dirs('junos')); $oids = snmpwalk_cache_oid($device, "jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold", $oids, "JUNIPER-DOM-MIB", mib_dirs('junos')); $oids = snmpwalk_cache_oid($device, "jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold", $oids, "JUNIPER-DOM-MIB", mib_dirs('junos')); $oids = snmpwalk_cache_oid($device, "jnxDomCurrentTxLaserOutputPowerHighWarningThreshold", $oids, "JUNIPER-DOM-MIB", mib_dirs('junos')); $oids = snmpwalk_cache_oid($device, "jnxDomCurrentTxLaserOutputPowerLowWarningThreshold", $oids, "JUNIPER-DOM-MIB", mib_dirs('junos')); if (is_array($oids)) { foreach ($oids as $index => $entry) { $entry['descr'] = snmp_get($device, "ifDescr." . $index, "-Oqv") . " tx output power"; $entry['oid'] = ".1.3.6.1.4.1.2636.3.60.1.1.1.1.7." . $index; $entry['current'] = $entry['jnxDomCurrentTxLaserOutputPower'] / 100; $entry['low'] = $entry['jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold'] / 100; $entry['loww'] = $entry['jnxDomCurrentTxLaserOutputPowerLowWarningThreshold'] / 100; $entry['high'] = $entry['jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold'] / 100; $entry['highw'] = $entry['jnxDomCurrentTxLaserOutputPowerHighWarningThreshold'] / 100; $entry['port'] = get_port_by_index_cache($device['device_id'], $index); if (is_array($entry['port'])) { $entry['e_t'] = 'port'; $entry['e_e'] = $entry['port']['port_id']; } discover_sensor($valid['sensor'], 'dbm', $device, $entry['oid'], $index, 'juniper-dom-tx', $entry['descr'], '100', '1', $entry['low'], $entry['loww'], $entry['high'], $entry['highw'], $entry['current'], 'snmp', NULL, NULL, $entry['e_t'], $entry['e_e']); } } } ?>
* Observium * * This file is part of Observium. * * @package observium * @subpackage graphs * @copyright (C) 2006-2014 Adam Armstrong * */ // Get port ID by ifIndex/ifDescr/ifAlias or customer circuit // variables: ifindex, ifdescr (or port), ifalias, circuit if (!is_numeric($vars['id'])) { if (is_numeric($device['device_id'])) { if (is_numeric($vars['ifindex'])) { // Get port by ifIndex $port = get_port_by_index_cache($device['device_id'], $vars['ifindex']); if ($port) { $vars['id'] = $port['port_id']; } } elseif (!empty($vars['ifdescr'])) { // Get port by ifDescr $port_id = get_port_id_by_ifDescr($device['device_id'], $vars['ifdescr']); if ($port_id) { $vars['id'] = $port_id; } } elseif (!empty($vars['port'])) { // Get port by ifDescr (backward compatibility) $port_id = get_port_id_by_ifDescr($device['device_id'], $vars['port']); if ($port_id) { $vars['id'] = $port_id; }
// nbsCmmcPortName.1.2.3 = XFP at 1.2.3 // nbsCmmcPortTemperature.1.2.3 = 56 // nbsCmmcPortTxPower.1.2.3 = -2569 // nbsCmmcPortRxPower.1.2.3 = -3045 // nbsCmmcPortBiasAmps.1.2.3 = 46863 // nbsCmmcPortSupplyVolts.1.2.3 = 3329 $oid_list = array('nbsCmmcPortName', 'nbsCmmcPortIfIndex', 'nbsCmmcPortTemperature', 'nbsCmmcPortTxPower', 'nbsCmmcPortRxPower', 'nbsCmmcPortBiasAmps', 'nbsCmmcPortSupplyVolts'); $oids = array(); foreach ($oid_list as $oid) { $oids = snmpwalk_cache_oid($device, $oid, $oids, "NBS-CMMC-MIB"); } foreach ($oids as $index => $port) { $name = $port['nbsCmmcPortName']; $options = array(); if (is_numeric($port['nbsCmmcPortIfIndex'])) { $db_port = get_port_by_index_cache($device['device_id'], $port['nbsCmmcPortIfIndex']); if (is_array($db_port)) { $options['measured_class'] = 'port'; $options['measured_entity'] = $db_port['port_id']; } } if ($port['nbsCmmcPortTemperature'] != -2147483648) { $sensor_oid = '.1.3.6.1.4.1.629.200.8.1.1.30.' . $index; discover_sensor($valid['sensor'], "temperature", $device, $sensor_oid, $index, 'nbsCmmcPortTemperature', $port['nbsCmmcPortName'], 1, $port['nbsCmmcPortTemperature'], $options); } if ($port['nbsCmmcPortTxPower'] != -2147483648) { $sensor_oid = '.1.3.6.1.4.1.629.200.8.1.1.31.' . $index; discover_sensor($valid['sensor'], "dbm", $device, $sensor_oid, $index, 'nbsCmmcPortTxPower', $port['nbsCmmcPortName'] . ' TX Power', 0.001, $port['nbsCmmcPortTxPower'], $options); } if ($port['nbsCmmcPortRxPower'] != -2147483648) { $sensor_oid = '.1.3.6.1.4.1.629.200.8.1.1.32.' . $index;
$remote_device = dbFetchCell('SELECT `device_id` FROM `' . $peer_addr_type . '_addresses` LEFT JOIN `ports` USING(`port_id`) WHERE `' . $peer_addr_type . '_address` = ? LIMIT 1;', array($peer_addr)); } else { $peer_rdns = ''; $peer_addr = ''; // Unset peer address print_debug("Not found correct peer address. See snmpwalk for 'jnxVpnRemotePeIdAddress'."); } if (empty($remote_device)) { $remote_device = array('NULL'); } if (!is_numeric($pw['jnxVpnPwAssociatedInterface']) || $pw['jnxVpnPwAssociatedInterface'] <= 0) { $pw['jnxVpnPwAssociatedInterface'] = $pw_ifIndex; } $port = get_port_by_index_cache($device, $pw['jnxVpnPwAssociatedInterface']); if (is_numeric($port['port_id'])) { $if_id = $port['port_id']; } else { $if_id = get_port_id_by_ifDescr($device['device_id'], $pw_name); } $pws_new = array('device_id' => $device['device_id'], 'mib' => 'JUNIPER-VPN-MIB', 'port_id' => $if_id, 'peer_device_id' => $remote_device, 'peer_addr' => $peer_addr, 'peer_rdns' => $peer_rdns, 'pwIndex' => $pw_index, 'pwType' => $pw_type, 'pwID' => $pw['jnxVpnPwLocalSiteId'], 'pwOutboundLabel' => $pw['jnxVpnPwLocalSiteId'], 'pwInboundLabel' => $pw['jnxVpnPwRemoteSiteId'], 'pwPsnType' => $pw['jnxVpnPwTunnelType'] ? $pw['jnxVpnPwTunnelType'] : 'unknown', 'pwDescr' => $pw['jnxVpnPwTunnelName'] ? $pw['jnxVpnPwTunnelName'] : $pw_name, 'pwRowStatus' => $pw['jnxVpnPwRowStatus']); if (OBS_DEBUG > 1) { print_vars($pws_new); } if (!empty($pws_cache['pws_db']['JUNIPER-VPN-MIB'][$pw_index])) { $pws_old = $pws_cache['pws_db']['JUNIPER-VPN-MIB'][$pw_index]; $pseudowire_id = $pws_old['pseudowire_id']; if (empty($pws_old['peer_device_id'])) { $pws_old['peer_device_id'] = array('NULL'); }
//F10-S-SERIES-CHASSIS-MIB::chSysPortXfpTxPower.1.2 = INTEGER: -5.36 dB //F10-S-SERIES-CHASSIS-MIB::chSysPortXfpTxPower.13.1 = INTEGER: .00 dB $oids = snmpwalk_cache_oid($device, "chSysPortIfIndex", array(), "F10-S-SERIES-CHASSIS-MIB"); if (count($oids)) { $oids = snmpwalk_cache_oid($device, "chSysPortXfpRecvPower", $oids, "F10-S-SERIES-CHASSIS-MIB"); $oids = snmpwalk_cache_oid($device, "chSysPortXfpTxPower", $oids, "F10-S-SERIES-CHASSIS-MIB"); $oids = snmpwalk_cache_oid($device, "chSysPortXfpRecvTemp", $oids, "F10-S-SERIES-CHASSIS-MIB"); if (OBS_DEBUG > 1) { print_vars($oids); } foreach ($oids as $index => $entry) { if ($entry['chSysPortXfpRecvPower'] === '655.35' && $entry['chSysPortXfpTxPower'] === '655.35' && $entry['chSysPortXfpRecvTemp'] === '65535' || $entry['chSysPortXfpRecvPower'] === '.00' && $entry['chSysPortXfpTxPower'] === '.00' && $entry['chSysPortXfpRecvTemp'] === '0' || $entry['chSysPortXfpRecvPower'] === '.00' && !is_numeric($entry['chSysPortXfpTxPower']) && !is_numeric($entry['chSysPortXfpRecvTemp'])) { continue; } list(, $entPhysicalIndex) = explode('.', $index); $port = get_port_by_index_cache($device['device_id'], $entry['chSysPortIfIndex']); $options = array('entPhysicalIndex' => $entPhysicalIndex, 'measured_class' => 'port', 'measured_entity' => $port['port_id']); if (is_numeric($entry['chSysPortXfpRecvPower'])) { $oid = ".1.3.6.1.4.1.6027.3.10.1.2.5.1.6." . $index; $descr = $port['ifDescr'] . " RX Power"; $value = $entry['chSysPortXfpRecvPower'] * 100; discover_sensor($valid['sensor'], 'dbm', $device, $oid, $index, 'f10-s-series-dom-rx', $descr, 0.01, $value, $options); } if (is_numeric($entry['chSysPortXfpTxPower'])) { $oid = ".1.3.6.1.4.1.6027.3.10.1.2.5.1.8." . $index; $descr = $port['ifDescr'] . " TX Power"; $value = $entry['chSysPortXfpTxPower'] * 100; discover_sensor($valid['sensor'], 'dbm', $device, $oid, $index, 'f10-s-series-dom-tx', $descr, 0.01, $value, $options); } if (is_numeric($entry['chSysPortXfpRecvTemp'])) { $oid = ".1.3.6.1.4.1.6027.3.10.1.2.5.1.7." . $index;
<?php /* * LibreNMS * * Copyright (c) 2016 Søren Friis Rosiak <*****@*****.**> * 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. */ if ($device['os'] == 'ciscosb') { echo 'CiscoSB: '; $temp = snmpwalk_cache_multi_oid($device, 'rlPethPsePortEntry', array(), 'CISCOSB-POE-MIB'); if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.6.1.101.108.1.1.5.'; $divisor = '1000'; foreach ($temp as $index => $entry) { if (is_numeric($temp[$index]['rlPethPsePortOutputPower']) && $temp[$index]['rlPethPsePortOutputPower'] > 0) { $port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index)); $descr = $port_descr['ifDescr'] . ' PoE'; $highlimit = $temp[$index]['rlPethPsePortOperPowerLimit'] / $divisor; discover_sensor($valid['sensor'], 'power', $device, $cur_oid . $index, $index, 'ciscosb', $descr, $divisor, '1', null, null, null, $highlimit, $temp[$index]['rlPethPsePortOutputPower'] / $divisor, 'snmp', $index); } } } }
# } # } # } # return $new_array; #} $acc_id = array(); // Count exist ma_ids if (count($ma_array)) { if (OBS_DEBUG > 1) { print_vars($ma_array); } $polled = time(); $mac_entries = 0; echo 'Entries: ' . count($ma_array) . PHP_EOL; foreach ($ma_array as $id => $ma) { $port = get_port_by_index_cache($device['device_id'], $ma['ifIndex']); echo ' ' . $id . ' '; if (!is_array($ma_db_array[$id])) { $ma_id = dbInsert(array('port_id' => $port['port_id'], 'device_id' => $device['device_id'], 'vlan_id' => $ma['vlan'], 'mac' => $ma['mac']), 'mac_accounting'); if ($ma_id) { //$ma_id = dbFetchCell('SELECT * FROM mac_accounting WHERE port_id = ? AND device_id = ? AND vlan_id = ? AND mac = ?', array($port['port_id'], $device['device_id'], $ma['vlan'], $ma['mac'])); dbInsert(array('ma_id' => $ma_id), 'mac_accounting-state'); echo '+'; $acc_id[$ma_id] = $ma_id; } else { echo '-'; continue; // wrong adding to DB, not exist id - delete } } else { echo '.';
$states = array(array($state_index_id, 'waiting', 0, 1, 1), array($state_index_id, 'progressing', 0, 2, 1), array($state_index_id, 'added', 0, 3, 1), array($state_index_id, 'ready', 0, 4, 0), array($state_index_id, 'sdmMismatch', 0, 5, 2), array($state_index_id, 'verMismatch', 0, 6, 2), array($state_index_id, 'featureMismatch', 0, 7, 2), array($state_index_id, 'newMasterInit', 0, 8, 2), array($state_index_id, 'provisioned', 0, 9, 1), array($state_index_id, 'invalid', 0, 10, 2), array($state_index_id, 'removed', 0, 11, 1)); } else { $states = array(array($state_index_id, 'normal', 0, 1, 0), array($state_index_id, 'warning', 0, 2, 1), array($state_index_id, 'critical', 0, 3, 2), array($state_index_id, 'shutdown', 0, 4, 3), array($state_index_id, 'notPresent', 0, 5, 3), array($state_index_id, 'notFunctioning', 0, 6, 2)); } foreach ($states as $value) { $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]); dbInsert($insert, 'state_translations'); } } foreach ($temp as $index => $entry) { //Discover Sensors $descr = ucwords($temp[$index][$tablevalue[3]]); if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState' || $state_name == 'cRFCfgRedundancyOperMode' || $state_name == 'cswRingRedundant') { $descr = $tablevalue[3]; } elseif ($state_name == 'cswSwitchRole') { $swrolenumber++; $descr = $tablevalue[3] . $swrolenumber; } elseif ($state_name == 'cswSwitchState') { $swstatenumber++; $descr = $tablevalue[3] . $swstatenumber; } elseif ($state_name == 'cswStackPortOperStatus') { $stack_port_descr = get_port_by_index_cache($device, $index); $descr = $tablevalue[3] . $stack_port_descr['ifDescr']; } discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index); //Create Sensor To State Index create_sensor_to_state_index($device, $state_name, $index); } } } }
function generate_port_row($port, $vars = array()) { global $config, $cache; $device = device_by_id_cache($port['device_id']); humanize_port($port); if (!isset($vars['view'])) { $vars['view'] = "basic"; } // Populate $port_adsl if the port has ADSL-MIB data if (!isset($cache['ports_option']['ports_adsl']) || in_array($port['port_id'], $cache['ports_option']['ports_adsl'])) { $port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])); } // Populate $port['tags'] with various tags to identify port statuses and features // Port Errors if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) { $port['tags'] .= generate_port_link($port, '<span class="label label-important">Errors</span>', 'port_errors'); } // Port Deleted if ($port['deleted'] == '1') { $port['tags'] .= '<a href="' . generate_url(array('page' => 'deleted-ports')) . '"><span class="label label-important">Deleted</span></a>'; } // Port CBQoS if (isset($cache['ports_option']['ports_cbqos'])) { if (in_array($port['port_id'], $cache['ports_option']['ports_cbqos'])) { $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>'; } } else { if (dbFetchCell("SELECT COUNT(*) FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']))) { $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>'; } } // Port MAC Accounting if (isset($cache['ports_option']['mac_accounting'])) { if (in_array($port['port_id'], $cache['ports_option']['mac_accounting'])) { $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>'; } } else { if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?", array($port['port_id']))) { $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>'; } } // Populated formatted versions of port rates. $port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8); $port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8); $port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps"; $port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps"; $string = ''; if ($vars['view'] == "basic" || $vars['view'] == "graphs") { $table_cols = '8'; $string .= '<tr class="' . $port['row_class'] . '"> <td class="state-marker"></td> <td style="width: 1px;"></td>'; if ($vars['page'] != "device" && $vars['popup'] != TRUE) { $table_cols++; // Increment table columns by one to make sure graph line draws correctly $string .= ' <td style="width: 200px;"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br /> <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>'; } $string .= ' <td><span class="entity">' . generate_port_link($port, rewrite_ifname($port['port_label'])) . ' ' . $port['tags'] . '</span><br /> <span class="em">' . escape_html(truncate($port['ifAlias'], 50, '')) . '</span></td>' . '<td style="width: 110px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td style="width: 90px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td style="width: 110px;"><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . '<td style="width: 110px;"><small>' . $port['human_speed'] . '<br />' . $port['ifMtu'] . '</small></td> <td ><small>' . $port['human_type'] . '<br />' . $port['human_mac'] . '</small></td> </tr>'; } else { if ($vars['view'] == "details" || $vars['view'] == "detail") { $table_cols = '9'; $string .= '<tr class="' . $port['row_class'] . '"'; if ($vars['tab'] != "port") { $string .= ' onclick="openLink(\'' . generate_port_url($port) . '\')" style="cursor: pointer;"'; } $string .= '>'; $string .= ' <td class="state-marker"></td> <td style="width: 1px;"></td>'; if ($vars['page'] != "device" && $vars['popup'] != TRUE) { $table_cols++; // Increment table columns by one to make sure graph line draws correctly $string .= ' <td width="200"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br /> <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>'; } $string .= ' <td style="min-width: 250px;">'; $string .= ' <span class="entity-title"> ' . generate_port_link($port) . ' ' . $port['tags'] . ' </span><br /><span class="small">' . escape_html($port['ifAlias']) . '</span>'; if ($port['ifAlias']) { $string .= '<br />'; } unset($break); if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) { foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) { $string .= $break . generate_popup_link('ip', $ip['ipv4_address'] . '/' . $ip['ipv4_prefixlen'], NULL, 'small'); $break = "<br />"; } } if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) { foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) { $string .= $break . generate_popup_link('ip', $ip6['ipv6_address'] . '/' . $ip6['ipv6_prefixlen'], NULL, 'small'); $break = "<br />"; } } //$string .= '</span>'; $string .= '</td>'; // Print port graph thumbnails $string .= '<td style="width: 147px;">'; $port['graph_type'] = "port_bits"; $graph_array = array(); $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $port['port_id']; $graph_array['type'] = $port['graph_type']; $graph_array['width'] = 100; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; $graph_array['from'] = $config['time']['day']; $string .= generate_port_link($port, generate_graph_tag($graph_array)); $port['graph_type'] = "port_upkts"; $graph_array['type'] = $port['graph_type']; $string .= generate_port_link($port, generate_graph_tag($graph_array)); $port['graph_type'] = "port_errors"; $graph_array['type'] = $port['graph_type']; $string .= generate_port_link($port, generate_graph_tag($graph_array)); $string .= '</td>'; $string .= '<td style="width: 100px; white-space: nowrap;">'; if ($port['ifOperStatus'] == "up" || $port['ifOperStatus'] == "monitoring") { // Colours generated by humanize_port $string .= '<i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br /> <i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /> <i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br /> <i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span>'; } $string .= '</td><td style="width: 110px;">'; if ($port['ifType'] && $port['ifType'] != "") { $string .= '<span class="small">' . $port['human_type'] . '</span>'; } else { $string .= '-'; } $string .= '<br />'; if ($port['ifSpeed']) { $string .= '<span class="small">' . humanspeed($port['ifSpeed']) . '</span>'; } if ($port['ifDuplex'] && $port['ifDuplex'] != "unknown") { $string .= '<span class="small"> (' . str_replace("Duplex", "", $port['ifDuplex']) . ')</span>'; } $string .= '<br />'; if ($port['ifMtu'] && $port['ifMtu'] != "") { $string .= '<span class="small">MTU ' . $port['ifMtu'] . '</span>'; } else { $string .= '<span class="small">Unknown MTU</span>'; } // if ($ifHardType && $ifHardType != "") { $string .= '<span class="small">" . $ifHardType . "</span>"); } else { $string .= '-'; } //$string .= '<br />'; // Set VLAN data if the port has ifTrunk populated if ($port['ifTrunk']) { if ($port['ifVlan']) { // Native VLAN if (!isset($cache['ports_vlan'])) { $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id'])); $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan'])); } else { $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state']; $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name']; } switch ($native_state) { case 'blocking': $class = 'text-danger'; break; case 'forwarding': $class = 'text-success'; break; default: $class = 'muted'; } if (empty($native_name)) { $native_name = 'VLAN' . str_pad($port['ifVlan'], 4, '0', STR_PAD_LEFT); } $native_tooltip = 'NATIVE: <strong class=' . $class . '>' . $port['ifVlan'] . ' [' . $native_name . ']</strong><br />'; } if (!isset($cache['ports_vlan'])) { $vlans = dbFetchRows('SELECT * FROM `ports_vlans` AS PV LEFT JOIN vlans AS V ON PV.`vlan` = V.`vlan_vlan` AND PV.`device_id` = V.`device_id` WHERE PV.`port_id` = ? AND PV.`device_id` = ? ORDER BY PV.`vlan`;', array($port['port_id'], $device['device_id'])); } else { $vlans = $cache['ports_vlan'][$port['port_id']]; } $vlans_count = count($vlans); $rel = $vlans_count || $native_tooltip ? 'tooltip' : ''; // Hide tooltip for empty $string .= '<p class="small"><a class="label label-info" data-rel="' . $rel . '" data-tooltip="<div class=\'small\' style=\'max-width: 320px; text-align: justify;\'>' . $native_tooltip; if ($vlans_count) { $string .= 'ALLOWED: '; $vlans_aggr = array(); foreach ($vlans as $vlan) { if ($vlans_count > 20) { // Aggregate VLANs $vlans_aggr[] = $vlan['vlan']; } else { // List VLANs switch ($vlan['state']) { case 'blocking': $class = 'text-danger'; break; case 'forwarding': $class = 'text-success'; break; default: $class = 'muted'; } if (empty($vlan['vlan_name'])) { 'VLAN' . str_pad($vlan['vlan'], 4, '0', STR_PAD_LEFT); } $string .= '<strong class=' . $class . '>' . $vlan['vlan'] . ' [' . $vlan['vlan_name'] . ']</strong><br />'; } } if ($vlans_count > 20) { // End aggregate VLANs $string .= '<strong>' . range_to_list($vlans_aggr, ', ') . '</strong>'; } } $string .= '</div>">' . $port['ifTrunk'] . '</a></p>'; } else { if ($port['ifVlan']) { if (!isset($cache['ports_vlan'])) { $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id'])); $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan'])); } else { $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state']; $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name']; } switch ($native_state) { case 'blocking': $class = 'label-error'; break; case 'forwarding': $class = 'label-success'; break; default: $class = ''; } $rel = $native_name ? 'tooltip' : ''; // Hide tooltip for empty $string .= '<br /><span data-rel="' . $rel . '" class="label ' . $class . '" data-tooltip="<strong class=\'small\'>' . $port['ifVlan'] . ' [' . $native_name . ']</strong>">VLAN ' . $port['ifVlan'] . '</span>'; } else { if ($port['ifVrf']) { $vrf_name = dbFetchCell("SELECT `vrf_name` FROM `vrfs` WHERE `vrf_id` = ?", array($port['ifVrf'])); $string .= '<br /><span class="label label-success" data-rel="tooltip" data-tooltip="VRF">' . $vrf_name . '</span>'; } } } $string .= '</td>'; // If the port is ADSL, print ADSL port data. if ($port_adsl['adslLineCoding']) { $string .= '<td style="width: 200px;"><span class="small">'; $string .= '<span class="label">' . $port_adsl['adslLineCoding'] . '</span> <span class="label">' . rewrite_adslLineType($port_adsl['adslLineType']) . '</span>'; $string .= '<br />'; $string .= 'SYN <i class="icon-circle-arrow-down green"></i> ' . formatRates($port_adsl['adslAtucChanCurrTxRate']) . ' <i class="icon-circle-arrow-up blue"></i> ' . formatRates($port_adsl['adslAturChanCurrTxRate']); $string .= '<br />'; //$string .= 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']) . '/'. formatRates($port_adsl['adslAturCurrAttainableRate']); //$string .= '<br />'; $string .= 'ATN <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrAtn'] . 'dBm <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrAtn'] . 'dBm'; $string .= '<br />'; $string .= 'SNR <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrSnrMgn'] . 'dB <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrSnrMgn'] . 'dB'; $string .= '</span>'; } else { // Otherwise print normal port data $string .= '<td style="width: 150px;"><span class="small">'; if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") { $string .= $port['human_mac']; } else { $string .= '-'; } $string .= '<br />' . $port['ifLastChange'] . '</span>'; } $string .= '</td>'; $string .= '<td style="min-width: 200px" class="small">'; if (strpos($port['port_label'], "oopback") === FALSE && !$graph_type) { unset($br); // Populate links array for ports with direct links if (!isset($cache['ports_option']['neighbours']) || in_array($port['port_id'], $cache['ports_option']['neighbours'])) { foreach (dbFetchRows('SELECT * FROM `neighbours` WHERE `port_id` = ?', array($port['port_id'])) as $neighbour) { // print_r($link); if ($neighbour['remote_port_id']) { $int_links[$neighbour['remote_port_id']] = $neighbour['remote_port_id']; $int_links_phys[$neighbour['remote_port_id']] = 1; } else { $int_links_unknown[] = $neighbour; } } } else { } // Populate links array for devices which share an IPv4 subnet if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) { 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) { //`port_id`,`peer_device_id`,`peer_ldp_id`,`pwID`,`pwIndex` # $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id'])); $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, `pseudowires` AS P WHERE I.`device_id` = ? AND P.`pwID` = ? AND P.`port_id` = I.`port_id`", array($pseudowire['peer_device_id'], $pseudowire['pwID'])); # $pw_peer_int = get_port_by_id_cache($pseudowire['peer_device_id']); $pw_peer_dev = device_by_id_cache($pseudowire['peer_device_id']); if (is_array($pw_peer_int)) { humanize_port($pw_peer_int); $string .= $br . '<i class="oicon-arrow-switch"></i> <strong>' . generate_port_link($pw_peer_int, $pw_peer_int['port_label_short']) . ' on ' . generate_device_link($pw_peer_dev, short_hostname($pw_peer_dev['hostname'])) . '</strong>'; } else { $string .= $br . '<i class="oicon-arrow-switch"></i> <strong> VC ' . $pseudowire['pwID'] . ' on ' . $pseudowire['peer_addr'] . '</strong>'; } $string .= ' <span class="label">' . $pseudowire['pwPsnType'] . '</span>'; $string .= ' <span class="label">' . $pseudowire['pwType'] . '</span>'; $br = "<br />"; } } if (!isset($cache['ports_option']['ports_pagp']) || in_array($port['ifIndex'], $cache['ports_option']['ports_pagp'])) { foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? AND `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) { humanize_port($member); $pagp[$device['device_id']][$port['ifIndex']][$member['ifIndex']] = TRUE; $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($member) . ' [PAgP]</strong>'; $br = "<br />"; } } if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) { $pagp[$device['device_id']][$port['pagpGroupIfIndex']][$port['ifIndex']] = TRUE; $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id'])); humanize_port($parent); $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($parent) . ' [PAgP]</strong>'; $br = "<br />"; } if (!isset($cache['ports_option']['ports_stack_low']) || in_array($port['ifIndex'], $cache['ports_option']['ports_stack_low'])) { 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']) { if ($pagp[$device['device_id']][$higher_if['port_id_high']][$port['ifIndex']]) { continue; } // Skip if same PAgP port $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']); if (is_array($this_port)) { $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($this_port) . '</strong>'; $br = "<br />"; } } } } if (!isset($cache['ports_option']['ports_stack_high']) || in_array($port['ifIndex'], $cache['ports_option']['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)) { $string .= $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); $string .= '</td></tr>'; } } // End Detailed View // If we're showing graphs, generate the graph and print the img tags if ($vars['graph'] == "etherlike") { $graph_file = get_port_rrdfilename($port, "dot3", TRUE); } else { $graph_file = get_port_rrdfilename($port, NULL, TRUE); } if ($vars['graph'] && is_file($graph_file)) { $string .= '<tr><td colspan="' . $table_cols . '">'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $port['port_id']; $graph_array['type'] = 'port_' . $vars['graph']; $string .= generate_graph_row($graph_array); $string .= '</td></tr>'; } return $string; }