本文整理汇总了PHP中get_port_by_index_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP get_port_by_index_cache函数的具体用法?PHP get_port_by_index_cache怎么用?PHP get_port_by_index_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_port_by_index_cache函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: array
$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, '+');
开发者ID:Rosiak,项目名称:librenms,代码行数:31,代码来源:arp-table.inc.php
示例2: get_port_by_index_cache
$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);
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:print-interface.inc.php
示例3: array_merge
#/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";
开发者ID:REAP720801,项目名称:librenms,代码行数:31,代码来源:vlans.inc.php
示例4: print_vars
$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);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:cisco-eigrp.inc.php
示例5: foreach
<?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 {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:ports-stack.inc.php
示例6: dbInsert
} 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
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:q-bridge-mib.inc.php
示例7: print_debug
$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
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:cisco-stackwise-mib.inc.php
示例8: snmpwalk_cache_oid
// 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']);
}
}
}
?>
开发者ID:RomanBogachev,项目名称:observium,代码行数:28,代码来源:junos-dom-tx.inc.php
示例9: get_port_by_index_cache
* 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;
}
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:auth.inc.php
示例10: array
// 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;
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:nbs-cmmc-mib.inc.php
示例11: dbFetchCell
$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');
}
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:juniper-vpn-mib.inc.php
示例12: snmpwalk_cache_oid
//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;
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:f10-s-series-chassis-mib.inc.php
示例13: snmpwalk_cache_multi_oid
<?php
/*
* LibreNMS
*
* Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
* 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);
}
}
}
}
开发者ID:Rosiak,项目名称:librenms,代码行数:28,代码来源:ciscosb.inc.php
示例14: array
# }
# }
# }
# 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 '.';
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:mac-accounting.inc.php
示例15: array
$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);
}
}
}
}
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:cisco.inc.php
示例16: generate_port_row
//.........这里部分代码省略.........
$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;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:port.inc.php
注:本文中的get_port_by_index_cache函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论