initial commit; version 22.5.12042

This commit is contained in:
2022-12-12 23:28:25 -05:00
commit af1b03d79f
17653 changed files with 22692970 additions and 0 deletions

View File

@ -0,0 +1,188 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// IP-MIB contains two tables:
// ipNetToMediaTable -- deprecated, as it contains only entries for IPv4.
// ipNetToPhysicalTable -- current, address version agnostic table
// IPV6-MIB has been abandoned in favor of the revised IP-MIB, but has one table:
// ipv6NetToMediaTable
// CISCO-IETF-IP-MIB -- based on an early draft of the revised IP-MIB
// cInetNetToMediaTable
unset($mac_table);
// Caching ifIndex
$query = 'SELECT `port_id`, `ifIndex` FROM `ports` WHERE `device_id` = ? GROUP BY `port_id`';
foreach (dbFetchRows($query, array($device['device_id'])) as $entry) {
$entry_if = $entry['ifIndex'];
$interface[$entry_if] = $entry['port_id'];
}
/// FIXME. Here necessary to use snmpwalk_cache_oid, but snmpwalk_cache_oid() not support custom options like (-OXqs) for parser. -- mike
/// Duplicate the function to use -OX. The SNMP specific stuff is all elsewhere, so shouldn't be too much duplicated -- adama
// FIXME check is_device_mib first!
// First check IP-MIB::ipNetToPhysicalPhysAddress (IPv4 & IPv6)
//ipNetToPhysicalPhysAddress[5][ipv4]["80.93.52.129"] 0:23:ab:64:d:42
//ipNetToPhysicalPhysAddress[34][ipv6]["2a:01:00:d8:00:00:00:01:00:00:00:00:00:00:00:03"] 0:15:63:e8:fb:31:0:0
$ipNetToPhysicalPhysAddress_oid = snmp_walk($device, 'ipNetToPhysicalPhysAddress', '-OXqs', 'IP-MIB');
if ($ipNetToPhysicalPhysAddress_oid)
{
$oid_data = $ipNetToPhysicalPhysAddress_oid;
print_debug("Used IP-MIB::ipNetToPhysicalPhysAddress");
} else {
$oid_data = '';
if ($device['os_group'] === 'cisco')
{
// Last check CISCO-IETF-IP-MIB::cInetNetToMediaPhysAddress (IPv6 only, Cisco only)
//cInetNetToMediaPhysAddress[167][ipv6]["20:01:0b:08:0b:08:0b:08:00:00:00:00:00:00:00:b1"] 0:24:c4:db:9b:40:0:0
$cInetNetToMediaPhysAddress_oid = snmp_walk($device, 'cInetNetToMediaPhysAddress', '-OXqs', 'CISCO-IETF-IP-MIB');
if ($cInetNetToMediaPhysAddress_oid)
{
$oid_data .= $cInetNetToMediaPhysAddress_oid;
print_debug("Used CISCO-IETF-IP-MIB::cInetNetToMediaPhysAddress");
}
} else {
// Or check IPV6-MIB::ipv6NetToMediaPhysAddress (IPv6 only, deprecated, junos)
//ipv6NetToMediaPhysAddress[18][fe80:0:0:0:200:ff:fe00:4] 2:0:0:0:0:4
$ipv6NetToMediaPhysAddress_oid = snmp_walk($device, 'ipv6NetToMediaPhysAddress', '-OXqs', 'IPV6-MIB');
if ($ipv6NetToMediaPhysAddress_oid)
{
$oid_data .= $ipv6NetToMediaPhysAddress_oid;
print_debug("Used IPV6-MIB::ipv6NetToMediaPhysAddress");
}
}
}
if (!strstr($oid_data, 'ipv4'))
{
// Check IP-MIB::ipNetToMediaPhysAddress (IPv4 only)
//ipNetToMediaPhysAddress[213][10.0.0.162] 70:81:5:ec:f9:bf
$ipNetToMediaPhysAddress_oid = snmp_walk($device, 'ipNetToMediaPhysAddress', '-OXqs', 'IP-MIB');
if ($ipNetToMediaPhysAddress_oid)
{
$oid_data .= $ipNetToMediaPhysAddress_oid;
print_debug("Used IP-MIB::ipNetToMediaPhysAddress");
}
}
$oid_data = trim($oid_data);
// Caching old ARP/NDP table
$query = 'SELECT mac_id, mac_address, ip_address, ip_version, ifIndex FROM ip_mac AS M
LEFT JOIN ports AS I ON M.port_id = I.port_id
WHERE I.device_id = ?';
$cache_arp = dbFetchRows($query, array($device['device_id']));
foreach ($cache_arp as $entry)
{
$old_if = $entry['ifIndex'];
$old_mac = $entry['mac_address'];
$old_address = $entry['ip_address'];
$old_version = $entry['ip_version'];
$old_table[$old_if][$old_version][$old_address] = $old_mac;
}
$ipv4_pattern = '/\[(\d+)\](?:\[ipv4\])?\["?([\d\.]+)"?\]\s+([a-f\d]+):([a-f\d]+):([a-f\d]+):([a-f\d]+):([a-f\d]+):([a-f\d]{1,2})/i';
$ipv6_pattern = '/\[(\d+)\](?:\[ipv6\])?\["?([a-f\d:]+)"?\]\s+(?:([a-f\d]+):([a-f\d]+):)?([a-f\d]+):([a-f\d]+):([a-f\d]+):([a-f\d]{1,2})/i';
foreach (explode("\n", $oid_data) as $data)
{
if (preg_match($ipv4_pattern, $data, $matches))
{
$ip = $matches[2];
$ip_version = 4;
}
elseif (preg_match($ipv6_pattern, $data, $matches))
{
if (count(explode(':', $matches[2])) === 8)
{
$ip = Net_IPv6::uncompress($matches[2], TRUE);
}
else
{
$ip = hex2ip($matches[2]);
}
$ip_version = 6;
} else {
// In principle the such shouldn't be.
continue;
}
$if = $matches[1];
$port_id = $interface[$if];
if ($ip && $port_id)
{
if ($matches[3] === '' && $matches[4] === '')
{
// Convert IPv4 to fake MAC for 6to4 tunnels
//ipNetToPhysicalPhysAddress[27][ipv6]["20:02:c0:58:63:01:00:00:00:00:00:00:00:00:00:00"] 0:0:c0:58
$matches[3] = 'ff';
$matches[4] = 'fe';
}
$mac = zeropad($matches[3]);
for ($i = 4; $i <= 8; $i++) { $mac .= ':' . zeropad($matches[$i]); }
$clean_mac = str_replace(':', '', $mac);
$mac_table[$if][$ip_version][$ip] = $clean_mac;
if (isset($old_table[$if][$ip_version][$ip]))
{
$old_mac = $old_table[$if][$ip_version][$ip];
if ($clean_mac != $old_mac && $clean_mac != '00:00:00:00:00:00' && $old_mac != '00:00:00:00:00:00')
{
print_debug("Changed MAC address for $ip from ".format_mac($old_mac)." to ".format_mac($clean_mac));
log_event("MAC changed: $ip : " . format_mac($old_mac) . " -> " . format_mac($clean_mac), $device, "port", $port_id);
dbUpdate(array('mac_address' => $clean_mac) , 'ip_mac', 'port_id = ? AND ip_address = ?', array($port_id, $ip));
echo("U");
} else {
echo(".");
}
} else {
$params = array(
'port_id' => $port_id,
'mac_address' => $clean_mac,
'ip_address' => $ip,
'ip_version' => $ip_version);
dbInsert($params, 'ip_mac');
print_debug("Added MAC address ".format_mac($clean_mac)." for $ip");
//log_event("MAC added: $ip : " . format_mac($clean_mac), $device, "port", $port_id);
echo("+");
}
}
}
// Remove expired ARP/NDP entries
$remove_mac_ids = array();
foreach ($cache_arp as $entry)
{
$entry_mac_id = $entry['mac_id'];
$entry_mac = $entry['mac_address'];
$entry_ip = $entry['ip_address'];
$entry_version = $entry['ip_version'];
$entry_if = $entry['ifIndex'];
$entry_port_id = $interface[$entry_if];
if (!isset($mac_table[$entry_if][$entry_version][$entry_ip]))
{
$remove_mac_ids[] = $entry_mac_id;
//dbDelete('ip_mac', 'mac_id = ?', array($entry_mac_id));
print_debug("Removed MAC address ".format_mac($entry_mac)." for $entry_ip");
//log_event("MAC removed: $entry_ip : " . format_mac($entry_mac), $device, "port", $entry['port_id']);
echo("-");
}
}
if (count($remove_mac_ids))
{
dbDelete('ip_mac', '1' . generate_query_values($remove_mac_ids, 'mac_id'));
}
echo(PHP_EOL);
unset($interface, $remove_mac_ids);
// EOF

View File

@ -0,0 +1,407 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// 'BGP4-MIB', 'CISCO-BGP4-MIB', 'BGP4-V2-MIB-JUNIPER', 'FORCE10-BGP4-V2-MIB', 'ARISTA-BGP4V2-MIB', 'FOUNDRY-BGP4V2-MIB', 'HUAWEI-BGP-VPN-MIB'
if (!$config['enable_bgp'] || !is_device_mib($device, 'BGP4-MIB')) {
// Note, BGP4-MIB is main MIB, without it, the rest will not be checked
if ($device['bgpLocalAs']) {
// Clean old discovered peers?
log_event('BGP Local ASN removed: AS' . $device['bgpLocalAs'], $device, 'device', $device['device_id']);
dbUpdate([ 'bgpLocalAs' => [ 'NULL' ] ], 'devices', 'device_id = ?', [ $device['device_id'] ]);
print_cli_data("Updated ASN", $device['bgpLocalAs'] . " -> ''", 2);
}
return;
}
/* Moved to definitions
$vendor_oids = array(
// Juniper BGP4-V2 MIB
'BGP4-V2-MIB-JUNIPER' => array('vendor_use_index' => array('jnxBgpM2PeerRemoteAddr' => 1,
'jnxBgpM2PeerRemoteAddrType' => 1,
'jnxBgpM2PeerLocalAddr' => 1),
'vendor_PeerTable' => 'jnxBgpM2PeerTable',
'vendor_PeerAdminStatus' => 'jnxBgpM2PeerStatus', //'jnxBgpM2CfgPeerAdminStatus' not exist in JunOS
'vendor_PeerRemoteAs' => 'jnxBgpM2PeerRemoteAs',
'vendor_PeerRemoteAddr' => 'jnxBgpM2PeerRemoteAddr',
'vendor_PeerLocalAddr' => 'jnxBgpM2PeerLocalAddr',
'vendor_PeerLocalAs' => 'jnxBgpM2PeerLocalAs',
'vendor_PeerIdentifier' => 'jnxBgpM2PeerIdentifier',
'vendor_PeerIndex' => 'jnxBgpM2PeerIndex',
'vendor_PeerRemoteAddrType' => 'jnxBgpM2PeerRemoteAddrType',
'vendor_PrefixCountersSafi' => 'jnxBgpM2PrefixCountersSafi'),
// Force10 BGP4-V2 MIB
'FORCE10-BGP4-V2-MIB' => array('vendor_PeerTable' => 'f10BgpM2PeerTable',
'vendor_PeerAdminStatus' => 'f10BgpM2PeerStatus',
'vendor_PeerRemoteAs' => 'f10BgpM2PeerRemoteAs',
'vendor_PeerRemoteAddr' => 'f10BgpM2PeerRemoteAddr',
'vendor_PeerLocalAddr' => 'f10BgpM2PeerLocalAddr',
'vendor_PeerLocalAs' => 'f10BgpM2PeerLocalAs',
'vendor_PeerIdentifier' => 'f10BgpM2PeerIdentifier',
'vendor_PeerIndex' => 'f10BgpM2PeerIndex',
'vendor_PeerRemoteAddrType' => 'f10BgpM2PeerRemoteAddrType',
'vendor_PrefixCountersSafi' => 'f10BgpM2PrefixCountersSafi'),
// Arista BGP4-V2 MIB
'ARISTA-BGP4V2-MIB' => array('vendor_use_index' => array('aristaBgp4V2PeerRemoteAddr' => 1,
'aristaBgp4V2PeerRemoteAddrType' => 1),
'vendor_PeerTable' => 'aristaBgp4V2PeerTable',
'vendor_PeerAdminStatus' => 'aristaBgp4V2PeerAdminStatus',
'vendor_PeerRemoteAs' => 'aristaBgp4V2PeerRemoteAs',
'vendor_PeerRemoteAddr' => 'aristaBgp4V2PeerRemoteAddr',
'vendor_PeerLocalAddr' => 'aristaBgp4V2PeerLocalAddr',
'vendor_PeerLocalAs' => 'aristaBgp4V2PeerLocalAs',
'vendor_PeerIdentifier' => 'aristaBgp4V2PeerRemoteIdentifier',
'vendor_PeerIndex' => '',
'vendor_PeerRemoteAddrType' => 'aristaBgp4V2PeerRemoteAddrType',
'vendor_PrefixCountersSafi' => 'aristaBgp4V2PrefixInPrefixes'),
# PrefixCountersSafi is not-accessible in draft-13, but we
# only use the INDEX from it, so use aristaBgp4V2PrefixInPrefixes.
// Brocade BGP4-V2 MIB
'FOUNDRY-BGP4V2-MIB' => array('vendor_use_index' => array('bgp4V2PeerRemoteAddr' => 1,
'bgp4V2PeerRemoteAddrType' => 1,
'bgp4V2PeerLocalAddr' => 1),
'vendor_PeerTable' => 'bgp4V2PeerTable',
'vendor_PeerAdminStatus' => 'bgp4V2PeerAdminStatus',
'vendor_PeerRemoteAs' => 'bgp4V2PeerRemoteAs',
'vendor_PeerRemoteAddr' => 'bgp4V2PeerRemoteAddr',
'vendor_PeerLocalAddr' => 'bgp4V2PeerLocalAddr',
'vendor_PeerLocalAs' => 'bgp4V2PeerLocalAs',
'vendor_PeerIdentifier' => 'bgp4V2PeerRemoteIdentifier',
'vendor_PeerIndex' => '',
'vendor_PeerRemoteAddrType' => 'bgp4V2PeerRemoteAddrType',
'vendor_PrefixCountersSafi' => 'bgp4V2PrefixInPrefixes'),
# PrefixCountersSafi is not-accessible in draft-13, but we
# only use the INDEX from it, so use bgp4V2PrefixInPrefixes.
'HUAWEI-BGP-VPN-MIB' => array('vendor_use_index' => array('hwBgpPeerRemoteAddr' => 1,
'hwBgpPeerRemoteAddrType' => 1,
'hwBgpPeerRemoteIdentifier' => 1,
'hwBgpPeerAdminStatus' => 1,
'afi' => 'hwBgpPeerAddrFamilyAfi',
'safi' => 'hwBgpPeerAddrFamilySafi'),
'vendor_PeerTable' => 'hwBgpPeerTable',
'vendor_PeerAdminStatus' => 'hwBgpPeerAdminStatus', // really not exist, always set to start if entry exist
'vendor_PeerRemoteAs' => 'hwBgpPeerRemoteAs',
'vendor_PeerRemoteAddr' => 'hwBgpPeerRemoteAddr',
'vendor_PeerLocalAddr' => '',
'vendor_PeerLocalAs' => '',
'vendor_PeerIdentifier' => 'hwBgpPeerRemoteIdentifier', // really not exist, use hwBgpPeerRemoteAddr
'vendor_PeerIndex' => '',
'vendor_PeerRemoteAddrType' => 'hwBgpPeerRemoteAddrType',
'vendor_PrefixCountersSafi' => 'hwBgpPeerPrefixActiveCounter'), # we only use the INDEX from it
);
*/
// Get Local ASN
// Get array with exist MIBs on device with LocasAs-es
$local_as_array = get_bgp_localas_array($device);
$vendor_mib = FALSE; // CLEANME. Clear after full rewrite to definitions.
$bgpVrfLocalAs = [];
foreach ($local_as_array as $entry) {
// CLEANME. Clear after full rewrite to definitions.
if ($entry['mib'] !== 'BGP4-MIB' && $entry['mib'] !== 'CISCO-BGP4-MIB') {
$vendor_mib = $entry['mib'];
}
// LocalAs by first non-zero
if ($entry['LocalAs'] != 0) {
if (!isset($bgpLocalAs) &&
$entry['oid'] !== 'cbgpPeer2LocalAs') {
// Do not use Cisco Peer LocalAs as device bgp, see https://jira.observium.org/browse/OBS-4116
$bgpLocalAs = $entry['LocalAs'];
}
if (isset($entry['virtual_name']) && !isset($bgpVrfLocalAs[$entry['virtual_name']])) {
// Set per vrf LocalAs
$bgpVrfLocalAs[$entry['virtual_name']] = $entry['LocalAs'];
}
}
}
// Discover BGP peers
/// NOTE. PeerIdentifier != PeerRemoteAddr
if (is_numeric($bgpLocalAs) && $bgpLocalAs != 0) {
print_cli_data("Local AS", "AS$bgpLocalAs ", 2);
// Detect if Local AS changed
if ($bgpLocalAs != $device['bgpLocalAs']) {
if (!$device['bgpLocalAs']) {
log_event('BGP Local ASN added: AS' . $bgpLocalAs, $device, 'device', $device['device_id']);
} elseif (!$bgpLocalAs) {
log_event('BGP Local ASN removed: AS' . $device['bgpLocalAs'], $device, 'device', $device['device_id']);
} else {
log_event('BGP ASN changed: AS' . $device['bgpLocalAs'] . ' -> AS' . $bgpLocalAs, $device, 'device', $device['device_id']);
}
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id = ?', array($device['device_id']));
print_cli_data("Updated ASN", $device['bgpLocalAs'] . " -> $bgpLocalAs", 2);
}
print_cli_data_field("Caching");
// Init
$p_list = []; // valid_peers
$peerlist = [];
$af_list = [];
foreach ($local_as_array as $entry) {
$mib = $entry['mib'];
echo("$mib ");
if ($check_vrfs = isset($entry['virtual_name'])) {
// Keep original
$device_original = $device;
$bgpLocalAs_original = $bgpLocalAs;
if (isset($bgpVrfLocalAs[$entry['virtual_name']])) {
// Need in per VRF discovery
$bgpLocalAs = $bgpVrfLocalAs[$entry['virtual_name']];
}
$vrf_name = $entry['virtual_name'];
$snmp_virtual = $entry['snmp_context'];
// Set device for VRF tables
$device = snmp_virtual_device($device_original, $snmp_virtual);
echo("(Virtual Routing $vrf_name) ");
}
/* Start caching bgp peers */
$include = __DIR__ . '/bgp/' . strtolower($mib) . '.inc.php';
if (!is_file($include)) {
// Common for vendor mibs
$include = __DIR__ . '/bgp/bgp4v2-mib.inc.php';
}
include $include;
/* End caching bgp peers */
if ($check_vrfs) {
// Restore device array
$device = $device_original;
$bgpLocalAs = $bgpLocalAs_original;
}
}
} else {
echo("No BGP on host");
if (is_numeric($device['bgpLocalAs'])) {
log_event('BGP ASN removed: AS' . $device['bgpLocalAs'], $device, 'device', $device['device_id']);
dbUpdate(array('bgpLocalAs' => array('NULL')), 'devices', 'device_id = ?', array($device['device_id']));
print_message('Removed ASN (' . $device['bgpLocalAs'] . ')');
} # End if
} # End if
// Process discovered peers
global $table_rows;
$table_rows = array();
if (safe_count($peerlist)) {
print_debug_vars($peerlist);
echo(PHP_EOL);
// Filter IP search by BGP enabled devices (without self)
$bgp_device_ids = dbFetchColumn('SELECT `device_id` FROM `devices` WHERE `device_id` != ? AND `bgpLocalAs` > 0 AND `disabled` = 0 AND `status` = 1', [ $device['device_id'] ]);
$peer_as_where = generate_query_values($bgp_device_ids, 'device_id');
$peer_devices = [];
$peer_devices_ids = [];
foreach (dbFetchRows('SELECT `device_id`, `bgpPeerLocalAddr`, `bgpPeerRemoteAddr` FROM `bgpPeers` WHERE `bgpPeerRemoteAs` = ?' . $peer_as_where, [ $bgpLocalAs ]) as $entry) {
$peer_devices[$entry['bgpPeerLocalAddr']][$entry['bgpPeerRemoteAddr']] = $entry['device_id'];
$peer_devices_ids[] = $entry['device_id'];
}
print_debug_vars($peer_devices);
$peer_ip_where = generate_query_values($peer_devices_ids, 'device_id') . generate_query_values('up', 'ifOperStatus');
foreach ($peerlist as $peer) {
$astext = get_astext($peer['as']);
$reverse_dns = gethostbyaddr6($peer['ip']);
if ($reverse_dns == $peer['ip']) {
unset($reverse_dns);
}
// Search remote device if possible
$peer_addr_version = get_ip_version($peer['ip']);
$peer_addr_type = get_ip_type($peer['ip']);
$peer_local_type = get_ip_type($peer['local_ip']);
$peer_device_id = [ 'NULL' ];
if (!in_array($peer_addr_type, [ 'unspecified', 'loopback' ]) &&
!in_array($peer_local_type, [ 'unspecified', 'loopback' ])) {
//if ($tmp_id = dbFetchCell('SELECT `device_id` FROM `bgpPeers` WHERE `bgpPeerLocalAddr` = ? AND `bgpPeerRemoteAs` = ? AND `bgpPeerRemoteAddr` = ?' . $peer_as_where, array($peer['ip'], $bgpLocalAs, $peer['local_ip'])))
print_debug("bgpPeerLocalAddr: ".$peer['ip'].", bgpPeerRemoteAddr: ".$peer['local_ip']);
if (isset($peer_devices[$peer['ip']][$peer['local_ip']])) {
// Simple search remote device by Local IP and Local AS and Remote IP
//$peer_device_id = $tmp_id;
$peer_device_id = $peer_devices[$peer['ip']][$peer['local_ip']];
} elseif ($ids = get_entity_ids_ip_by_network('device', $peer['ip'], $peer_ip_where)) {
// Fetch all devices with peer IP
// Peer device will found if device UP and NOT DISABLED, port with IP is UP, bgpLocalAs present on remote device
$peer_device_id = array_shift($ids);
/*
foreach($ids as $tmp_id)
{
//if (dbFetchCell('SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ? AND `bgpPeerRemoteAs` = ?', array($tmp_id, $bgpLocalAs)))
if (dbExist('bgpPeers', '`device_id` = ? AND `bgpPeerRemoteAs` = ?', array($tmp_id, $bgpLocalAs)))
{
// Validate if bgpLocalAs also present on remote device
$peer_device_id = $tmp_id;
break; // Found, stop loop
}
}
*/
}
}
if (is_numeric($peer_device_id)) {
$peer_device = device_by_id_cache($peer_device_id);
} else {
unset($peer_device);
}
//$peer['local_as'] = (isset($peer['local_as']) && $peer['local_as'] != 0 && $peer['local_as'] != '') ? $peer['local_as'] : $bgpLocalAs;
$local_as = $peer['local_as'];
$virtual_name = [ 'NULL' ];
if (isset($peer['virtual_name'])) {
$local_as .= ' ('.$peer['virtual_name'].')';
$virtual_name = $peer['virtual_name'];
}
$table_rows[$peer['ip']] = [ $local_as, $peer['local_ip'], $peer['as'], $peer['ip'], '', $reverse_dns, truncate($peer_device['hostname'], 30) ];
$params = [
'device_id' => $device['device_id'],
'bgpPeerIdentifier' => $peer['identifier'],
'bgpPeerRemoteAddr' => $peer['ip'],
'bgpPeerLocalAddr' => $peer['local_ip'],
'local_as' => $peer['local_as'],
'bgpPeerRemoteAs' => $peer['as'],
'astext' => $astext,
'reverse_dns' => $reverse_dns,
'virtual_name' => $virtual_name,
'peer_device_id' => $peer_device_id
];
$peer_db = dbFetchRow('SELECT * FROM `bgpPeers` WHERE `device_id` = ? AND `bgpPeerRemoteAddr` = ?', [ $device['device_id'], $peer['ip'] ]);
if (safe_count($peer_db)) {
$update_array = [];
foreach ($params as $param => $value) {
if ($value === [ 'NULL' ]) {
if ($peer_db[$param] != '') {
$update_array[$param] = $value;
}
} elseif ($value != $peer_db[$param]) {
$update_array[$param] = $value;
}
}
if (count($update_array)) {
dbUpdate($update_array, 'bgpPeers', '`device_id` = ? AND `bgpPeerRemoteAddr` = ?', [ $device['device_id'], $peer['ip'] ]);
if (isset($update_array['reverse_dns']) && count($update_array) === 1) {
// Do not count updates if changed only reverse DNS
$GLOBALS['module_stats'][$module]['unchanged']++;
} else {
$GLOBALS['module_stats'][$module]['updated']++;
}
} else {
$GLOBALS['module_stats'][$module]['unchanged']++;
}
$peer_id = $peer_db['bgpPeer_id'];
} else {
$peer_id = dbInsert($params, 'bgpPeers');
$GLOBALS['module_stats'][$module]['added']++;
}
$peer['id'] = $peer_id;
$peer_ids[$peer['ip']] = $peer_id;
// AFI/SAFI for specific vendors
if (isset($peer_afis[$peer['ip']])) {
$peer_index = $peer['index']; // keep original
foreach ($peer_afis[$peer['ip']] as $af_entry) {
$peer['index'] = isset($af_entry['index']) ? $af_entry['index'] : $peer_index;
discovery_bgp_afisafi($device, $peer, $af_entry['afi'], $af_entry['safi'], $af_list);
}
$peer['index'] = $peer_index; // restore
}
// Autodiscovery for bgp neighbours
if ($config['autodiscovery']['bgp']) {
if (($peer['as'] == $device['bgpLocalAs']) || // ASN matches local router
($config['autodiscovery']['bgp_as_private'] && is_bgp_as_private($peer['as'])) || // ASN is private
(is_array($config['autodiscovery']['bgp_as_whitelist']) && in_array($peer['as'], $config['autodiscovery']['bgp_as_whitelist']))) { // ASN is in bgp_as_whitelist
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $peer['id']);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($peer['id'])) { // Check all previous autodiscovery rounds
// Neighbour never checked, try autodiscover
$remote_device_id = autodiscovery_device($peer['id'], NULL, 'BGP', NULL, $device);
}
}
}
} # Foreach
// Remove deleted AFI/SAFI
unset($afi, $safi, $peer_ip, $peer_id);
$cbgp_delete = [];
$query = 'SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ?';
foreach (dbFetchRows($query, [ $device['device_id'] ]) as $entry) {
$peer_id = $entry['bgpPeer_id'];
$afi = $entry['afi'];
$safi = $entry['safi'];
$cbgp_id = $entry['cbgp_id'];
if (!isset($af_list[$peer_id][$afi][$safi])) {
$cbgp_delete[] = $cbgp_id;
//dbDelete('bgpPeers_cbgp', '`cbgp_id` = ?', array($cbgp_id));
}
} # AF list
if (safe_count($cbgp_delete)) {
// Multi-delete
dbDelete('bgpPeers_cbgp', generate_query_values($cbgp_delete, 'cbgp_id', NULL, FALSE));
}
unset($af_list, $cbgp_delete);
} # end peerlist
// Delete removed peers
unset($peer_ip, $peer_as);
$peers_delete = [];
$query = 'SELECT * FROM `bgpPeers` WHERE `device_id` = ?';
foreach (dbFetchRows($query, [ $device['device_id'] ]) as $entry) {
$peer_ip = $entry['bgpPeerRemoteAddr'];
$peer_as = $entry['bgpPeerRemoteAs'];
if (!isset($p_list[$peer_ip][$peer_as])) {
// dbDelete('bgpPeers', '`bgpPeer_id` = ?', [ $entry['bgpPeer_id'] ]);
$peers_delete[] = $entry['bgpPeer_id'];
$GLOBALS['module_stats'][$module]['deleted']++;
} else {
// Unset, for exclude duplicate entries in DB
unset($p_list[$peer_ip][$peer_as]);
}
}
if (count($peers_delete)) {
// Multi-delete
dbDelete('bgpPeers', generate_query_values($peers_delete, 'bgpPeer_id', NULL, FALSE));
dbDelete('bgpPeers_cbgp', generate_query_values($peers_delete, 'bgpPeer_id', NULL, FALSE));
}
$table_headers = array('%WLocal: AS (VRF)%n', '%WIP%n', '%WPeer: AS%n', '%WIP%n', '%WFamily%n', '%WrDNS%n', '%WRemote Device%n');
print_cli_table($table_rows, $table_headers);
unset($p_list, $peerlist, $vendor_mib, $cisco_version, $cisco_peers, $table_rows, $table_headers, $peer_devices, $peer_devices_ids);
// EOF

View File

@ -0,0 +1,76 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/**
* @var array $device
* @var string $mib
* @var array $entry
* @var string $bgpLocalAs
* @var integer $cisco_version Come from cisco-bgp4-mib.inc.php
* @var array $p_list
* @var array $peerlist
* @var bool $check_vrfs
* @var string $vrf_name
*/
// All MIBs except CISCO-BGP4-MIB (table version 2)
if (isset($cisco_version) && $cisco_version > 1) {
return;
}
if (is_device_mib($device, 'CUMULUS-BGPUN-MIB')) {
// CUMULUS-BGPUN-MIB is copy-paste of BGP4-MIB
return;
}
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerRemoteAs', [], 'BGP4-MIB');
//$peers_data = snmpwalk_cache_oid($device, 'bgpPeerRemoteAddr', $peers_data, 'BGP4-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerLocalAddr', $peers_data, 'BGP4-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerIdentifier', $peers_data, 'BGP4-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerAdminStatus', $peers_data, 'BGP4-MIB');
foreach ($peers_data as $index => $bgp4_entry) {
$index_parts = explode('.', $index);
if (safe_count($index_parts) > 4) {
// Aruba case:
// BGP4-MIB::bgpPeerRemoteAddr.4.18.1.23.109 = IpAddress: 18.1.23.109
$ip_len = array_shift($index_parts);
$peer_ip = implode('.', $index_parts);
} else {
$peer_ip = $index;
}
$peer_as = snmp_dewrap32bit($bgp4_entry['bgpPeerRemoteAs']); // Dewrap for 32bit ASN
if ($peer_as > $bgp4_entry['bgpPeerRemoteAs']) {
$peers_data[$index]['bgpPeerRemoteAs'] = $peer_as;
}
$local_ip = $bgp4_entry['bgpPeerLocalAddr'];
$peer = [
'mib' => $mib,
'index' => $index,
'identifier' => $bgp4_entry['bgpPeerIdentifier'],
'local_ip' => $local_ip,
'ip' => $peer_ip === '0.0.0.0' ? '' : $peer_ip,
'local_as' => $bgpLocalAs,
'as' => $peer_as,
'admin_status' => $bgp4_entry['bgpPeerAdminStatus']
];
if ($check_vrfs) {
$peer['virtual_name'] = $vrf_name;
}
if (!isset($p_list[$peer_ip][$peer_as]) && is_bgp_peer_valid($peer, $device)) {
print_debug("Found peer IP: $peer_ip (AS$peer_as, LocalIP: $local_ip)");
$peerlist[] = $peer;
$p_list[$peer_ip][$peer_as] = 1;
}
}
// EOF

View File

@ -0,0 +1,224 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/**
* @var array $config
* @var array $device
* @var string $mib
* @var array $entry
* @var string $bgpLocalAs
* @var array $peers_data from BGP4-MIB
* @var array $p_list
* @var array $peerlist
* @var bool $check_vrfs
* @var string $vrf_name
*/
// Common vendor specific
$def = $config['mibs'][$mib]['bgp'];
$vendor_mib = $mib;
$vendor_bgp = snmpwalk_cache_oid($device, $def['oids']['PeerRemoteAs']['oid'], [], $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
if (safe_empty($vendor_bgp)) {
$vendor_mib = FALSE; // Unset vendor_mib since not found on device
return;
}
// PeerRemoteAddr
$vendor_oid = $def['oids']['PeerRemoteAddr']['oid'];
if (!isset($def['index'][$vendor_oid])) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PeerLocalAddr
$local_ips = [];
$vendor_oid = $def['oids']['PeerLocalAddr']['oid'];
if (!isset($def['index'][$vendor_oid]) && strlen($vendor_oid)) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
} else {
// LocalAddr trick, when not available in vendor table, by known device ip/network
foreach (dbFetchRows('SELECT * FROM `ipv4_addresses` LEFT JOIN `ipv4_networks` USING(`ipv4_network_id`) WHERE `device_id` = ?', [ $device['device_id'] ]) as $ipv4) {
$local_ips['ipv4'][$ipv4['ipv4_address']] = $ipv4['ipv4_network'];
}
foreach (dbFetchRows('SELECT * FROM `ipv6_addresses` LEFT JOIN `ipv6_networks` USING(`ipv6_network_id`) WHERE `device_id` = ?', [ $device['device_id'] ]) as $ipv6) {
$local_ips['ipv6'][$ipv6['ipv6_address']] = $ipv6['ipv6_network'];
}
print_debug_vars($local_ips);
}
// PeerIdentifier
$vendor_oid = $def['oids']['PeerIdentifier']['oid'];
if (!isset($def['index'][$vendor_oid]) && !safe_empty($vendor_oid)) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PeerLocalAs
$vendor_oid = $def['oids']['PeerLocalAs']['oid'];
if (!isset($def['index'][$vendor_oid]) && !safe_empty($vendor_oid)) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PeerAdminStatus
$vendor_oid = $def['oids']['PeerAdminStatus']['oid'];
if (!isset($def['index'][$vendor_oid]) && !safe_empty($vendor_oid)) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PeerRemoteAddrType
$vendor_oid = $def['oids']['PeerRemoteAddrType']['oid'];
if (!isset($def['index'][$vendor_oid])) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PeerIndex
$vendor_oid = $def['oids']['PeerIndex']['oid'];
if (!isset($def['index'][$vendor_oid]) && !safe_empty($vendor_oid)) {
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_oid, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
}
// PrefixCountersSafi
$vendor_oid = $def['oids']['PrefixCountersSafi']['oid'];
if (!safe_empty($vendor_oid)) {
$vendor_counters = snmpwalk_cache_oid($device, $vendor_oid, [], $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
} else {
$vendor_counters = NULL;
}
//print_vars($vendor_counters);
// See possible AFI/SAFI here: https://www.juniper.net/techpubs/en_US/junos12.3/topics/topic-map/bgp-multiprotocol.html
$afis['1'] = 'ipv4';
$afis['2'] = 'ipv6';
$afis['ipv4'] = '1';
$afis['ipv6'] = '2';
//print_vars($vendor_bgp);
print_debug("$vendor_mib Peers: ");
foreach ($vendor_bgp as $idx => $vendor_entry) {
if (!safe_empty($def['index'])) {
parse_bgp_peer_index($vendor_entry, $idx, $vendor_mib);
}
$peer_ip = hex2ip($vendor_entry[$def['oids']['PeerRemoteAddr']['oid']]);
$peer_addr_type = 'ipv' . get_ip_version($peer_ip);
$local_ip = '';
if (strlen($def['oids']['PeerLocalAddr']['oid'])) {
$local_ip = hex2ip($vendor_entry[$def['oids']['PeerLocalAddr']['oid']]);
} elseif (isset($local_ips[$peer_addr_type])) {
// Trick for detect local ip by matching between device IPs network and peer ip
// Actually for Huawei BGP peers
foreach ($local_ips[$peer_addr_type] as $ip => $network) {
if (match_network($peer_ip, $network)) {
$local_ip = $ip;
print_debug("Local IP: $ip. Matched Peer IP [$peer_ip] with device network [$network].");
break;
}
}
}
$local_as = isset($vendor_entry[$def['oids']['PeerLocalAs']['oid']]) ? snmp_dewrap32bit($vendor_entry[$def['oids']['PeerLocalAs']['oid']]) : $bgpLocalAs;
$peer_as = $vendor_entry[$def['oids']['PeerRemoteAs']['oid']];
// index
$vendor_oid = $def['oids']['PeerIndex']['oid'];
if (empty($vendor_oid)) {
$index = $idx;
} else {
$index = $vendor_entry[$vendor_oid];
}
$peer = [
'mib' => $mib,
'index' => $index,
'identifier' => $vendor_entry[$def['oids']['PeerIdentifier']['oid']],
'local_ip' => $local_ip,
'local_as' => $local_as,
'ip' => $peer_ip === '0.0.0.0' ? '' : $peer_ip,
'as' => $peer_as,
'admin_status' => $vendor_entry[$def['oids']['PeerAdminStatus']['oid']]
];
if ($check_vrfs) {
$peer['virtual_name'] = $vrf_name;
}
if (!isset($p_list[$peer_ip][$peer_as]) && is_bgp_peer_valid($peer, $device)) {
// Fix possible 32bit ASN for peers from BGP4-MIB
// Brocade example:
// BGP4-MIB::bgpPeerRemoteAs.27.122.122.4 = 23456
// FOUNDRY-BGPV2-MIB::bgp4V2PeerRemoteAs.1.1.4.27.122.122.5.1.4.27.122.122.4 = 133189
if (isset($p_list[$peer_ip])) {
unset($p_list[$peer_ip]); // Clean old peer list
$bgp4_peer_as = $peers_data[$peer_ip]['bgpPeerRemoteAs']; // BGP4-MIB
if ($peer_as > $bgp4_peer_as) {
//$peers_data[$peer_ip]['bgpPeerRemoteAs'] = $peer_as;
// Yah, need to found and remove duplicate peer from $peerlist
foreach ($peerlist as $key => $tmp) {
if ($tmp['ip'] == $peer_ip && $tmp['as'] == $bgp4_peer_as) {
unset($peerlist[$key]);
break;
}
}
}
}
$p_list[$peer_ip][$peer_as] = 1;
$peerlist[] = $peer;
print_debug("Found peer IP: $peer_ip (AS$peer_as, LocalIP: $local_ip)");
} elseif (isset($p_list[$peer_ip][$peer_as]) && $local_as != $bgpLocalAs) {
// Find and replace local_as key in peer list if different local as
// FIXME, Yah, $peerlist stored as simple array without indexed key, that why used derp per-peer loop
foreach ($peerlist as $key => $tmp) {
if ($tmp['ip'] == $peer_ip && $tmp['as'] == $peer_as) {
$peerlist[$key]['local_as'] = $local_as;
print_debug("Replaced Local AS for peer: $peer_ip (AS$peer_as, LocalIP: $local_ip) - AS$bgpLocalAs -> AS$local_as");
break;
}
}
} else {
print_debug("Vendor peer already found: $peer_ip");
print_debug_vars($peer);
}
// AFI/SAFI
$vendor_oid = isset($def['index']['afi']) ? $def['index']['afi'] : $def['oids']['PeerRemoteAddrType']['oid'];
$afi = $vendor_entry[$vendor_oid];
if (isset($def['index']['safi'])) {
$safi = $vendor_entry[$def['index']['safi']];
// Here each table entry is uniq afi/safi, see HUAWEI-BGP-VPN-MIB
if (isset($vendor_counters[$index])) {
//$peer_afis[$peer_ip][$afi][$safi] = 1;
$peer_afis[$peer_ip][] = [ 'afi' => $afi, 'safi' => $safi, 'index' => $index ];
//discovery_bgp_afisafi($device, $entry, $afi, $safi, $af_list);
}
continue;
}
if ($vendor_mib === 'VIPTELA-OPER-BGP') {
// This mib has only one possible AFI/SAFI
if (isset($vendor_counters[$index.'.0'])) {
//$peer_afis[$peer_ip][$afi][$safi] = 1;
$peer_afis[$peer_ip][] = [ 'afi' => 'ipv4', 'safi' => 'unicast' ];
}
continue;
}
// Here can be multiple table entries for different afi/safi
foreach ($config['routing_safis'] as $i => $safi_def) {
$safi = $safi_def['name'];
if (is_numeric($afi)) {
$afi_num = $afi;
$afi = $config['routing_afis'][$afi]['name'];
} else {
$afi_num = $config['routing_afis_name'][$afi];
}
if (isset($vendor_counters["$index.$afi_num.$i"])) {
//$peer_afis[$peer_ip][$afi][$safi] = 1;
$peer_afis[$peer_ip][] = [ 'afi' => $afi, 'safi' => $safi, 'index' => $index ];
//discovery_bgp_afisafi($device, $entry, $afi, $safi, $af_list);
} else {
print_debug("Did not find AFI/SAFI with index $index.$afi_num.$i");
}
}
}
// EOF

View File

@ -0,0 +1,136 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/**
* @var array $device
* @var string $mib
* @var array $entry
* @var string $bgpLocalAs
* @var array $p_list
* @var array $peerlist
* @var bool $check_vrfs
* @var string $vrf_name
*/
$cisco_version = $entry['cisco_version'];
if ($cisco_version < 2) {
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
$af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyName', [], 'CISCO-BGP4-MIB');
} else {
// Check Cisco cbgpPeer2Table
$cisco_peers = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', [], 'CISCO-BGP4-MIB');
$cisco_peers = snmpwalk_cache_oid($device, 'cbgpPeer2LocalAddr', $cisco_peers, 'CISCO-BGP4-MIB');
// Cisco vendor mib LocalAddr issue:
// cbgpPeer2LocalAddr.ipv4."10.0.1.1" = "0B 8E 95 38 " --> 11.142.149.56
// but should:
// bgpPeerLocalAddr.10.0.1.1 = 10.0.1.3
// Yah, Cisco you again added extra work for me? What mean this random numbers?
$cisco_fix = snmpwalk_cache_oid($device, 'bgpPeerLocalAddr', [], 'BGP4-MIB');
$cisco_peers = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteIdentifier', $cisco_peers, 'CISCO-BGP4-MIB');
$cisco_peers = snmpwalk_cache_oid($device, 'cbgpPeer2AdminStatus', $cisco_peers, 'CISCO-BGP4-MIB');
$cisco_peers = snmpwalk_cache_oid($device, 'cbgpPeer2LocalAs', $cisco_peers, 'CISCO-BGP4-MIB');
print_debug("CISCO-BGP4-MIB Peers: ");
foreach ($cisco_peers as $index => $cisco_entry) {
list(, $peer_ip) = explode('.', $index, 2);
$peer_ip = hex2ip($peer_ip);
if (isset($cisco_fix[$peer_ip]) && strlen($cisco_fix[$peer_ip]['bgpPeerLocalAddr'])) {
// Fix incorrect IPv4 local IPs
$local_ip = $cisco_fix[$peer_ip]['bgpPeerLocalAddr'];
} else {
$local_ip = hex2ip($cisco_entry['cbgpPeer2LocalAddr']);
}
$peer_as = $cisco_entry['cbgpPeer2RemoteAs'];
$local_as = snmp_dewrap32bit($cisco_entry['cbgpPeer2LocalAs']);
if ($local_as == 0) {
// Per session local ASN can be zero if session down
$local_as = $bgpLocalAs;
}
$peer = [
'mib' => $mib,
'index' => $index,
'identifier' => $cisco_entry['cbgpPeer2RemoteIdentifier'],
'local_ip' => $local_ip,
'local_as' => $local_as,
'ip' => $peer_ip === '0.0.0.0' ? '' : $peer_ip,
'as' => $peer_as,
'admin_status' => $cisco_entry['cbgpPeer2AdminStatus']
];
if ($check_vrfs) {
$peer['virtual_name'] = $vrf_name;
}
if (!isset($p_list[$peer_ip][$peer_as]) && is_bgp_peer_valid($peer, $device)) {
$p_list[$peer_ip][$peer_as] = 1;
$peerlist[] = $peer;
print_debug("Found peer IP: $peer_ip (AS$peer_as, LocalIP: $local_ip)");
} elseif (isset($p_list[$peer_ip][$peer_as]) && $local_as != $bgpLocalAs) {
// Find and replace local_as key in peer list if different local as
// FIXME, Yah, $peerlist stored as simple array without indexed key, that why used derp per-peer loop
foreach ($peerlist as $key => $tmp) {
if ($tmp['ip'] == $peer_ip && $tmp['as'] == $peer_as) {
$peerlist[$key]['local_as'] = $local_as;
print_debug("Replaced Local AS for peer: $peer_ip (AS$peer_as, LocalIP: $local_ip) - AS$bgpLocalAs -> AS$local_as");
break;
}
}
}
}
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
$af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyName', [], 'CISCO-BGP4-MIB');
}
// Process AFI/SAFI
foreach ($af_data as $af => $af_entry) {
if ($cisco_version === 2) {
list(, $af) = explode('.', $af, 2);
$text = $af_entry['cbgpPeer2AddrFamilyName'];
} else {
$text = $af_entry['cbgpPeerAddrFamilyName'];
}
$afisafi = explode('.', $af);
$c = count($afisafi);
$afi = $afisafi[$c - 2];
$safi = $afisafi[$c - 1];
$peer_ip = hex2ip(str_replace(".$afi.$safi", '', $af));
print_debug("Peer IP: $peer_ip, AFI: $afi, SAFI: $safi");
if ($afi && $safi) {
//$peer_afis[$peer_ip][$afi][$safi] = $text;
$peer_afis[$peer_ip][] = [ 'afi' => $afi, 'safi' => $safi ];
/*
if (strlen($table_rows[$peer_ip][4]))
{
$table_rows[$peer_ip][4] .= ', ';
}
$table_rows[$peer_ip][4] .= $afi . '.' . $safi;
$peer_id = $peer_ids[$peer_ip];
$af_list[$peer_id][$afi][$safi] = 1;
//if (dbFetchCell('SELECT COUNT(*) FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND `bgpPeer_id` = ? AND `afi` = ? AND `safi` = ?', array($device['device_id'], $peer_id, $afi, $safi)) == 0)
if (!dbExist('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeer_id` = ? AND `afi` = ? AND `safi` = ?', array($device['device_id'], $peer_id, $afi, $safi)))
{
$params = [ 'device_id' => $device['device_id'], 'bgpPeer_id' => $peer_id, 'afi' => $afi, 'safi' => $safi ];
dbInsert($params, 'bgpPeers_cbgp');
}
*/
}
}
// EOF

View File

@ -0,0 +1,88 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
/**
* @var array $device
* @var string $mib
* @var array $entry
* @var string $bgpLocalAs
* @var array $p_list
* @var array $peerlist
* @var bool $check_vrfs
* @var string $vrf_name
*/
// CUMULUS-BGPUN-MIB::bgpPeerState.192.168.0.1 = INTEGER: established(6)
// CUMULUS-BGPUN-MIB::bgpPeerState.192.168.0.5 = INTEGER: established(6)
// CUMULUS-BGPUN-MIB::bgpPeerAdminStatus.192.168.0.1 = INTEGER: start(2)
// CUMULUS-BGPUN-MIB::bgpPeerAdminStatus.192.168.0.5 = INTEGER: start(2)
// CUMULUS-BGPUN-MIB::bgpPeerLocalAddr.192.168.0.1 = STRING: "fe80::e04:1fff:fe86:1"
// CUMULUS-BGPUN-MIB::bgpPeerLocalAddr.192.168.0.5 = STRING: "192.168.125.2"
// CUMULUS-BGPUN-MIB::bgpPeerRemoteAs.192.168.0.1 = INTEGER: 65000
// CUMULUS-BGPUN-MIB::bgpPeerRemoteAs.192.168.0.5 = INTEGER: 65005
// CUMULUS-BGPUN-MIB::bgpPeerInUpdates.192.168.0.1 = Counter32: 6
// CUMULUS-BGPUN-MIB::bgpPeerInUpdates.192.168.0.5 = Counter32: 6
// CUMULUS-BGPUN-MIB::bgpPeerOutUpdates.192.168.0.1 = Counter32: 6
// CUMULUS-BGPUN-MIB::bgpPeerOutUpdates.192.168.0.5 = Counter32: 6
// CUMULUS-BGPUN-MIB::bgpPeerInTotalMessages.192.168.0.1 = Counter32: 32629
// CUMULUS-BGPUN-MIB::bgpPeerInTotalMessages.192.168.0.5 = Counter32: 32629
// CUMULUS-BGPUN-MIB::bgpPeerOutTotalMessages.192.168.0.1 = Counter32: 32629
// CUMULUS-BGPUN-MIB::bgpPeerOutTotalMessages.192.168.0.5 = Counter32: 32629
// CUMULUS-BGPUN-MIB::bgpPeerLastError.192.168.0.1 = Hex-STRING: 00 00
// CUMULUS-BGPUN-MIB::bgpPeerLastError.192.168.0.5 = Hex-STRING: 00 00
// CUMULUS-BGPUN-MIB::bgpPeerFsmEstablishedTime.192.168.0.1 = Gauge32: 97875
// CUMULUS-BGPUN-MIB::bgpPeerFsmEstablishedTime.192.168.0.5 = Gauge32: 97875
// CUMULUS-BGPUN-MIB::bgpPeerInUpdateElapsedTime.192.168.0.1 = Gauge32: 11473
// CUMULUS-BGPUN-MIB::bgpPeerInUpdateElapsedTime.192.168.0.5 = Gauge32: 11473
// CUMULUS-BGPUN-MIB::bgpPeerIface.192.168.0.1 = STRING: "swp1"
// CUMULUS-BGPUN-MIB::bgpPeerIface.192.168.0.5 = STRING: "192.168.125.254"
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerRemoteAs', [], 'CUMULUS-BGPUN-MIB');
//$peers_data = snmpwalk_cache_oid($device, 'bgpPeerRemoteAddr', $peers_data, 'CUMULUS-BGPUN-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerLocalAddr', $peers_data, 'CUMULUS-BGPUN-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerIface', $peers_data, 'CUMULUS-BGPUN-MIB');
$peers_data = snmpwalk_cache_oid($device, 'bgpPeerAdminStatus', $peers_data, 'CUMULUS-BGPUN-MIB');
foreach ($peers_data as $index => $bgp4_entry) {
$peer_ip = $index;
$peer_as = snmp_dewrap32bit($bgp4_entry['bgpPeerRemoteAs']); // Dewrap for 32bit ASN
if ($peer_as > $bgp4_entry['bgpPeerRemoteAs']) {
$peers_data[$index]['bgpPeerRemoteAs'] = $peer_as;
}
$local_ip = $bgp4_entry['bgpPeerLocalAddr'];
// Add bgpPeerIdentifier
//$bgp4_entry['bgpPeerIdentifier'] = get_ip_version($bgp4_entry['bgpPeerIface']) ? $bgp4_entry['bgpPeerIface'] : $index;
$bgp4_entry['bgpPeerIdentifier'] = $index;
$peers_data[$index]['bgpPeerIdentifier'] = $bgp4_entry['bgpPeerIdentifier'];
$peer = [
'mib' => $mib,
'index' => $index,
'identifier' => $bgp4_entry['bgpPeerIdentifier'],
'local_ip' => $local_ip,
'ip' => $peer_ip === '0.0.0.0' ? '' : $peer_ip,
'local_as' => $bgpLocalAs,
'as' => $peer_as,
'admin_status' => $bgp4_entry['bgpPeerAdminStatus']
];
if ($check_vrfs) {
$peer['virtual_name'] = $vrf_name;
}
if (!isset($p_list[$peer_ip][$peer_as]) && is_bgp_peer_valid($peer, $device)) {
print_debug("Found peer IP: $peer_ip (AS$peer_as, LocalIP: $local_ip)");
$peerlist[] = $peer;
$p_list[$peer_ip][$peer_as] = 1;
}
}
// EOF

View File

@ -0,0 +1,126 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Check if QoS exists on the host
$query = 'SELECT * FROM `ports_cbqos`';
$query .= ' WHERE `device_id` = ?';
$cbq_db = dbFetchRows($query, array($device['device_id']));
foreach ($cbq_db as $cbq) { $cbq_table[$cbq['policy_index']][$cbq['object_index']] = $cbq; }
// Walk the first service policies OID and then see if it was populated before we continue
$service_policies = array(); // This ends up being indexed by cbQosPolicyIndex
$service_policies = snmpwalk_cache_oid($device, "cbQosIfType", $service_policies, 'CISCO-CLASS-BASED-QOS-MIB');
if (count($service_policies))
{
$table_rows = array();
// Continue populating service policies
$service_policies = snmpwalk_cache_oid($device, "cbQosPolicyDirection", $service_policies, 'CISCO-CLASS-BASED-QOS-MIB');
$service_policies = snmpwalk_cache_oid($device, "cbQosIfIndex", $service_policies, 'CISCO-CLASS-BASED-QOS-MIB');
$policy_maps = snmpwalk_cache_oid($device, "cbQosPolicyMapCfgEntry", array(), 'CISCO-CLASS-BASED-QOS-MIB');
$class_maps = snmpwalk_cache_oid($device, "cbQosCMCfgEntry", array(), 'CISCO-CLASS-BASED-QOS-MIB');
$object_indexes = snmpwalk_cache_twopart_oid($device, "cbQosObjectsEntry", array(), 'CISCO-CLASS-BASED-QOS-MIB');
# print_r($policy_maps);
# print_r($class_maps);
# print_r($object_indexes);
$cm_stats = array();
// $oids = array('cbQosCMPrePolicyPkt64','cbQosCMPrePolicyByte64', 'cbQosCMPostPolicyByte64', 'cbQosCMDropPkt64', 'cbQosCMDropByte64', 'cbQosCMNoBufDropPkt64');
$oids = array('cbQosCMPrePolicyPkt64');
foreach ($oids as $oid)
{
$cm_stats = snmpwalk_cache_twopart_oid($device, $oid, $cm_stats, 'CISCO-CLASS-BASED-QOS-MIB');
}
foreach ($cm_stats as $policy_index => $policy_entry)
{
foreach ($policy_entry as $object_index => $object_entry)
{
$port = get_port_by_ifIndex($device['device_id'], $service_policies[$policy_index]['cbQosIfIndex']);
$object_entry['port_id'] = $port['port_id'];
$object_entry['direction'] = $service_policies[$policy_index]['cbQosPolicyDirection'];
$object_entry['policy_index'] = $policy_index;
$object_entry['object_index'] = $object_index;
$object_entry['cm_cfg_index'] = $object_indexes[$policy_index][$object_index]['cbQosConfigIndex'];
$object_entry['pm_cfg_index'] = $object_indexes[$policy_index][$policy_index]['cbQosConfigIndex'];
// Loop the entries for this policy and get the policy configuration id. This is messy. This MIB sucks. Also sometimes the indexing format changes (!)
foreach ($object_indexes[$policy_index] AS $object_data)
{
# print_vars($object_data);
if ($object_data['cbQosObjectsType'] == 'policymap') { $object_entry['pm_cfg_index'] = $object_data['cbQosConfigIndex']; }
}
$object_entry['policy_name'] = $policy_maps[$object_entry['pm_cfg_index']]['cbQosPolicyMapName'];
$object_entry['policy_desc'] = $policy_maps[$object_entry['pm_cfg_index']]['cbQosPolicyMapDesc'];
$object_entry['cm_name'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMName'];
$object_entry['cm_desc'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMDesc'];
$object_entry['cm_info'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMInfo'];
if ($object_entry['policy_index'] == '1995099406' ) { print_vars($object_entry); }
if (!isset($cbq_table[$policy_index][$object_index]))
{
dbInsert(array('device_id' => $device['device_id'], 'port_id' => $port['port_id'], 'policy_index' => $policy_index, 'object_index' => $object_index, 'direction' => $object_entry['direction'], 'object_name' => $object_entry['cm_name'], 'policy_name' => $object_entry['policy_name']), 'ports_cbqos');
//echo("+");
$cbq_table[$policy_index][$object_index] = dbFetchRow("SELECT * FROM `ports_cbqos` WHERE `device_id` = ? AND `port_id` = ? AND `policy_index` = ? AND `object_index` = ?",
array($device['device_id'], $port['port_id'], $policy_index, $object_index));
} else {
if ($cbq_table[$policy_index][$object_index]['policy_name'] != $object_entry['policy_name'] || $cbq_table[$policy_index][$object_index]['object_name'] != $object_entry['cm_name']) {
dbUpdate(array('object_name' => $object_entry['cm_name'], 'policy_name' => $object_entry['policy_name']), 'ports_cbqos', '`device_id` = ? AND `port_id` = ? AND `policy_index` = ? AND `object_index` = ?', array($device['device_id'], $port['port_id'], $policy_index, $object_index));
//echo("U");
}
unset($cbq_table[$policy_index][$object_index]);
}
$table_row = array();
$table_row[] = $port['port_label_short'];
$table_row[] = $object_entry['policy_name'];
$table_row[] = $object_entry['cm_name'];
$table_row[] = $object_entry['direction'];
$table_rows[] = $table_row;
unset($table_row);
}
}
$headers = array('%WPort%n', '%WPolicy%n', '%WObject%n', '%WDir%n');
print_cli_table($table_rows, $headers);
} // End check if QoS is enabled before we walk everything
else
{
echo 'QoS not configured.', PHP_EOL;
}
foreach($cbq_table AS $policy => $objects)
{
foreach($objects AS $object_name => $object)
{
dbDelete('ports_cbqos', '`cbqos_id` = ?', array($object['cbqos_id'])); echo '-';
}
}
// EOF

View File

@ -0,0 +1,61 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
echo("Cisco CEF Switching Path: ");
$cefs = snmpwalk_cache_threepart_oid($device, "cefSwitchingPath", array(), 'CISCO-CEF-MIB');
if (OBS_DEBUG > 1) { print_vars($cefs); }
if (is_array($cefs))
{
if (!is_array($entity_array))
{
echo("Caching OIDs: ");
$entity_array = array();
echo(" entPhysicalDescr");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalDescr", $entity_array, "ENTITY-MIB");
echo(" entPhysicalName");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalName", $entity_array, "ENTITY-MIB");
echo(" entPhysicalModelName");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalModelName", $entity_array, "ENTITY-MIB");
}
foreach ($cefs as $entity => $afis)
{
$entity_name = $entity_array[$entity]['entPhysicalName'] ." - ".$entity_array[$entity]['entPhysicalModelName'];
echo("\n$entity $entity_name\n");
foreach ($afis as $afi => $paths)
{
echo(" |- $afi\n");
foreach ($paths as $path => $path_name)
{
echo(" | |-".$path.": ".$path_name['cefSwitchingPath']."\n");
$cef_exists[$device['device_id']][$entity][$afi][$path] = 1;
// FIXME, old code was incorrect, but not sure that still fixed..
//if (dbFetchCell("SELECT COUNT(*) from `cef` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1") // Why != 1 ???
if (!dbExist('cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_path` = ?', array($device['device_id'], $entity, $afi, $path)))
{
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_path' => $path), 'cef_switching');
echo("+");
}
}
}
}
}
// FIXME - need to delete old ones. FIXME REALLY.
echo(PHP_EOL);
// EOF

View File

@ -0,0 +1,74 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mib = 'Printer-MIB';
//Printer-MIB::prtMarkerMarkTech.1.1 = INTEGER: electrophotographicLaser(4)
//Printer-MIB::prtMarkerCounterUnit.1.1 = INTEGER: impressions(7)
//Printer-MIB::prtMarkerLifeCount.1.1 = Counter32: 19116
//Printer-MIB::prtMarkerPowerOnCount.1.1 = Counter32: 43
//Printer-MIB::prtMarkerProcessColorants.1.1 = INTEGER: 1
//Printer-MIB::prtMarkerSpotColorants.1.1 = INTEGER: 0
//Printer-MIB::prtMarkerAddressabilityUnit.1.1 = INTEGER: tenThousandthsOfInches(3)
//Printer-MIB::prtMarkerAddressabilityFeedDir.1.1 = INTEGER: 600
//Printer-MIB::prtMarkerAddressabilityXFeedDir.1.1 = INTEGER: 600
//Printer-MIB::prtMarkerNorthMargin.1.1 = INTEGER: 1968
//Printer-MIB::prtMarkerSouthMargin.1.1 = INTEGER: 1968
//Printer-MIB::prtMarkerWestMargin.1.1 = INTEGER: 1968
//Printer-MIB::prtMarkerEastMargin.1.1 = INTEGER: 1968
//Printer-MIB::prtMarkerStatus.1.1 = INTEGER: 2
$oids = snmpwalk_cache_oid($device, "prtMarkerEntry", array(), $mib);
$prt_supplies = snmpwalk_cache_oid($device, 'prtMarkerSuppliesDescription', array(), $mib, NULL, OBS_SNMP_ALL_ASCII);
//print_vars($oids);
$count = count($oids);
$total_printed_allow = TRUE;
foreach ($oids as $index => $entry)
{
$printer_supply = dbFetchRow("SELECT * FROM `printersupplies` WHERE `device_id` = ? AND `supply_mib` = ? AND `supply_index` = ?", array($device['device_id'], 'jetdirect', $index));
$marker_descr = "Printed ".nicecase($entry['prtMarkerCounterUnit']);
list($hrDeviceIndex, $prtMarkerIndex) = explode('.', $index);
$options = array('measured_class' => 'printersupply',
'measured_entity' => $printer_supply['supply_id'],
'counter_unit' => $entry['prtMarkerCounterUnit']);
// Lifetime counter (should be always single)
$descr = "Total $marker_descr";
$oid_name = 'prtMarkerLifeCount';
$oid = '.1.3.6.1.2.1.43.10.2.1.4.' . $index;
$value = $entry[$oid_name];
if (isset($entry[$oid_name]) && $total_printed_allow)
{
discover_counter($device, 'printersupply', $mib, $oid_name, $oid, $index, $descr, 1, $value, $options);
$total_printed_allow = FALSE; // Discover only first "Total Printed", all other always same
}
// PowerOn counter
$descr = "PowerOn $marker_descr";
if ($prt_supplies[$index]['prtMarkerSuppliesDescription'])
{
$descr .= ' - ' . rewrite_entity_name(snmp_hexstring($prt_supplies[$index]['prtMarkerSuppliesDescription']));
}
$oid_name = 'prtMarkerPowerOnCount';
$oid = '.1.3.6.1.2.1.43.10.2.1.5.' . $index;
$value = $entry[$oid_name];
discover_counter($device, 'printersupply', $mib, $oid_name, $oid, $index, rewrite_entity_name($descr), 1, $value, $options);
// prtMarkerStatus
// FIXME, binary statuses currently unsupported
}
// EOF

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Discover arbitrary graphs by MIB
$include_dir = "includes/discovery/graphs/";
include("includes/include-dir-mib.inc.php");
// EOF

View File

@ -0,0 +1,57 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
echo("Juniper Firewall Counters");
$fws = array();
$fws = snmpwalk_cache_threepart_oid($device, "jnxFWCounterDisplayType", $fws, "JUNIPER-FIREWALL-MIB");
if (count($fws))
{
$oid = 'jnxFWCounterDisplayType';
}
/*
else
{
$fws = snmpwalk_cache_twopart_oid($device, "jnxFWType", $fws, "JUNIPER-FIREWALL-MIB");
if (count($fws))
{
$oid = 'jnxFWType';
}
}
*/
$array = array();
foreach ($fws as $filter => $counters)
{
foreach ($counters AS $counter => $types)
{
foreach($types as $type => $data)
{
$array[$filter][$counter][$type] = 1;
}
}
}
echo("\n");
if (count($array))
{
set_entity_attrib('device', $device['device_id'], 'juniper-firewall-mib', json_encode($array));
}
unset($fws, $filter, $counters, $counter, $data);
// EOF

View File

@ -0,0 +1,23 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$valid['inventory'] = array();
$include_dir = "includes/discovery/inventory";
include($config['install_dir']."/includes/include-dir-mib.inc.php");
check_valid_inventory($device);
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid[$module]);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) { print_vars($valid[$module]); }
// EOF

View File

@ -0,0 +1,164 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$oids = snmp_cache_table($device, 'cpqRackServerBladeTable', NULL, 'CPQRACK-MIB'); // This table also used in statuses
// Chassis
$index = 1;
$inventory[$index] = array(
'entPhysicalName' => $device['hardware'].' Chassis',
'entPhysicalDescr' => $device['hostname'],
'entPhysicalClass' => 'chassis',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $device['hardware'],
'entPhysicalSerialNum' => $device['serial'],
'entPhysicalFirmwareRev' => $device['version'],
'entPhysicalAssetID' => $device['asset_tag'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'HP'
);
discover_inventory($device, $index, $inventory[$index], $mib);
// Blades
foreach ($oids as $tmp => $entry)
{
if ($entry['cpqRackServerBladeEntry'] == "0") { continue; }
if ($entry['cpqRackServerBladeSlotsUsed'] == "0") { continue; }
$index += 2;
$inventory[$index] = array(
'entPhysicalName' => 'Slot '.$entry['cpqRackServerBladePosition'],
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $entry['cpqRackServerBladePosition'],
'entPhysicalMfgName' => 'HP'
);
$model = $entry['cpqRackServerBladeProductId'];
if ($entry['cpqRackServerBladePowered'] === "off")
{
$model .= ' (OFF)';
}
$inventory[$index+1] = array(
'entPhysicalName' => $entry['cpqRackServerBladeName'],
'entPhysicalDescr' => $entry['cpqRackServerBladeName'],
'entPhysicalClass' => 'module',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $model,
'entPhysicalSerialNum' => $entry['cpqRackServerBladeSerialNum'],
'entPhysicalContainedIn' => $index,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HP'
);
discover_inventory($device, $index, $inventory[$index], $mib);
discover_inventory($device, $index+1, $inventory[$index+1], $mib);
unset($model);
}
$oids = snmp_cache_table($device, 'cpqRackPowerSupplyTable', NULL, 'CPQRACK-MIB'); // This table also used in sensors
foreach ($oids as $pwr => $entry)
{
$index += 2;
$inventory[$index] = array(
'entPhysicalName' => 'Power Supply Module ' . $pwr,
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $pwr,
'entPhysicalMfgName' => 'HP'
);
$inventory[$index+1] = array(
'entPhysicalName' => 'Power Supply ' . $pwr,
'entPhysicalDescr' => 'Power Supply ' . $pwr,
'entPhysicalClass' => 'power',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $entry['cpqRackPowerSupplyPartNumber'],
'entPhysicalSerialNum' => $entry['cpqRackPowerSupplySerialNum'],
'entPhysicalContainedIn' => $index,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HP'
);
discover_inventory($device, $index, $inventory[$index], $mib);
discover_inventory($device, $index+1, $inventory[$index+1], $mib);
}
$nets = snmpwalk_cache_oid($device, 'cpqRackNetConnectorTable', array(), 'CPQRACK-MIB');
foreach ($nets as $net => $entry)
{
if ($entry['cpqRackNetConnectorPresent'] == "absent") { continue; }
$index += 2;
$inventory[$index] = array(
'entPhysicalName' => 'Network Connector Module ' . $net,
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $net,
'entPhysicalMfgName' => 'HP'
);
$inventory[$index+1] = array(
'entPhysicalName' => 'Network Connector ' . $net,
'entPhysicalDescr' => 'Network Connector ' . $net,
'entPhysicalClass' => 'port',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $entry['cpqRackNetConnectorModel'],
'entPhysicalSerialNum' => $entry['cpqRackNetConnectorSerialNum'],
'entPhysicalContainedIn' => $index,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HP'
);
discover_inventory($device, $index, $inventory[$index], $mib);
discover_inventory($device, $index+1, $inventory[$index+1], $mib);
}
$oas = snmpwalk_cache_oid($device, 'cpqRackCommonEnclosureManagerTable', array(), 'CPQRACK-MIB');
foreach ($oas as $oa => $entry)
{
if ($entry['cpqRackCommonEnclosureManagerPresent'] == "absent") { continue; }
$index += 2;
$inventory[$index] = array(
'entPhysicalName' => 'Onboard Administrator Module ' . $oa,
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $oa,
'entPhysicalMfgName' => 'HP'
);
$oa_state = $entry['cpqRackCommonEnclosureManagerRole'];
$inventory[$index+1] = array(
'entPhysicalName' => 'Onboard Administrator ' . $oa . ' [' . $oa_state . ']',
'entPhysicalDescr' => 'Onboard Administrator ' . $oa,
'entPhysicalClass' => 'module',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $entry['cpqRackCommonEnclosureManagerEnclosureName'],
'entPhysicalSerialNum' => $entry['cpqRackCommonEnclosureManagerSerialNum'],
'entPhysicalFirmwareRev' => $entry['cpqRackCommonEnclosureManagerFWRev'],
'entPhysicalContainedIn' => $index,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HP'
);
discover_inventory($device, $index, $inventory[$index], $mib);
discover_inventory($device, $index+1, $inventory[$index+1], $mib);
}
unset($power, $net, $oa, $oa_state);
// EOF

View File

@ -0,0 +1,81 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2015 Observium Limited
*
*/
// Only run this mib for chassis systems
// DELL-RAC-MIB::drsProductType.0 = INTEGER: cmc(8)
$type = snmp_get_oid($device, "drsProductType.0", "DELL-RAC-MIB");
if ( strstr($type, "cmc") || strstr($type, "CMC") )
{
$oids = snmp_cache_table($device, 'drsChassisServerGroup', NULL, 'DELL-RAC-MIB'); // This table also used in statuses
$index = 1;
$inventory[$index] = array(
'entPhysicalName' => $device['hardware'].' Chassis',
'entPhysicalDescr' => $device['hostname'],
'entPhysicalClass' => 'chassis',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $device['hardware'],
'entPhysicalSerialNum' => $device['serial'],
'entPhysicalHardwareRev' => snmp_get($device, "drsProductVersion.0", "-Oqv", "DELL-RAC-MIB"),
'entPhysicalFirmwareRev' => $device['version'],
'entPhysicalAssetID' => $device['asset_tag'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Dell'
);
discover_inventory($device, $index, $inventory[$index], $mib);
foreach ($oids as $tmp => $entry)
{
if ($entry['drsServerSlotNumber'] === "N/A") { continue; }
$index += 2;
// Full height blades take up two slots and are marked as Extension
if (!strstr($entry[drsServerSlotName],"Extension")) {
$serial = $entry['drsServerServiceTag'];
$inventory[$index] = array(
'entPhysicalName' => 'Slot '.$entry['drsServerSlotNumber'],
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $entry['drsServerSlotNumber'],
'entPhysicalMfgName' => 'Dell'
);
$model = $entry['drsServerModel'];
if ( $entry['drsServerMonitoringCapable'] === "off") {
$model .= ' (OFF)';
}
$inventory[$index+1] = array(
'entPhysicalName' => $entry['drsServerSlotName'],
'entPhysicalDescr' => $entry['drsServerSlotName'],
'entPhysicalClass' => 'module',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $model,
'entPhysicalSerialNum' => $serial,
'entPhysicalContainedIn' => $index,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'Dell'
);
discover_inventory($device, $index, $inventory[$index], $mib);
discover_inventory($device, $index+1, $inventory[$index+1], $mib);
unset($serial, $model);
} else {
$i = $index-2;
$inventory[$i]['entPhysicalName'] = $inventory[$i]['entPhysicalName'] . '+' . $entry['drsServerSlotNumber'];
discover_inventory($device, $i, $inventory[$i], $mib);
}
}
}
// EOF

View File

@ -0,0 +1,134 @@
<?php
if (is_device_mib($device, 'DES-1210-28ME-B2')) {
$vendor_mib = 'DES-1210-28ME-B2';
$vendor_oids = snmpwalk_cache_oid($device, "sfpVendorInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
print_debug_vars($vendor_oids);
$copperports = 24;
$comboports = 2;
$fiberports = 2;
} else {
return;
}
echo($vendor_mib);
$revision = snmp_get_oid($device, 'probeHardwareRev.0', 'RMON2-MIB');
$system_index = 1;
$inventory[$system_index] = [
'entPhysicalDescr' => $device['sysDescr'],
'entPhysicalClass' => 'chassis',
'entPhysicalName' => $device['hardware'],
'entPhysicalHardwareRev' => $revision,
'entPhysicalSoftwareRev' => $device['version'],
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $device['hardware'],
'entPhysicalSerialNum' => $device['serial'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'D-Link',
];
discover_inventory($device, $system_index, $inventory[$system_index], $vendor_mib);
/*
DES-1210-28ME-B2::companySfpVendorInfo
sfpPortIndex.27 = 27
sfpPortIndex.28 = 28
sfpConnectorType.27 = SFP - MT-RJ
sfpConnectorType.28 = SFP - SC
sfpTranceiverCode.27 =
sfpTranceiverCode.28 = Unallocated
sfpBaudRate.27 = d
sfpBaudRate.28 = d
sfpVendorName.27 =
sfpVendorName.28 =
sfpVendorOui.27 = 0:90:65
sfpVendorOui.28 = 0: 0: 0
sfpVendorPn.27 = SFP-1.25G-1310
sfpVendorPn.28 = TBSF15d1012gSC3c
sfpVendorRev.27 = A0
sfpVendorRev.28 = A
sfpWavelength.27 = 51e
sfpWavelength.28 = 60e
sfpVendorSn.27 = SC91750197
sfpVendorSn.28 = F201705111103
sfpDateCode.27 = 120904
sfpDateCode.28 = 170512
DES-1210-28ME-B2::sfpPortIndex.25 = INTEGER: 25
DES-1210-28ME-B2::sfpPortIndex.26 = INTEGER: 26
DES-1210-28ME-B2::sfpPortIndex.28 = INTEGER: 28
DES-1210-28ME-B2::sfpConnectorType.25 = STRING: "SFP - SC"
DES-1210-28ME-B2::sfpConnectorType.26 = STRING: "SFP - SC"
DES-1210-28ME-B2::sfpConnectorType.28 = STRING: "SFP - SC"
DES-1210-28ME-B2::sfpTranceiverCode.25 = STRING: "Unallocated"
DES-1210-28ME-B2::sfpTranceiverCode.26 = STRING: "Single Mode"
DES-1210-28ME-B2::sfpTranceiverCode.28 = STRING: "Single Mode"
DES-1210-28ME-B2::sfpBaudRate.25 = STRING: "d"
DES-1210-28ME-B2::sfpBaudRate.26 = STRING: "d"
DES-1210-28ME-B2::sfpBaudRate.28 = STRING: "d"
DES-1210-28ME-B2::sfpVendorName.25 = ""
DES-1210-28ME-B2::sfpVendorName.26 = ""
DES-1210-28ME-B2::sfpVendorName.28 = ""
DES-1210-28ME-B2::sfpVendorOui.25 = STRING: " 0: 0: 0"
DES-1210-28ME-B2::sfpVendorOui.26 = STRING: " 0: 0: 0"
DES-1210-28ME-B2::sfpVendorOui.28 = STRING: " 0: 0: 0"
DES-1210-28ME-B2::sfpVendorPn.25 = STRING: "TBSF13312gSC3cDD"
DES-1210-28ME-B2::sfpVendorPn.26 = STRING: "SFP-BIDI "
DES-1210-28ME-B2::sfpVendorPn.28 = STRING: "AP-B53121-3CS3 "
DES-1210-28ME-B2::sfpVendorRev.25 = STRING: "A "
DES-1210-28ME-B2::sfpVendorRev.26 = STRING: "1.0 "
DES-1210-28ME-B2::sfpVendorRev.28 = STRING: "1.00"
DES-1210-28ME-B2::sfpWavelength.25 = STRING: "51e"
DES-1210-28ME-B2::sfpWavelength.26 = STRING: "60e"
DES-1210-28ME-B2::sfpWavelength.28 = STRING: "60e"
DES-1210-28ME-B2::sfpVendorSn.25 = STRING: "F201705113806 "
DES-1210-28ME-B2::sfpVendorSn.26 = STRING: "G181687 "
DES-1210-28ME-B2::sfpVendorSn.28 = STRING: "SG53E20800234 "
DES-1210-28ME-B2::sfpDateCode.25 = STRING: "170517 "
DES-1210-28ME-B2::sfpDateCode.26 = STRING: "180916 "
DES-1210-28ME-B2::sfpDateCode.28 = STRING: "120224 "
*/
$totalports = $copperports + $comboports + $fiberports;
for ($i = 1; $i <= $totalports; $i++) {
$system_index = 100 + $i;
if ($i <= $copperports) {
$inventory[$system_index] = [
'entPhysicalDescr' => '100Base-T Copper Port',
'entPhysicalClass' => 'port',
'entPhysicalName' => 'Port '.$i,
'entPhysicalIsFRU' => 'false',
'entPhysicalModelName' => 'Copper Port',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $i,
'ifIndex' => $i,
];
} else {
if ($i <= $copperports + $comboports) {
$portdescr = 'Combo Port';
} else {
$portdescr = 'SFP Port';
}
$inventory[$system_index] = [
'entPhysicalDescr' => $portdescr,
'entPhysicalClass' => 'port',
'entPhysicalName' => 'Port '.$i,
'entPhysicalIsFRU' => 'false',
'entPhysicalModelName' => trim($vendor_oids[$i]['sfpTranceiverCode']),
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $i,
'ifIndex' => $i,
'entPhysicalVendorType' => trim($vendor_oids[$i]['sfpConnectorType']),
'entPhysicalSerialNum' => trim($vendor_oids[$i]['sfpVendorSn']),
'entPhysicalHardwareRev' => trim($vendor_oids[$i]['sfpVendorPn']),
'entPhysicalFirmwareRev' => trim($vendor_oids[$i]['sfpVendorRev']),
'entPhysicalMfgName' => trim($vendor_oids[$i]['sfpVendorName']),
];
}
discover_inventory($device, $system_index, $inventory[$system_index], $vendor_mib);
}
print_debug_vars($inventory);
// EOF

View File

@ -0,0 +1,15 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
include __DIR__ . '/des3026-l2mgmt-mib.inc.php';
// EOF

View File

@ -0,0 +1,102 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (is_device_mib($device, 'DES3026-L2MGMT-MIB')) {
$desmib = 'DES3026-L2MGMT-MIB';
$copperports = 24;
} elseif (is_device_mib($device, 'DES3018-L2MGMT-MIB')) {
$desmib = 'DES3018-L2MGMT-MIB';
$copperports = 16;
} else {
return;
}
echo($desmib);
$revision = snmp_get_oid($device, 'probeHardwareRev.0', 'RMON2-MIB');
$system_index = 1;
$inventory[$system_index] = array(
'entPhysicalDescr' => $device['sysDescr'],
'entPhysicalClass' => 'chassis',
'entPhysicalName' => $device['hardware'],
'entPhysicalHardwareRev' => $revision,
'entPhysicalSoftwareRev' => $device['version'],
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $device['hardware'],
'entPhysicalSerialNum' => $device['serial'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'D-Link',
);
discover_inventory($device, $system_index, $inventory[$system_index], $desmib);
for ($i = 1; $i <= $copperports; $i++) {
$system_index = 100 + $i;
$inventory[$system_index] = array(
'entPhysicalDescr' => '100Base-T Copper Port',
'entPhysicalClass' => 'port',
'entPhysicalName' => 'Port '.$i,
'entPhysicalIsFRU' => 'false',
'entPhysicalModelName' => 'Copper Port',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $i,
'ifIndex' => $i,
);
discover_inventory($device, $system_index, $inventory[$system_index], $desmib);
}
for ($slot = 1; $slot <= 2; $slot++) {
// Slot 1
$system_index = 100 + $i;
$inventory[$system_index] = array(
'entPhysicalDescr' => 'DES-3018/3026 extended Slot',
'entPhysicalClass' => 'container',
'entPhysicalName' => 'Slot '.$slot,
'entPhysicalIsFRU' => 'false',
'entPhysicalModelName' => 'Extended Slot',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $i,
);
discover_inventory($device, $system_index, $inventory[$system_index], $desmib);
if ($slot == 1) {
$des30xxswL2ModuleXType = snmp_get_oid($device, 'swL2Module-1-Type.0', $desmib);
} else {
$des30xxswL2ModuleXType = snmp_get_oid($device, 'swL2Module-2-Type.0', $desmib);
}
$system2_index = 200 + $i;
$inventory[$system2_index] = array(
'entPhysicalDescr' => $des30xxswL2ModuleXType,
'entPhysicalClass' => 'module',
'entPhysicalName' => 'Module '.$slot,
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => $system_index,
'entPhysicalParentRelPos' => 0,
'entPhysicalMfgName' => 'D-Link',
);
discover_inventory($device, $system2_index, $inventory[$system2_index], $desmib);
$system3_index = 300 + $i;
$inventory[$system3_index] = array(
'entPhysicalDescr' => 'Gigabit Ethernet',
'entPhysicalClass' => 'port',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $system2_index,
'entPhysicalParentRelPos' => 0,
'ifIndex' => $i,
);
discover_inventory($device, $system3_index, $inventory[$system3_index], $desmib);
// Slot 2
$i++;
}
print_debug_vars($inventory);
// EOF

View File

@ -0,0 +1,75 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// This device not have self Indexes.
// Use workaround ($base_vendor_index * 100000) + ($e7CardBank * 1000) + $e7CardIndex
$base_vendor_index = 6321;
// System
$e7SystemId = snmp_get($device, 'e7SystemId.0', '-OQUs', 'E7-Calix-MIB');
if ($e7SystemId)
{
$e7SystemChassisSerialNumber = snmp_get($device, '.1.3.6.1.4.1.6321.1.2.2.2.1.7.10.0', '-Oqvn');
$system_index = $base_vendor_index * 100000;
$inventory[$system_index] = array(
'entPhysicalDescr' => 'Calix Networks, E7 Ethernet Service Access Platform',
'entPhysicalClass' => 'chassis',
'entPhysicalName' => 'E7 ESAP',
'entPhysicalSerialNum' => $e7SystemChassisSerialNumber,
'entPhysicalAssetID' => $e7SystemId,
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => 0,
'entPhysicalMfgName' => 'Calix'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
// Cards
$E7CardEntry = snmpwalk_cache_twopart_oid($device, 'E7CardEntry', array(), 'E7-Calix-MIB');
foreach ($E7CardEntry as $e7CardBank => $entries)
{
$bank_index = $system_index + $e7CardBank * 1000;
$inventory[$bank_index] = array(
'entPhysicalDescr' => 'E7 ESAP Bank',
'entPhysicalClass' => 'container',
'entPhysicalName' => 'Bank '.$e7CardBank,
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $system_index,
'entPhysicalParentRelPos' => $e7CardBank,
'entPhysicalMfgName' => 'Calix'
);
discover_inventory($device, $bank_index, $inventory[$bank_index], $mib);
foreach ($entries as $e7CardIndex => $entry)
{
$card_index = $bank_index + $e7CardIndex;
$inventory[$card_index] = array(
'entPhysicalDescr' => 'E7 ESAP Card',
'entPhysicalClass' => 'other',
'entPhysicalName' => 'Card '.ucfirst($entry['e7CardActualType']),
'entPhysicalVendorType' => $entry['e7CardActualType'],
'entPhysicalSerialNum' => $entry['e7CardSerialNumber'],
'entPhysicalSoftwareRev' => $entry['e7CardSoftwareVersion'],
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $bank_index,
'entPhysicalParentRelPos' => $e7CardIndex,
'entPhysicalMfgName' => 'Calix'
);
discover_inventory($device, $card_index, $inventory[$card_index], $mib);
}
}
print_debug_vars($inventory);
}
// EOF

View File

@ -0,0 +1,208 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
echo("ENTITY-MIB ");
$snmp_flags = OBS_SNMP_ALL;
//snmp_log_error(OBS_SNMP_ERROR_OID_NOT_INCREASING, FALSE); // disable log error for next snmpwalk
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", [], snmp_mib_entity_vendortype($device, 'ENTITY-MIB'));
if (!snmp_status()) {
if (snmp_error_code() === OBS_SNMP_ERROR_OID_NOT_INCREASING) {
// Try refetch with NOINCREASE
$snmp_flags |= OBS_SNMP_NOINCREASE;
print_debug("WARNING! snmpwalk error 'OID not increasing' detected, try snmpwalk with -Cc option.");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, snmp_mib_entity_vendortype($device, 'ENTITY-MIB'), NULL, $snmp_flags);
if (!snmp_status()) { return; }
} else {
return;
}
}
$entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, 'ENTITY-MIB:IF-MIB', NULL, $snmp_flags);
$GLOBALS['cache']['snmp']['ENTITY-MIB'][$device['device_id']] = $entity_array; // Cache this array for sensors discovery (see in cisco-entity-sensor-mib or entity-sensor-mib)
// Some vendor specific inventory expander's
$vendor_oids = [];
$vendor_mib = NULL;
if (is_device_mib($device, 'ELTEX-MES-PHYSICAL-DESCRIPTION-MIB')) {
$vendor_mib = 'ELTEX-MES-PHYSICAL-DESCRIPTION-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "eltPhdTransceiverInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS3627G-L2MGMT-MIB')) {
$vendor_mib = 'DGS3627G-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS3120-24SC-L2MGMT-MIB')) {
$vendor_mib = 'DGS3120-24SC-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS-3420-28SC-L2MGMT-MIB')) {
$vendor_mib = 'DGS-3420-28SC-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS-3420-26SC-L2MGMT-MIB')) {
$vendor_mib = 'DGS-3420-26SC-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS-3620-28SC-L2MGMT-MIB')) {
$vendor_mib = 'DGS-3620-28SC-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
} elseif (is_device_mib($device, 'DGS-3620-26SC-L2MGMT-MIB')) {
$vendor_mib = 'DGS-3620-26SC-L2MGMT-MIB';
$vendor_oids = snmpwalk_cache_oid($device, "swL2PortSfpInfoTable", $vendor_oids, $vendor_mib, NULL, $snmp_flags);
//print_vars($entity_array);
//print_debug_vars($vendor_oids);
}
foreach ($entity_array as $entPhysicalIndex => $entry) {
unset($entAliasMappingIdentifier);
foreach ([ 0, 1, 2 ] as $i) {
if (isset($entity_array[$entPhysicalIndex][$i]['entAliasMappingIdentifier'])) {
$entAliasMappingIdentifier = $entity_array[$entPhysicalIndex][$i]['entAliasMappingIdentifier'];
break;
}
}
if (isset($entAliasMappingIdentifier) && str_contains_array($entAliasMappingIdentifier, 'fIndex')) {
list(, $ifIndex) = explode('.', $entAliasMappingIdentifier);
$entry['ifIndex'] = $ifIndex;
}
// Some vendor specific inventory expander's
if ($vendor_mib === 'ELTEX-MES-PHYSICAL-DESCRIPTION-MIB' && isset($vendor_oids[$entry['ifIndex']])) {
//$entry = array_merge($entry, $vendor_oids[$entry['ifIndex']]);
print_debug_vars($vendor_oids[$entry['ifIndex']]);
/*
[entPhysicalDescr] => string(20) "gigabitethernet1/0/2"
[entPhysicalVendorType] => string(17) "cevPortDCUATMPort"
[entPhysicalContainedIn] => string(8) "68424704"
[entPhysicalClass] => string(4) "port"
[entPhysicalParentRelPos] => string(1) "4"
[entPhysicalName] => string(7) "gi1/0/2"
[entPhysicalHardwareRev] => string(0) ""
[entPhysicalFirmwareRev] => string(0) ""
[entPhysicalSoftwareRev] => string(0) ""
[entPhysicalSerialNum] => string(0) ""
[entPhysicalMfgName] => string(0) ""
[entPhysicalModelName] => string(0) ""
[entPhysicalAlias] => string(0) ""
[entPhysicalAssetID] => string(0) ""
[entPhysicalIsFRU] => string(5) "false"
*/
/*
[eltPhdTransceiverInfoConnectorType] => string(2) "sc"
[eltPhdTransceiverInfoType] => string(11) "sfp-sfpplus"
[eltPhdTransceiverInfoComplianceCode] => string(11) "1000BASE-LX"
[eltPhdTransceiverInfoWaveLength] => string(4) "1550"
[eltPhdTransceiverInfoVendorName] => string(16) "OptiCin "
[eltPhdTransceiverInfoSerialNumber] => string(16) "PF4D870547 "
[eltPhdTransceiverInfoFiberDiameterType] => string(6) "fiber9"
[eltPhdTransceiverInfoTransferDistance] => string(4) "3000"
[eltPhdTransceiverInfoDiagnostic] => string(5) "false"
[eltPhdTransceiverInfoPartNumber] => string(16) "SFP-WDM5.03 "
[eltPhdTransceiverInfoVendorRev] => string(4) " "
*/
// entPhysicalVendorType -> eltPhdTransceiverInfoType
// entPhysicalHardwareRev -> eltPhdTransceiverInfoPartNumber
// entPhysicalFirmwareRev -> eltPhdTransceiverInfoVendorRev
// entPhysicalSoftwareRev -> ??
// entPhysicalSerialNum -> eltPhdTransceiverInfoSerialNumber
// entPhysicalMfgName -> eltPhdTransceiverInfoVendorName
// entPhysicalModelName -> eltPhdTransceiverInfoComplianceCode
// entPhysicalAlias -> ??
// entPhysicalAssetID -> ??
$entry['entPhysicalVendorType'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoType']);
$entry['entPhysicalHardwareRev'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoPartNumber']);
$entry['entPhysicalFirmwareRev'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoVendorRev']);
$entry['entPhysicalSerialNum'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoSerialNumber']);
$entry['entPhysicalMfgName'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoVendorName']);
$entry['entPhysicalModelName'] = trim($vendor_oids[$entry['ifIndex']]['eltPhdTransceiverInfoComplianceCode']);
} elseif (str_starts($vendor_mib, 'DGS') && $entry['entPhysicalModelName'] === 'Fiber Port' &&
isset($vendor_oids[$entry['entPhysicalParentRelPos']]) &&
is_numeric($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoDateCode'])) {
//$entry = array_merge($entry, $vendor_oids[$entry['ifIndex']]);
print_debug_vars($vendor_oids[$entry['entPhysicalParentRelPos']]);
/*
[13] => array(
[entPhysicalDescr] => string(29) "1000_TXGBIC_COMBO Copper Port"
[entPhysicalVendorType] => string(11) "zeroDotZero"
[entPhysicalContainedIn] => string(1) "2"
[entPhysicalClass] => string(4) "port"
[entPhysicalParentRelPos] => string(2) "21"
[entPhysicalName] => string(7) "Port 21"
[entPhysicalHardwareRev] => string(0) ""
[entPhysicalFirmwareRev] => string(0) ""
[entPhysicalSoftwareRev] => string(0) ""
[entPhysicalSerialNum] => string(0) ""
[entPhysicalMfgName] => string(0) ""
[entPhysicalModelName] => string(11) "Copper Port"
[entPhysicalAlias] => string(0) ""
[entPhysicalAssetID] => string(0) ""
[entPhysicalIsFRU] => string(5) "false"
)
...
[37] => array(
[entPhysicalDescr] => string(28) "1000_TXGBIC_COMBO Fiber Port"
[entPhysicalVendorType] => string(11) "zeroDotZero"
[entPhysicalContainedIn] => string(1) "2"
[entPhysicalClass] => string(4) "port"
[entPhysicalParentRelPos] => string(2) "21"
[entPhysicalName] => string(7) "Port 21"
[entPhysicalHardwareRev] => string(0) ""
[entPhysicalFirmwareRev] => string(0) ""
[entPhysicalSoftwareRev] => string(0) ""
[entPhysicalSerialNum] => string(0) ""
[entPhysicalMfgName] => string(0) ""
[entPhysicalModelName] => string(10) "Fiber Port"
[entPhysicalAlias] => string(0) ""
[entPhysicalAssetID] => string(0) ""
[entPhysicalIsFRU] => string(5) "false"
)
*/
/*
[21] => array(
[swL2PortSfpInfoPortIndex] => string(2) "21"
[swL2PortSfpInfoConnectType] => string(6) "SFP LC"
[swL2PortSfpInfoVendorName] => string(3) "OEM"
[swL2PortSfpInfoVendorPN] => string(10) "SFP-BX-U31"
[swL2PortSfpInfoVendorSN] => string(8) "F10GU046"
[swL2PortSfpInfoVendorOUI] => string(6) "0:0:0."
[swL2PortSfpInfoVendorRev] => string(3) "1.0"
[swL2PortSfpInfoDateCode] => string(6) "090701"
[swL2PortSfpInfoFiberType] => string(16) "Single Mode (SM)"
[swL2PortSfpInfoBaudRate] => string(4) "1300"
[swL2PortSfpInfoWavelength] => string(4) "1310"
)
*/
$entry['entPhysicalVendorType'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoConnectType']);
$entry['entPhysicalHardwareRev'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoVendorPN']);
$entry['entPhysicalFirmwareRev'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoVendorRev']);
$entry['entPhysicalSerialNum'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoVendorSN']);
$entry['entPhysicalMfgName'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoVendorName']);
$entry['entPhysicalModelName'] = trim($vendor_oids[$entry['entPhysicalParentRelPos']]['swL2PortSfpInfoFiberType']);
}
if ($entry['entPhysicalDescr'] || $entry['entPhysicalName']) {
discover_inventory($device, $entPhysicalIndex, $entry, $mib);
}
}
// EOF

View File

@ -0,0 +1,271 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2015 Observium Limited
*
*/
echo(" F5-BIGIP-SYSTEM-MIB ");
$index = 1; $chassis_pos = 0;
$inventory[$index] = array(
'entPhysicalName' => $device['hardware'].' Chassis',
'entPhysicalDescr' => $device['hostname'],
'entPhysicalClass' => 'chassis',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $device['hardware'],
'entPhysicalSerialNum' => $device['serial'],
'entPhysicalHardwareRev' => snmp_get($device, "sysGeneralHwName.0", "-Oqv", "F5-BIGIP-SYSTEM-MIB"),
'entPhysicalFirmwareRev' => $device['version'],
'entPhysicalAssetID' => $device['asset_tag'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
if (!isset($cache_discovery['f5-bigip-system-mib']))
{
$cache_discovery['f5-bigip-system-mib']['chassis']['port'] = snmpwalk_cache_oid($device, 'sysInterfaceTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['chassis']['powerSupply'] = snmpwalk_cache_oid($device, 'sysChassisPowerSupplyTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['chassis']['fan'] = snmpwalk_cache_oid($device, 'sysChassisFanTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['chassis']['temp'] = snmpwalk_cache_oid($device, 'sysChassisTempTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['slot']['voltage'] = snmpwalk_cache_oid($device, 'sysBladeVoltageTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['slot']['cpu'] = snmpwalk_cache_oid($device, 'sysCpuSensorTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['slot']['disk'] = snmpwalk_cache_oid($device, 'sysPhysicalDiskTable', array(), 'F5-BIGIP-SYSTEM-MIB');
$cache_discovery['f5-bigip-system-mib']['slot']['temp'] = snmpwalk_cache_oid($device, 'sysBladeTempTable', array(), 'F5-BIGIP-SYSTEM-MIB');
}
$cache_ports = dbFetchRows('SELECT `ifName`,`ifIndex` FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
foreach ($cache_ports as $row => $port)
{
$cache_ports[$port['ifName']] = $port['ifIndex'];
}
$fru = array(
'fan' => 'false',
'powerSupply' => 'true',
'temp' => 'false',
'disk' => 'false',
'port' => 'false',
);
$class = array(
'fan' => 'fan',
'powerSupply' => 'powerSupply',
'temp' => 'sensor',
'disk' => 'disk',
'port' => 'port',
);
foreach ($cache_discovery['f5-bigip-system-mib']['chassis'] as $type => $cache)
{
if (!count($cache)) continue;
$index++; $chassis_pos++;
$container = $index;
$inventory[$index] = array(
'entPhysicalName' => 'Chassis '.ucfirst($type).' Container',
'entPhysicalDescr' => $device['hostname'].' - Chassis '.ucfirst($type).' Container',
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => $fru[$type],
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $chassis_pos,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
$pos = 0;
foreach ($cache as $id => $entry)
{
$index++; $pos++;
$name = ucfirst($type).' '.$id;
$serial = NULL;
$ifindex = NULL;
if ($type == 'port')
{
$ifindex = $cache_ports[$id];
}
$inventory[$index] = array(
'entPhysicalName' => $name,
'entPhysicalDescr' => $device['hostname'].' - '.$name,
'entPhysicalClass' => $class[$type],
'entPhysicalIsFRU' => $fru[$type],
'entPhysicalSerialNum' => $serial,
'entPhysicalContainedIn' => $container,
'entPhysicalParentRelPos' => $pos,
'entPhysicalMfgName' => 'F5',
'ifIndex' => $ifindex
);
discover_inventory($device, $index, $inventory[$index], $mib);
unset($ifIndex);
}
}
// Build and array of stuff by slot
foreach ($cache_discovery['f5-bigip-system-mib']['slot'] as $type => $sensors)
{
foreach ($sensors as $tmp => $sensor)
switch ($type)
{
case 'cpu':
$slots[$sensor['sysCpuSensorSlot']]['cpu'] = $sensor;
break;
case 'disk':
$slots[$sensor['sysPhysicalDiskSlotId']]['disk'] = $sensor;
break;
case 'temp':
$slots[$sensor['sysBladeTempSlot']]['temp'][$sensor['sysBladeTempIndex']] = $sensor;
break;
case 'voltage':
$slots[$sensor['sysBladeVoltageSlot']]['voltage'][$sensor['sysBladeVoltageIndex']] = $sensor;
break;
}
}
foreach ($slots as $slot => $sensors)
{
$index++; $chassis_pos++;
$slot_container = $index;
$pos = 0;
$inventory[$index] = array(
'entPhysicalName' => 'Blade Slot '.$slot.' Container',
'entPhysicalDescr' => $device['hostname'].' - Blade Slot '.$slot.' Container',
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $chassis_pos,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
foreach ($sensors as $type => $entry)
{
$index++;
if ($type == 'disk')
{
$pos++;
$name = $entry['sysPhysicalDiskName'];
$serial = $entry['sysPhysicalDiskSerialNumber'];
$inventory[$index] = array(
'entPhysicalName' => $name,
'entPhysicalDescr' => $device['hostname'].' - '.$name,
'entPhysicalClass' => $class[$type],
'entPhysicalIsFRU' => $fru[$type],
'entPhysicalSerialNum' => $serial,
'entPhysicalContainedIn' => $slot_container,
'entPhysicalParentRelPos' => $pos,
'entPhysicalMfgName' => 'F5',
);
discover_inventory($device, $index, $inventory[$index], $mib);
}
else if ($type == 'cpu')
{
$pos++;
$cpu_container = $index;
$inventory[$index] = array(
'entPhysicalName' => 'Blade Slot '.$slot.' CPU Container',
'entPhysicalDescr' => $device['hostname'].' - Chassis Slot '.$slot.' CPU Container',
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $slot_container,
'entPhysicalParentRelPos' => $pos,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
$index++;
$name = $entry['sysCpuSensorName'].' Temperature';
$inventory[$index] = array(
'entPhysicalName' => $name,
'entPhysicalDescr' => $device['hostname'].' - '.$name,
'entPhysicalClass' => 'sensor',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $cpu_container,
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'F5',
);
discover_inventory($device, $index, $inventory[$index], $mib);
$index++;
$name = $entry['sysCpuSensorName'].' Fan';
$inventory[$index] = array(
'entPhysicalName' => $name,
'entPhysicalDescr' => $device['hostname'].' - '.$name,
'entPhysicalClass' => 'fan',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $cpu_container,
'entPhysicalParentRelPos' => 2,
'entPhysicalMfgName' => 'F5',
);
discover_inventory($device, $index, $inventory[$index], $mib);
}
else if ($type == 'temp')
{
$pos++;
$temp_container = $index;
$inventory[$index] = array(
'entPhysicalName' => 'Blade Slot '.$slot.' Temp Container',
'entPhysicalDescr' => $device['hostname'].' - Chassis Slot '.$slot.' Temp Container',
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $slot_container,
'entPhysicalParentRelPos' => $pos,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
foreach ($entry as $temp_index => $temp_sensor)
{
$index++;
$inventory[$index] = array(
'entPhysicalName' => $temp_sensor['sysBladeTempLocation'],
'entPhysicalDescr' => $device['hostname'].' - '.$temp_sensor['sysBladeTempLocation'],
'entPhysicalClass' => 'sensor',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $temp_container,
'entPhysicalParentRelPos' => $temp_index,
'entPhysicalMfgName' => 'F5',
);
discover_inventory($device, $index, $inventory[$index], $mib);
}
}
else if ($type == 'voltage')
{
$pos++;
$voltage_container = $index;
$inventory[$index] = array(
'entPhysicalName' => 'Blade Slot '.$slot.' Voltage Container',
'entPhysicalDescr' => $device['hostname'].' - Chassis Slot '.$slot.' Voltage Container',
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $slot_container,
'entPhysicalParentRelPos' => $pos,
'entPhysicalMfgName' => 'F5'
);
discover_inventory($device, $index, $inventory[$index], $mib);
$volt_pos = 0;
foreach ($entry as $volt_index => $volt_sensor)
{
$index++; $volt_pos++;
$inventory[$index] = array(
'entPhysicalName' => $volt_index,
'entPhysicalDescr' => $device['hostname'].' - '.$volt_index,
'entPhysicalClass' => 'sensor',
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => $voltage_container,
'entPhysicalParentRelPos' => $volt_pos,
'entPhysicalMfgName' => 'F5',
);
discover_inventory($device, $index, $inventory[$index], $mib);
}
}
}
}
unset($cache_ports, $slots, $name, $index, $container, $pos, $slot_container, $cpu_container, $temp_container, $voltage_container);
// EOF

View File

@ -0,0 +1,71 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$snChasProductType = snmp_get($device, 'snChasProductType.0', '-OQv', 'FOUNDRY-SN-AGENT-MIB');
if ($snChasProductType)
{
$snChasSerNum = snmp_get($device, 'snChasSerNum.0', '-OQv', 'FOUNDRY-SN-AGENT-MIB');
// Insert chassis as index 1, everything hangs off of this.
$system_index = 1;
$inventory[$system_index] = array(
'entPhysicalDescr' => $snChasProductType,
'entPhysicalClass' => 'chassis',
'entPhysicalName' => 'Chassis',
'entPhysicalSerialNum' => $snChasSerNum,
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Brocade'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
// Now fetch data for the rest of the hardware in the chassis
$data = snmpwalk_cache_oid($device, 'snAgentBrdTable', array(), 'FOUNDRY-SN-AGENT-MIB');
$relPos = 0;
foreach ($data as $part)
{
$system_index = $part['snAgentBrdIndex']*256;
if ($system_index != 0)
{
$containedIn = 1; // Attach to chassis inserted above
// snAgentBrdModuleStatus.6 = moduleRunning
// snAgentBrdModuleStatus.7 = moduleEmpty
if ($part['snAgentBrdModuleStatus'] != 'moduleEmpty')
{
$relPos++;
$inventory[$system_index] = array(
'entPhysicalDescr' => $part['snAgentBrdMainBrdDescription'],
'entPhysicalClass' => 'module',
'entPhysicalName' => $part['snAgentBrdMainBrdDescription'],
'entPhysicalSerialNum' => $part['snAgentBrdSerialNumber'],
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => $containedIn,
'entPhysicalParentRelPos' => $relPos,
'entPhysicalMfgName' => 'Brocade'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
}
}
}
// EOF

View File

@ -0,0 +1,133 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$productTitle = snmp_get($device, 'productTitle.0', '-OQv', 'GEIST-MIB-V3');
if ($productTitle)
{
// Insert chassis as index 1, everything hangs off of this.
$system_index = 1;
$inventory[$system_index] = array(
'entPhysicalDescr' => $productTitle,
'entPhysicalClass' => 'chassis',
'entPhysicalName' => 'Chassis',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Geist',
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
$relPos = 1;
// Note: sensors without example SNMP output have not been tested.
$geist_sensors = array(
// GEIST-MIB-V3::climateSerial.1 = STRING: 28F123456700000D
// GEIST-MIB-V3::climateName.1 = STRING: RSMINI163
// GEIST-MIB-V3::climateAvail.1 = Gauge32: 1
array('descr' => 'Climate Monitor', 'prefix' => 'climate', 'oid' => 2, 'class' => 'sensor'),
// GEIST-MIB-V3::powMonSerial.1 = STRING: 3B0000007BF12345
// GEIST-MIB-V3::powMonName.1 = STRING: Outlet
// GEIST-MIB-V3::powMonAvail.1 = Gauge32: 1
array('descr' => 'Power Monitor', 'prefix' => 'powMon', 'oid' => 3, 'class' => 'powerSupply', 'avail' => 1),
array('descr' => 'Temperature Sensor', 'prefix' => 'tempSensor', 'oid' => 4, 'class' => 'sensor'),
// GEIST-MIB-V3::airFlowSensorSerial.1 = STRING: 2000000012345678
// GEIST-MIB-V3::airFlowSensorName.1 = STRING: AF/HTD Sensor
// GEIST-MIB-V3::airFlowSensorAvail.1 = Gauge32: 1
array('descr' => 'AF/HTD Sensor', 'prefix' => 'airFlowSensor', 'oid' => 5, 'class' => 'airflowSensor'),
array('descr' => 'DELTA 3 Channel Controller', 'prefix' => 'ctrl3ChDELTA', 'oid' => 6, 'class' => 'sensor'),
// GEIST-MIB-V3::doorSensorSerial.1 = STRING: 0E00000123456789
// GEIST-MIB-V3::doorSensorName.1 = STRING: Door Sensor
// GEIST-MIB-V3::doorSensorAvail.1 = Gauge32: 1
array('descr' => 'Door Sensor', 'prefix' => 'doorSensor', 'oid' => 7, 'class' => 'sensor'),
array('descr' => 'Water Sensor', 'prefix' => 'waterSensor', 'oid' => 8, 'class' => 'sensor'),
array('descr' => 'Current Sensor', 'prefix' => 'currentSensor', 'oid' => 9, 'class' => 'sensor'),
array('descr' => 'Millivolt Sensor', 'prefix' => 'millivoltSensor', 'oid' => 10, 'class' => 'sensor'),
array('descr' => '3 Channel Power Sensor', 'prefix' => 'power3ChSensor', 'oid' => 11, 'class' => 'sensor'),
array('descr' => 'Outlet', 'prefix' => 'outlet', 'oid' => 12, 'class' => 'outlet'),
array('descr' => 'Fan Controller Monitor', 'prefix' => 'vsfc', 'oid' => 13, 'class' => 'sensor'),
array('descr' => '3 Channel Power Monitor', 'prefix' => 'ctrl3Ch', 'oid' => 14, 'class' => 'sensor'),
array('descr' => 'Amperage Controller', 'prefix' => 'analogSensor', 'oid' => 15, 'class' => 'powerSupply'),
// GEIST-MIB-V3::ctrlOutletName.1 = STRING: Outlet 1
array('descr' => 'Controlled outlet', 'prefix' => 'ctrlOutlet', 'oid' => 16, 'class' => 'outlet', 'avail' => 1),
array('descr' => 'Dew Point Sensor', 'prefix' => 'dewpointSensor', 'oid' => 17, 'class' => 'sensor'),
// GEIST-MIB-V3::digitalSensorSerial.1 = STRING: 8C00000493782754
// GEIST-MIB-V3::digitalSensorName.1 = STRING: CCAT
// GEIST-MIB-V3::digitalSensorAvail.1 = Gauge32: 1
array('descr' => 'Digital Sensor', 'prefix' => 'digitalSensor', 'oid' => 18, 'class' => 'sensor'),
array('descr' => 'DSTS Controller Sensor', 'prefix' => 'dstsSensor', 'oid' => 19, 'class' => 'sensor'),
array('descr' => 'City Power Sensor', 'prefix' => 'cpmSensor', 'oid' => 20, 'class' => 'sensor'),
// GEIST-MIB-V3::smokeAlarmSerial.1 = STRING: D900000498765432
// GEIST-MIB-V3::smokeAlarmName.1 = STRING: Smoke Alarm
// GEIST-MIB-V3::smokeAlarmAvail.1 = Gauge32: 1
array('descr' => 'Smoke Alarm Sensor', 'prefix' => 'smokeAlarm', 'oid' => 21, 'class' => 'sensor'),
array('descr' => '-48VDC Sensor', 'prefix' => 'neg48VdcSensor', 'oid' => 22, 'class' => 'sensor'),
array('descr' => '+30VDC Sensor', 'prefix' => 'pos30VdcSensor', 'oid' => 23, 'class' => 'sensor'),
array('descr' => 'Analog Sensor', 'prefix' => 'analogSensor', 'oid' => 24, 'class' => 'sensor'),
// GEIST-MIB-V3::ctrl3ChIECSerial.1 = STRING: 0000777654567777
// GEIST-MIB-V3::ctrl3ChIECName.1 = STRING: my-geist-pdu0
// GEIST-MIB-V3::ctrl3ChIECAvail.1 = Gauge32: 1
array('descr' => '3 Channel IEC Power Monitor', 'prefix' => 'ctrl3ChIEC', 'oid' => 25, 'class' => 'powerSupply'),
// GEIST-MIB-V3::climateRelaySerial.1 = STRING: 2878924802000000
// GEIST-MIB-V3::climateRelayName.1 = STRING: GRSO
// GEIST-MIB-V3::climateRelayAvail.1 = Gauge32: 1
array('descr' => 'Climate Relay Monitor', 'prefix' => 'climateRelay', 'oid' => 26, 'class' => 'sensor'),
// GEIST-MIB-V3::ctrlRelayName.1 = STRING: Relay-1
array('descr' => 'Controlled Relay', 'prefix' => 'ctrlRelay', 'oid' => 27, 'class' => 'relay', 'avail' => 1),
array('descr' => 'Airspeed Switch Sensor', 'prefix' => 'airSpeedSwitchSensor', 'oid' => 28, 'class' => 'sensor'),
// GEIST-MIB-V3::powerDMSerial.1 = STRING: E200000076221234
// GEIST-MIB-V3::powerDMName.1 = STRING: DM16 PDU
// GEIST-MIB-V3::powerDMAvail.1 = Gauge32: 1
array('descr' => 'DM16/48 Current Sensor', 'prefix' => 'powerDM', 'oid' => 29, 'class' => 'sensor'),
array('descr' => 'I/O Expander', 'prefix' => 'ioExpander', 'oid' => 30, 'class' => 'sensor'),
array('descr' => 'T3HD Sensor', 'prefix' => 't3hdSensor', 'oid' => 31, 'class' => 'sensor'),
array('descr' => 'THD Sensor', 'prefix' => 'thdSensor', 'oid' => 32, 'class' => 'sensor'),
array('descr' => '+60VDC Sensor', 'prefix' => 'pos60VdcSensor', 'oid' => 33, 'class' => 'sensor'),
array('descr' => '3Phase Outlet Control', 'prefix' => 'ctrl2CirTot', 'oid' => 34, 'class' => 'outlet'),
array('descr' => 'SC10 Sensor', 'prefix' => 'sc10Sensor', 'oid' => 35, 'class' => 'sensor'),
);
foreach ($geist_sensors as $sensor)
{
$oids = snmp_cache_table($device, $sensor['prefix'].'Table', array(), 'GEIST-MIB-V3');
foreach ($oids as $index => $entry)
{
// Index can only be int in the database, so we create our own from, this sensor is at 21239.2.$oid.
$system_index = $sensor['oid'] * 256 + $index;
if ($sensor['avail'] || $entry[$sensor['prefix'].'Avail'])
{
$inventory[$system_index] = array(
'entPhysicalDescr' => $sensor['descr'],
'entPhysicalClass' => $sensor['class'],
'entPhysicalName' => $entry[$sensor['prefix'].'Name'],
'entPhysicalSerialNum' => $entry[$sensor['prefix'].'Serial'],
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $relPos,
'entPhysicalMfgName' => 'Geist',
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
$relPos++;
}
}
}
}
unset($geist_sensors);
// EOF

View File

@ -0,0 +1,78 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
/// FIXME. Full rewrite and move to inventory stuff
$hrDevice_oids = array('hrDeviceEntry','hrProcessorEntry');
$hrDevices = array();
foreach ($hrDevice_oids as $oid) { $hrDevices = snmpwalk_cache_oid($device, $oid, $hrDevices, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
print_debug_vars($hrDevices);
if (is_array($hrDevices)) {
foreach ($hrDevices as $hrDevice) {
if (!is_numeric($hrDevice['hrDeviceIndex'])) {
print_debug("Empty hrDevice entry skipped:");
print_debug_vars($hrDevice, 1);
continue;
}
if ($hrDevice['hrDeviceType'] === 'hrDevicePrinter' &&
$hrDevice['hrDeviceStatus'] === 'unknown' &&
$hrDevice['hrPrinterStatus'] === 'unknown') {
print_debug("Broken hrDevice entry skipped:");
print_debug_vars($hrDevice, 1);
continue;
}
//if (dbFetchCell("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = ? AND hrDeviceIndex = ?",array($device['device_id'], $hrDevice['hrDeviceIndex'])))
if (dbExist('hrDevice', '`device_id` = ? AND `hrDeviceIndex` = ?', array($device['device_id'], $hrDevice['hrDeviceIndex'])))
{
if (($hrDevice['hrDeviceType'] === "hrDeviceProcessor") && empty($hrDevice['hrDeviceDescr']))
{
$hrDevice['hrDeviceDescr'] = "Processor";
}
$update_array = array('hrDeviceType' => $hrDevice['hrDeviceType'],
'hrDeviceDescr' => $hrDevice['hrDeviceDescr'],
'hrDeviceStatus' => $hrDevice['hrDeviceStatus'],
'hrDeviceErrors' => $hrDevice['hrDeviceErrors']);
if ($hrDevice['hrDeviceType'] === "hrDeviceProcessor")
{
$update_array['hrProcessorLoad'] = $hrDevice['hrProcessorLoad'];
} else {
$update_array['hrProcessorLoad'] = array('NULL');
}
dbUpdate($update_array, 'hrDevice', 'device_id = ? AND hrDeviceIndex = ?', array($device['device_id'], $hrDevice['hrDeviceIndex']));
// FIXME -- check if it has updated, and print a U instead of a .
echo(".");
} else {
$inserted = dbInsert(array('hrDeviceIndex' => $hrDevice['hrDeviceIndex'], 'device_id' => $device['device_id'], 'hrDeviceType' => $hrDevice['hrDeviceType'], 'hrDeviceDescr' => $hrDevice['hrDeviceDescr'], 'hrDeviceStatus' => $hrDevice['hrDeviceStatus'], 'hrDeviceErrors' => $hrDevice['hrDeviceErrors']), 'hrDevice');
echo("+");
}
$valid_hrDevice[$hrDevice['hrDeviceIndex']] = 1;
}
}
foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ?', array($device['device_id'])) as $test_hrDevice)
{
if (!$valid_hrDevice[$test_hrDevice['hrDeviceIndex']])
{
$deleted = dbDelete('hrDevice', '`hrDevice_id` = ?', array($test_hrDevice['hrDevice_id']));
echo("-");
if (OBS_DEBUG > 1) { print_vars($test_hrDevice); echo($deleted . " deleted"); }
}
}
unset($valid_hrDevice);
// EOF

View File

@ -0,0 +1,111 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$domain = snmpwalk_cache_oid($device, 'vcDomain', NULL, 'HPVC-MIB');
$domain = $domain[0];
// Domain
$array = array(
'entPhysicalName' => $domain['vcDomainName'],
'entPhysicalClass' => 'domain',
'entPhysicalIsFRU' => 'true',
'entPhysicalDescr' => $domain['vcDomainPrimaryAddressType'],
'entPhysicalAssetID' => $domain['vcDomainPrimaryAddress'],
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'HPE'
);
discover_inventory($device, '-1', $array, $mib);
$entries = snmpwalk_cache_oid($device, 'vcEnclosureTable', NULL, 'HPVC-MIB');
foreach ($entries as $index => $entry)
{
$array = array(
'entPhysicalName' => $entry['vcEnclosureName'],
'entPhysicalClass' => 'chassis',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalDescr' => $entry['vcEnclosureAddressType'],
'entPhysicalSerialNum' => $entry['vcEnclosureUUID'],
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HPE'
);
if(isset($entry['vcEnclosureIndex']))
{
discover_inventory($device, $index, $array, $mib);
}
}
unset($entries, $array, $domain);
$entries = snmpwalk_cache_oid($device, 'vcPhysicalServerTable', NULL, 'HPVC-MIB');
// Blades
foreach ($entries as $index => $entry)
{
$array = array(
'entPhysicalName' => 'Slot '.$entry['vcPhysicalServerLocation.'],
'entPhysicalClass' => 'container',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $entry['vcPhysicalServerLocation.'],
'entPhysicalContainedIn' => $entry['vcPhysicalServerEnclosureIndex'],
'entPhysicalMfgName' => 'HPE'
);
//discover_inventory($device, '999'.$index, $array, $mib);
$array = array(
'entPhysicalName' => $entry['vcPhysicalServerProductName'],
//'entPhysicalDescr' => $entry['vcPhysicalServerProductName'],
'entPhysicalClass' => 'module',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $entry['vcPhysicalServerPartNumber'],
'entPhysicalSerialNum' => $entry['vcPhysicalServerSerialNumber'],
'entPhysicalContainedIn' => $entry['vcPhysicalServerEnclosureIndex'],
'entPhysicalParentRelPos' => 1,
'entPhysicalMfgName' => 'HPE'
);
if(isset($entry['vcPhysicalServerEnclosureIndex']))
{
discover_inventory($device, $index, $array, $mib);
}
}
$entries = snmpwalk_cache_oid($device, 'vcModuleTable', NULL, 'HPVC-MIB');
// Modules
foreach ($entries as $index => $entry)
{
list($entry['type'], $entry['index']) = explode('.', $entry['vcModuleEnclosurePointer']);
$array = array(
'entPhysicalName' => $entry['vcModuleProductName'],
//'entPhysicalDescr' => $entry['vcPhysicalServerProductName'],
'entPhysicalClass' => 'module',
'entPhysicalIsFRU' => 'true',
'entPhysicalModelName' => $entry['vcModulePartNumber'],
'entPhysicalSerialNum' => $entry['vcModuleSerialNumber'],
'entPhysicalContainedIn' => $entry['index'],
'entPhysicalParentRelPos' => $entry['vcModuleLocation'],
'entPhysicalMfgName' => 'HPE'
);
if(isset($entry['vcModuleLocation']))
{
discover_inventory($device, '999'.$index, $array, $mib);
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$jnxBoxDescr = snmp_get_oid($device, 'jnxBoxDescr.0', 'JUNIPER-MIB');
if ($jnxBoxDescr) {
$jnxBoxSerialNo = snmp_get_oid($device, 'jnxBoxSerialNo.0', 'JUNIPER-MIB');
// Insert chassis as index 1, everything hangs off of this.
$system_index = 1;
$inventory[$system_index] = array(
'entPhysicalDescr' => $jnxBoxDescr,
'entPhysicalClass' => 'chassis',
'entPhysicalName' => 'Chassis',
'entPhysicalSerialNum' => $jnxBoxSerialNo,
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Juniper'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
// Now fetch data for the rest of the hardware in the chassis
$data = snmpwalk_cache_oid($device, 'jnxContentsTable', array(), 'JUNIPER-MIB:JUNIPER-CHASSIS-DEFINES-MIB');
$data = snmpwalk_cache_oid($device, 'jnxFruTable', $data, 'JUNIPER-MIB:JUNIPER-CHASSIS-DEFINES-MIB');
$global_relPos = 0;
foreach ($data as $part) {
// Index can only be int in the database, so we create our own from 7.1.1.0:
$system_index = $part['jnxContentsContainerIndex'] * 16777216 + $part['jnxContentsL1Index'] * 65536 + $part['jnxContentsL2Index'] * 256 + $part['jnxContentsL3Index'];
if ($system_index != 0) {
if ($part['jnxContentsL2Index'] == 0 && $part['jnxContentsL3Index'] == 0) {
$containedIn = 1; // Attach to chassis inserted above
$global_relPos++; $relPos = $global_relPos;
} else {
$containerIndex = $part['jnxContentsContainerIndex'];
if ($containerIndex == 8) { $containerIndex--; } // Convert PIC (8) to FPC (7) parent
$containedIn = $containerIndex * 16777216 + $part['jnxContentsL1Index'] * 65536;
$relPos = $part['jnxContentsL2Index'];
}
// [jnxFruTemp] => 45 - Could link to sensor somehow? (like we do for ENTITY-SENSOR-MIB)
$inventory[$system_index] = array(
'entPhysicalDescr' => ucfirst($part['jnxContentsDescr']),
'entPhysicalHardwareRev' => $part['jnxContentsRevision'],
'entPhysicalClass' => isset($part['jnxFruType']) ? $part['jnxFruType'] : 'chassis',
'entPhysicalName' => ucfirst($part['jnxFruName'] ?: $part['jnxContentsDescr']),
'entPhysicalSerialNum' => str_replace([ 'S/N ', 'BUILTIN' ], '', $part['jnxContentsSerialNo']),
'entPhysicalModelName' => str_replace('BUILTIN', '', $part['jnxContentsPartNo']),
'entPhysicalVendorType' => $part['jnxContentsType'], //$part['jnxContentsModel'],
'entPhysicalIsFRU' => isset($part['jnxFruType']) ? 'true' : 'false',
'entPhysicalContainedIn' => $containedIn,
'entPhysicalParentRelPos' => $relPos,
'entPhysicalMfgName' => 'Juniper'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
}
}
// EOF

View File

@ -0,0 +1,42 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mtxrBoardName = snmp_get_oid($device, 'mtxrBoardName.0', 'MIKROTIK-MIB');
$mtxrSerialNumber = snmp_get_oid($device, 'mtxrSerialNumber.0', 'MIKROTIK-MIB');
$mtxrLicSoftwareId = snmp_get_oid($device, 'mtxrLicSoftwareId.0', 'MIKROTIK-MIB');
$mtxrLicVersion = snmp_get_oid($device, 'mtxrLicVersion.0', 'MIKROTIK-MIB');
$mtxrFirmwareVersion = snmp_get_oid($device, 'mtxrFirmwareVersion.0', 'MIKROTIK-MIB');
$system_index = 1;
if ($mtxrSerialNumber)
{
$inventory[$system_index] = array(
'entPhysicalDescr' => 'MikroTik RouterBoard',
'entPhysicalClass' => 'chassis',
'entPhysicalName' => '',
'entPhysicalModelName' => $mtxrBoardName,
'entPhysicalSerialNum' => $mtxrSerialNumber,
'entPhysicalAssetID' => $mtxrLicSoftwareId,
'entPhysicalIsFRU' => 'false',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => 0,
'entPhysicalFirmwareRev' => $mtxrFirmwareVersion,
'entPhysicalSoftwareRev' => $mtxrLicVersion,
'entPhysicalMfgName' => 'MikroTik'
);
discover_inventory($device, $system_index, $inventory[$system_index], "MIKROTIK-MIB");
print_debug_vars($inventory);
}
// EOF

View File

@ -0,0 +1,36 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$oids = snmpwalk_cache_oid($device, 'oacExpIMSysHwComponentsTable', array(), 'ONEACCESS-SYS-MIB');
foreach ($oids as $index => $entry)
{
//print_r($entry);
$index = (int)$entry['oacExpIMSysHwcIndex'] + 1;
$inventory[$index] = array(
'entPhysicalDescr' => $entry['oacExpIMSysHwcDescription'],
'entPhysicalName' => $entry['oacExpIMSysHwcProductName'],
'entPhysicalClass' => $entry['oacExpIMSysHwcClass'],
'entPhysicalModelName' => $entry['oacExpIMSysHwcType'],
//'entPhysicalAssetID' => $entry['oacExpIMSysHwcManufacturer'],
'entPhysicalSerialNum' => $entry['oacExpIMSysHwcSerialNumber'],
'entPhysicalIsFRU' => 'false',
'entPhysicalMfgName' => 'OneAccess',
'entPhysicalContainedIn' => ($entry['oacExpIMSysHwcIndex'] == 0 ? 0 : 1),
'entPhysicalParentRelPos' => ($entry['oacExpIMSysHwcIndex'] == 0 ? -1 : (int)$entry['oacExpIMSysHwcIndex']),
);
discover_inventory($device, $index, $inventory[$index], $mib);
}
// EOF

View File

@ -0,0 +1,104 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$ChasProductType = snmp_get_oid($device, 'chassisModelName.1', 'PERLE-MCR-MGT-MIB');
if ($ChasProductType)
{
$ChasDesc = snmp_get_oid($device, 'chassisModelDesc.1', 'PERLE-MCR-MGT-MIB');
$ChasSerNum = snmp_get_oid($device, 'chassisSerialNumber.1', 'PERLE-MCR-MGT-MIB');
$ChasMgmtSlot = snmp_get_oid($device, 'chassisCfgMgmtSlot.1', 'PERLE-MCR-MGT-MIB');
// Insert chassis as index 1, everything hangs off of this.
$system_index = 1;
$inventory[$system_index] = array(
'entPhysicalDescr' => $ChasProductType,
'entPhysicalClass' => 'chassis',
'entPhysicalName' => $ChasDesc,
'entPhysicalSerialNum' => $ChasSerNum,
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 0,
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Perle'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
// Now fetch data for the rest of the hardware in the chassis
$data = snmpwalk_cache_oid($device, 'mcrChassisSlotTable', array(), 'PERLE-MCR-MGT-MIB');
$data_sfp = snmpwalk_cache_oid($device, 'mcrSfpDmiModuleTable', array(), 'PERLE-MCR-MGT-MIB');
$relPos = 0;
foreach ($data as $part)
{
$system_index = $part['mcrChassisSlotIndex'] * 256;
$slotindex = $part['mcrChassisSlotIndex'];
if ($system_index != 0)
{
$containedIn = 1; // Attach to chassis inserted above
// snAgentBrdModuleStatus.6 = moduleRunning
// snAgentBrdModuleStatus.7 = moduleEmpty
if ($part['mcrModuleModelName'] != '')
{
$relPos++;
$inventory[$system_index] = array(
'entPhysicalDescr' => $part['mcrUserDefinedModuleName'] . "(".$part['mcrModuleModelDesc'].")",
'entPhysicalClass' => 'module',
'entPhysicalName' => $part['mcrModuleModelName'],
'entPhysicalSerialNum' => $part['mcrModuleSerialNumber'],
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => $containedIn,
'entPhysicalParentRelPos' => $relPos,
'entPhysicalFirmwareRev' => $part['mcrModuleBootloaderVersion'],
'entPhysicalSoftwareRev' => $part['mcrModuleFirmwareVersion'],
'entPhysicalMfgName' => 'Perle',
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
foreach ($data_sfp as $part_sfp)
{
if ($part_sfp['sfpDmiSlotIndex'] == $slotindex) {
$system_index_sfp = $part_sfp['sfpDmiSlotIndex'] * 256 + 1;
$relPos++;
if ($part_sfp['sfpDmiLinkReach625125'] != 0) { $range = $part_sfp['sfpDmiLinkReach625125']."m"; }
if ($part_sfp['sfpDmiLinkReach50125'] != 0) { $range = $part_sfp['sfpDmiLinkReach50125']."m"; }
if ($part_sfp['sfpDmiLinkReach9125'] != 0) { $range = ($part_sfp['sfpDmiLinkReach9125']/1000)."km"; }
$inventory[$system_index] = array(
'entPhysicalDescr' => $part_sfp['sfpDmiVendorName'] . " SFP (".$part_sfp['sfpDmiFiberWaveLength']."nm ".$range." ".$part_sfp['sfpDmiNominalBitRate']."Mbps)",
'entPhysicalClass' => 'module',
'entPhysicalName' => $part_sfp['sfpDmiVendorPartNumber'],
'entPhysicalSerialNum' => $part_sfp['sfpDmiVendorSerialNumber'],
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => $system_index,
'entPhysicalParentRelPos' => $relPos,
'entPhysicalMfgName' => $part_sfp['sfpDmiVendorName'],
);
discover_inventory($device, $system_index_sfp, $inventory[$system_index], $mib);
}
}
}
}
}
// EOF

View File

@ -0,0 +1,40 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mib = 'RAISECOM-FANMONITOR-MIB';
$serials = snmp_get_oid($device, 'raisecomFanCardSerialNumber.0', $mib); // STRING: "serial1;serial2"
$system_index = 101;
$i = 1;
foreach (explode(';', $serials) as $fan_card_serial)
{
if ($fan_card_serial != 'NULL') // the serial number is string 'NULL' when the fan card is absent
{
$inventory[$system_index] = array(
'entPhysicalDescr' => '',
'entPhysicalClass' => 'module',
'entPhysicalName' => "Fan Card $i",
'entPhysicalSerialNum' => $fan_card_serial,
'entPhysicalAssetID' => '',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1, // ENTITY-MIB exposes the chassis with index 1.
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Raisecom'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
$system_index++;
$i++;
}
unset($mib, $serials, $system_index, $i, $fan_card_serial);
// EOF

View File

@ -0,0 +1,40 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$oids = snmpwalk_cache_oid($device, 'raisecomPowerSerialNumber', NULL, $mib);
$oids = snmpwalk_cache_oid($device, 'raisecomPowerType', $oids, $mib);
$system_index = 201;
foreach ($oids as $id => $entry)
{
$psu_type = strtoupper($entry['raisecomPowerType']);
if ($psu_type == 'AC' || $psu_type == 'DC')
{
$inventory[$system_index] = array(
'entPhysicalDescr' => "{$psu_type} Power Supply Unit",
'entPhysicalClass' => 'module',
'entPhysicalName' => "PSU $id",
'entPhysicalSerialNum' => $entry['raisecomPowerSerialNumber'],
'entPhysicalAssetID' => '',
'entPhysicalIsFRU' => 'true',
'entPhysicalContainedIn' => 1, // ENTITY-MIB exposes the chassis with index 1.
'entPhysicalParentRelPos' => -1,
'entPhysicalMfgName' => 'Raisecom'
);
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
$system_index++;
}
unset($mib, $system_index, $id, $entry, $psu_type);
// EOF

View File

@ -0,0 +1,45 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
echo("SNR-SWITCH-MIB ");
$ports_array = snmpwalk_cache_oid($device, "priPortTable", [], 'SNR-SWITCH-MIB', NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($ports_array);
if (safe_count($ports_array)) {
//$portCount = snmp_get_oid($device, 'portCount.0', 'SNR-SWITCH-MIB');
$ddminfo_array = snmpwalk_cache_oid($device, "ddmTranscBasicInfoTable", [], 'SNR-SWITCH-MIB');
print_debug_vars($ddminfo_array);
foreach ($ports_array as $index => $entry) {
$local_index = 100 + $entry['portIndex'];
$inventory[$local_index] = [
'entPhysicalDescr' => $entry['portType']." ".$ddminfo_array[$entry['portIndex']]['ddmTransSerialWaveLength'],
'entPhysicalClass' => 'port',
'entPhysicalName' => $entry['portName'],
'entPhysicalIsFRU' => 'false',
'entPhysicalModelName' => $ddminfo_array[$entry['portIndex']]['ddmTransSerialModelName'],
'entPhysicalVendorType' => $ddminfo_array[$entry['portIndex']]['ddmTransSerialTypeName'],
'entPhysicalContainedIn' => 1,
'entPhysicalParentRelPos' => $entry['portIndex'],
'entPhysicalSerialNum' => $entry['transceiverSn'],
'ifIndex' => $entry['portIndex'],
'entPhysicalMfgName' => $ddminfo_array[$entry['portIndex']]['ddmTransSerialVendorName'],
];
discover_inventory($device, $local_index, $inventory[$local_index], 'SNR-SWITCH-MIB');
}
}
print_debug_vars($inventory);
// EOF

View File

@ -0,0 +1,37 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
$oids = snmp_cache_table($device, 'tmnxHwTable', NULL, 'TIMETRA-CHASSIS-MIB');
foreach ($oids as $index => $entry) {
list($chassis, $system_index) = explode('.', $index);
$inventory[$system_index] = array(
'entPhysicalDescr' => $entry['tmnxHwName'],
'entPhysicalClass' => $entry['tmnxHwClass'],
'entPhysicalName' => $entry['tmnxHwName'],
'entPhysicalAlias' => $entry['tmnxHwAlias'],
'entPhysicalAssetID' => $entry['tmnxHwAssetID'],
'entPhysicalIsFRU' => $entry['tmnxHwIsFRU'],
'entPhysicalSerialNum' => $entry['tmnxHwSerialNumber'],
'entPhysicalContainedIn' => $entry['tmnxHwContainedIn'],
'entPhysicalParentRelPos' => $entry['tmnxHwParentRelPos'],
'entPhysicalMfgName' => $entry['tmnxHwMfgString'] // 'Alcatel-Lucent'
);
if ($entry['tmnxHwContainedIn'] === '0' && $entry['tmnxHwParentRelPos'] === '-1') {
$inventory[$system_index]['entPhysicalName'] .= ' '.$chassis;
}
discover_inventory($device, $system_index, $inventory[$system_index], $mib);
}
// EOF

View File

@ -0,0 +1,303 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
/**
* @var array $config
* @var array $device
* @var string $module
* @global array $ip_data
*/
global $ip_data;
$ip_data = array('ipv4' => array(),
'ipv6' => array());
//$valid['ip-addresses'] = array();
$include_dir = 'includes/discovery/ip-addresses';
$include_order = 'default'; // Use MIBs from default os definitions by first!
include($config['install_dir'] . "/includes/include-dir-mib.inc.php");
foreach (get_device_mibs_permitted($device) as $mib)
{
// Detect addresses by definitions
if (is_array($config['mibs'][$mib]['ip-address']))
{
print_cli_data_field($mib);
foreach ($config['mibs'][$mib]['ip-address'] as $oid_data)
{
discover_ip_address_definition($device, $mib, $oid_data);
}
print_cli(PHP_EOL);
}
}
// Try discovery IP addresses in VRF SNMP contexts (currently actual only on Cisco Nexus)
if (safe_empty($device['snmp_context']) && // Device not already with context
isset($config['os'][$device['os']]['snmp']['virtual']) && $config['os'][$device['os']]['snmp']['virtual'] && // Context permitted for os
$vrf_contexts = safe_json_decode(get_entity_attrib('device', $device, 'vrf_contexts'))) { // SNMP VRF context discovered for device
// Keep original device array
$device_original = $device;
foreach ($vrf_contexts as $vrf_name => $snmp_virtual) {
print_message("Addresses in Virtual Routing: $vrf_name...");
$device = snmp_virtual_device($device_original, $snmp_virtual);
//$device['snmp_context'] = $snmp_context;
if (!$device['snmp_retries']) {
// force less retries on vrf requests.. if not set in db
$device['snmp_retries'] = 1;
}
$include_dir = 'includes/discovery/ip-addresses';
$include_order = 'default'; // Use MIBs from default os definitions by first!
include($config['install_dir']."/includes/include-dir-mib.inc.php");
}
// Clean
$device = $device_original;
unset($device_original);
}
// Process IP Addresses
$table_rows = array();
$check_networks = array();
foreach (array('ipv4', 'ipv6') as $ip_version)
{
print_debug_vars($ip_data[$ip_version]);
// Caching old IP addresses table
$query = 'SELECT * FROM `'.$ip_version.'_addresses`
WHERE `device_id` = ?';
foreach (dbFetchRows($query, array($device['device_id'])) as $entry)
{
if (!strlen($entry['ifIndex']))
{
// Compatibility
$ifIndex = dbFetchCell('SELECT `ifIndex` FROM `ports` WHERE `port_id` = ? AND `deleted` = ?', array($entry['port_id'], 0));
} else {
$ifIndex = $entry['ifIndex'];
}
$old_table[$ip_version][$ifIndex][$entry[$ip_version.'_address']] = $entry;
}
if (!safe_count($ip_data[$ip_version]) && !safe_count($old_table[$ip_version]))
{
// Skip if walk and DB empty
continue;
}
// Process founded IP addresses
foreach ($ip_data[$ip_version] as $ifIndex => $addresses)
{
$port = get_port_by_index_cache($device, $ifIndex);
if (is_array($port) && !$port['deleted'])
{
$port_id = $port['port_id'];
} else {
// Allow to store IP addresses without associated port, but ifIndex available
// ie, Nortel/Avaya devices have hidden vlan ifIndexes
$port_id = '0';
}
print_debug_vars($port);
print_debug_vars($addresses);
foreach ($addresses as $ip_address => $entry)
{
if ($ip_version === 'ipv4')
{
// IPv4
$ip_prefix = $entry['prefix'];
$ip_origin = $entry['origin'];
$ip_compressed = $ip_address; // just for compat with IPv6
$ip_type = $entry['type'];
$addr = Net_IPv4::parseAddress($ip_address.'/'.$ip_prefix);
$ip_cidr = $addr->bitmask;
$ip_network = $addr->network . '/' . $ip_cidr;
$full_address = $ip_address . '/' . $ip_cidr;
$new_address = [
'port_id' => $port_id,
'ifIndex' => $ifIndex,
'device_id' => $device['device_id'],
'ipv4_address' => $ip_address,
'ipv4_binary' => inet_pton($ip_address),
'ipv4_prefixlen' => $ip_cidr,
'ipv4_type' => $ip_type
];
} else {
// IPv6
$ip_prefix = $entry['prefix'];
$ip_origin = $entry['origin'];
$ip_compressed = Net_IPv6::compress($ip_address, TRUE);
$full_address = $ip_compressed.'/'.$ip_prefix;
$ip_type = $entry['type'];
$ip_network = Net_IPv6::getNetmask($full_address) . '/' . $ip_prefix;
//$full_compressed = $ip_compressed.'/'.$ipv6_prefixlen;
$new_address = [
'port_id' => $port_id,
'ifIndex' => $ifIndex,
'device_id' => $device['device_id'],
'ipv6_address' => $ip_address,
'ipv6_binary' => inet_pton($ip_address),
'ipv6_compressed' => $ip_compressed,
'ipv6_prefixlen' => $ip_prefix,
'ipv6_type' => $ip_type,
'ipv6_origin' => $ip_origin
];
}
// VRFs
$sql = "SELECT `vrf_id` FROM `vrfs` WHERE `device_id` = ? AND `vrf_name` = ?";
if (strlen($entry['vrf']) &&
$vrf_id = dbFetchCell($sql, [ $device['device_id'], $entry['vrf'] ]))
{
$new_address['vrf_id'] = $vrf_id;
}
// Check network
$ip_network_id = dbFetchCell('SELECT `'.$ip_version.'_network_id` FROM `'.$ip_version.'_networks` WHERE `'.$ip_version.'_network` = ?', array($ip_network));
if (empty($ip_network_id))
{
// Add new network
$ip_network_id = dbInsert(array($ip_version.'_network' => $ip_network), $ip_version.'_networks');
//echo('N');
}
$new_address[$ip_version.'_network_id'] = $ip_network_id;
// Add to display table
$table_rows[] = array($ifIndex, truncate($port['ifDescr'], 30), nicecase($ip_version), $full_address, $ip_network, $entry['type'], $ip_origin);
// Check IP in DB
$update_array = array();
if (isset($old_table[$ip_version][$ifIndex][$ip_address]))
{
$old_address = &$old_table[$ip_version][$ifIndex][$ip_address];
$ip_address_id = $old_address[$ip_version.'_address_id'];
$params = array_diff(array_keys($old_address), [ 'device_id', $ip_version.'_address_id' ]);
foreach ($params as $param)
{
if ($param === 'ipv6_binary')
{
// Compare decoded binary IPv6 address
if (inet_ntop($old_address[$param]) != $new_address['ipv6_compressed']) { $update_array[$param] = $new_address[$param]; }
}
elseif ($param === 'ipv4_binary')
{
// Compare decoded binary IPv4 address
if (inet_ntop($old_address[$param]) != $new_address['ipv4_address']) { $update_array[$param] = $new_address[$param]; }
} else {
// All other params as string
if ($old_address[$param] != $new_address[$param])
{
if (in_array($param, [ 'vrf_id', 'ifIndex', $ip_version.'_type' ]) && !strlen($new_address[$param]))
{
$update_array[$param] = [ 'NULL' ];
} else {
$update_array[$param] = $new_address[$param];
}
}
}
}
$update_count = count($update_array);
if ($update_count === 1 && (isset($update_array['ipv4_binary']) || isset($update_array['ipv6_binary'])))
{
// Silent update binary address after upgrade
dbUpdate($update_array, $ip_version.'_addresses', '`'.$ip_version.'_address_id` = ?', array($old_address[$ip_version.'_address_id']));
$GLOBALS['module_stats'][$module]['unchanged']++;
}
elseif ($update_count)
{
// Updated
dbUpdate($update_array, $ip_version.'_addresses', '`'.$ip_version.'_address_id` = ?', array($old_address[$ip_version.'_address_id']));
if (!$port_id)
{
log_event("IP address changed: $ip_compressed/".$old_address[$ip_version.'_prefixlen']." -> $full_address", $device, 'device', $device['device_id']);
}
else if (isset($update_array['port_id']))
{
// Address moved to another port
log_event("IP address removed: $ip_compressed/".$old_address[$ip_version.'_prefixlen'], $device, 'port', $old_address['port_id']);
log_event("IP address added: $full_address", $device, 'port', $port_id);
} else {
// Changed prefix/cidr
log_event("IP address changed: $ip_compressed/".$old_address[$ip_version.'_prefixlen']." -> $full_address", $device, 'port', $port_id);
}
$GLOBALS['module_stats'][$module]['updated']++; //echo "U";
$check_networks[$ip_version][$ip_network_id] = 1;
} else {
// Not changed
$GLOBALS['module_stats'][$module]['unchanged']++; //echo ".";
}
} else {
// New IP
$update_array = $new_address;
$ip_address_id = dbInsert($update_array, $ip_version.'_addresses');
if ($port_id)
{
log_event("IP address added: $full_address", $device, 'port', $port_id);
} else {
log_event("IP address added: $full_address", $device, 'device', $device['device_id']);
}
$GLOBALS['module_stats'][$module]['added']++; //echo "+";
}
$valid[$ip_version][$ip_address_id] = $full_address . ':' . $port_id;
}
}
// Refetch and clean IP addresses from DB
foreach (dbFetchRows($query, array($device['device_id'])) as $entry)
{
$ip_address_id = $entry[$ip_version.'_address_id'];
if (!isset($valid[$ip_version][$ip_address_id]))
{
$full_address = ($ip_version === 'ipv4' ? $entry['ipv4_address'] : $entry['ipv6_compressed']);
$full_address .= '/' . $entry[$ip_version.'_prefixlen'];
// Delete IP
dbDelete($ip_version.'_addresses', '`'.$ip_version.'_address_id` = ?', array($ip_address_id));
if ($port_id)
{
log_event("IP address removed: $full_address", $device, 'port', $entry['port_id']);
} else {
log_event("IP address removed: $full_address", $device, 'device', $entry['device_id']);
}
$GLOBALS['module_stats'][$module]['deleted']++; //echo "-";
$check_networks[$ip_version][$entry[$ip_version.'_network_id']] = 1;
}
}
// Clean networks
foreach ($check_networks[$ip_version] as $ip_network_id => $n)
{
//$count = dbFetchCell('SELECT COUNT(*) FROM `'.$ip_version.'_addresses` WHERE `'.$ip_version.'_network_id` = ?', array($ip_network_id));
//if (empty($count))
if (!dbExist($ip_version.'_addresses', '`'.$ip_version.'_network_id` = ?', array($ip_network_id)))
{
dbDelete($ip_version.'_networks', '`'.$ip_version.'_network_id` = ?', array($ip_network_id));
//echo('n');
}
}
}
$table_headers = array('%WifIndex%n', '%WifDescr%n', '%WIP: Version%n', '%WAddress%n', '%WNetwork%n', '%WType%n', '%WOrigin%n');
print_cli_table($table_rows, $table_headers);
// Clean
unset($ip_data, $check_networks, $check_ipv6_mib, $update_array, $old_table, $table_rows, $table_headers);
// EOF

View File

@ -0,0 +1,66 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$ip_version = 'ipv6';
if (!safe_count($ip_data[$ip_version])) {
// Get IP addresses from CISCO-IETF-IP-MIB
//cIpAddressIfIndex.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = 450
//cIpAddressPrefix.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = cIpAddressPfxOrigin.450.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:00".64
//cIpAddressOrigin.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = manual
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
$oid_data = array();
foreach (array('cIpAddressIfIndex', 'cIpAddressPrefix', 'cIpAddressType', 'cIpAddressOrigin') as $oid)
{
$oid_data = snmpwalk_cache_twopart_oid($device, $oid.'.'.$ip_version, $oid_data, 'CISCO-IETF-IP-MIB', NULL, $flags);
if ($oid == 'cIpAddressIfIndex' && snmp_status() === FALSE)
{
break; // Stop walk, not exist table
}
}
//print_vars($oid_data);
// IPv6z
if (isset($oid_data[$ip_version . 'z']))
{
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
}
// Rewrite CISCO-IETF-IP-MIB array
foreach ($oid_data[$ip_version] as $ip_snmp => $entry)
{
$ip_address = hex2ip($ip_snmp);
$ifIndex = $entry['cIpAddressIfIndex'];
$tmp_prefix = explode('.', $entry['cIpAddressPrefix']);
$entry['cIpAddressPrefix'] = end($tmp_prefix);
/*
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['cIpAddressPrefix'],
'type' => $entry['cIpAddressType'],
'origin' => $entry['cIpAddressOrigin']);
*/
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['cIpAddressPrefix'],
'type' => $entry['cIpAddressType'],
'origin' => $entry['cIpAddressOrigin']
];
discover_add_ip_address($device, $mib, $data);
}
}
unset($ifIndex, $ip_address, $tmp_prefix, $oid_data, $flags);
// EOF

View File

@ -0,0 +1,72 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// DNOS-SWITCHING-MIB::agentNetworkIPAddress.0 = IpAddress: 192.168.1.195
// DNOS-SWITCHING-MIB::agentNetworkSubnetMask.0 = IpAddress: 255.255.254.0
// DNOS-SWITCHING-MIB::agentNetworkDefaultGateway.0 = IpAddress: 192.168.1.100
// DNOS-SWITCHING-MIB::agentNetworkBurnedInMacAddress.0 = Hex-STRING: 68 4F 64 D6 DF BB
// DNOS-SWITCHING-MIB::agentNetworkLocalAdminMacAddress.0 = Hex-STRING: 00 00 00 00 00 00
// DNOS-SWITCHING-MIB::agentNetworkMacAddressType.0 = INTEGER: burned-in(1)
// DNOS-SWITCHING-MIB::agentNetworkConfigProtocol.0 = INTEGER: none(1)
// DNOS-SWITCHING-MIB::agentNetworkConfigProtocolDhcpRenew.0 = INTEGER: normalOperation(0)
// DNOS-SWITCHING-MIB::agentNetworkMgmtVlan.0 = INTEGER: 4
$oids = snmp_get_multi_oid($device, 'agentNetworkIPAddress.0 agentNetworkSubnetMask.0 agentNetworkBurnedInMacAddress.0 agentNetworkMgmtVlan.0', [], $mib);
print_debug_vars($oids);
$entry = $oids[0];
if ($port_id = get_port_id_by_ifDescr($device['device_id'], 'Vl'.$entry['agentNetworkMgmtVlan']))
{
// By Vlan
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
}
elseif ($port_id = get_port_id_by_mac($device['device_id'], $entry['agentNetworkBurnedInMacAddress']))
{
// By MAC address
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
} else {
$ifIndex = 0;
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['agentNetworkIPAddress'],
'mask' => $entry['agentNetworkSubnetMask']
];
discover_add_ip_address($device, $mib, $data);
// DNOS-SWITCHING-MIB::agentNetworkIpv6AdminMode.0 = INTEGER: enabled(1)
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddrPrefixLength."........jOd....." = INTEGER: 64
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddrEuiFlag."........jOd....." = INTEGER: enabled(1)
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddrStatus."........jOd....." = INTEGER: active(1)
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddressAutoConfig.0 = INTEGER: disable(2)
// DNOS-SWITCHING-MIB::agentNetworkIpv6ConfigProtocol.0 = INTEGER: none(1)
if (snmp_get_oid($device, 'agentNetworkIpv6AdminMode.0', $mib) === 'enabled')
{
// IPv6
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrPrefixLength', [], $mib, NULL, OBS_SNMP_ALL_TABLE);
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrStatus', $oids, $mib, NULL, OBS_SNMP_ALL_TABLE);
print_debug_vars($oids);
foreach ($oids as $ip_address => $entry)
{
if ($entry['agentNetworkIpv6AddrStatus'] !== 'active') { continue; }
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['agentNetworkIpv6AddrPrefixLength']
];
discover_add_ip_address($device, $mib, $data);
}
}
// EOF

View File

@ -0,0 +1,104 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// F5-BIGIP-SYSTEM-MIB
//if (!count($ip_data['ipv4']) && !count($ip_data['ipv6']))
//{
// Note, F5-BIGIP support IP-MIB, but on some firmware versions return not correct ifIndexes, this MIB uses correct indexes
$mib = 'F5-BIGIP-SYSTEM-MIB';
// Get IP addresses from F5-BIGIP-SYSTEM-MIB
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/157.122.148.244" = INTEGER: ipv4(1)
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/vlan2422HeFei-CU1G" = INTEGER: ipv4(1)
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/157.122.148.244" = Hex-STRING: 9D 7A 94 F4
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/vlan2422HeFei-CU1G" = Hex-STRING: 2A 9D 09 42
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan2422HeFei-CU1G" = Hex-STRING: FF FF FF F8
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan3682HeFei-CU2G" = Hex-STRING: FF FF FF F0
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/157.122.148.244" = STRING: /Common/vlan3617
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/vlan2422HeFei-CU1G" = STRING: /Common/vlan2422HeFei_CU1G
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/157.122.148.244" = INTEGER: 1
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/vlan2422HeFei-CU1G" = INTEGER: 0
//$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
$flags = OBS_SNMP_ALL;
$oid_data = array();
foreach (array('sysSelfIpAddrType', 'sysSelfIpVlanName', 'sysSelfIpUnitId', 'sysSelfIpAddr', 'sysSelfIpNetmask') as $oid)
{
$oid_data = snmpwalk_cache_oid($device, $oid, $oid_data, $mib, NULL, $flags);
if ($oid == 'sysSelfIpAddrType' && $GLOBALS['snmp_status'] === FALSE)
{
break; // Stop walk, not exist table
}
}
//print_vars($oid_data);
$query = 'SELECT `port_id`, `ifIndex`, `ifDescr` FROM `ports` WHERE `device_id` = ? AND `deleted` = ?';
foreach (dbFetchRows($query, array($device['device_id'], 0)) as $entry)
{
$ports_ifDescr[$entry['ifDescr']] = $entry;
}
// Rewrite F5-BIGIP-SYSTEM-MIB array
foreach ($oid_data as $ip_name => $entry)
{
if ($entry['sysSelfIpUnitId'] != '0') { continue; } // Skip all except self Unit addresses
$ifName = $entry['sysSelfIpVlanName'];
if (isset($ports_ifDescr[$ifName]))
{
$ifIndex = $ports_ifDescr[$ifName]['ifIndex'];
$ip_version = $entry['sysSelfIpAddrType'];
$ip_address = hex2ip($entry['sysSelfIpAddr']);
$ip_mask = hex2ip($entry['sysSelfIpNetmask']);
if ($ip_version == 'ipv4')
{
$ip_mask_fix = explode('.', $ip_mask);
if (empty($ip_mask) || count($ip_mask_fix) != 4)
{
$ip_mask = '255.255.255.255';
}
} else {
// IPv6 - not tested
$prefix = 0;
$m = str_split($ip_mask);
foreach ($m as $c) {
if ($c == ":") { continue; }
if ($c == "0") { break; }
$bin = base_convert($c, 16, 2);
$bin = trim($bin,"0");
$prefix += strlen($bin);
}
}
/*
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
'ip' => $ip_address,
'mask' => $ip_mask,
'prefix' => $prefix);
*/
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'mask' => $ip_mask,
'prefix' => $prefix
];
discover_add_ip_address($device, $mib, $data);
}
unset($ifName, $ifIndex, $ip_version, $ip_address, $ip_mask, $prefix);
}
//}
unset($ports_ifDescr, $ifIndex, $ip_address, $ip_mask_fix, $oid_data, $flags);
// EOF

View File

@ -0,0 +1,222 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// IPv4 addresses
$ip_version = 'ipv4';
// NOTE. By default used old tables IP-MIB, because some weird vendors use "random" data in new tables:
//ipAddressIfIndex.ipv4."94.142.242.194" = 2
//ipAddressIfIndex.ipv4."127.0.0.1" = 1
//ipAddressPrefix.ipv4."94.142.242.194" = ipAddressPrefixOrigin.2.ipv4."88.0.0.0".5
//ipAddressPrefix.ipv4."127.0.0.1" = ipAddressPrefixOrigin.1.ipv4."51.101.48.0".0
// Get IP addresses from IP-MIB (old table)
// Normal:
//IP-MIB::ipAdEntIfIndex.10.0.0.130 = 193
//IP-MIB::ipAdEntNetMask.10.0.0.130 = 255.255.255.252
// Cisco Nexus (seems as first number is interface index):
//IP-MIB::ipAdEntIfIndex.4.10.44.44.110 = 151192525
//IP-MIB::ipAdEntNetMask.4.10.44.44.110 = 255.255.255.0
// Bintec Elmeg (seems as last number is counter number 1,2,3,etc)
//IP-MIB::ipAdEntIfIndex.192.168.1.254.0 = 1000
//IP-MIB::ipAdEntNetMask.192.168.1.254.0 = 255.255.255.0
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntIfIndex', [], 'IP-MIB');
if (snmp_status()) {
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntNetMask', $oid_data, 'IP-MIB');
if (is_numeric(array_key_first($oid_data))) {
// Some devices report just numbers instead ip address:
// IP-MIB::ipAdEntAddr.0 = IpAddress: 0.0.0.0
// IP-MIB::ipAdEntAddr.2130706433 = IpAddress: 127.0.0.1
// IP-MIB::ipAdEntIfIndex.0 = INTEGER: 6620672
// IP-MIB::ipAdEntIfIndex.2130706433 = INTEGER: 6625280
// IP-MIB::ipAdEntNetMask.0 = IpAddress: 255.255.255.0
// IP-MIB::ipAdEntNetMask.2130706433 = IpAddress: 255.255.255.255
// IP-MIB::ipAdEntBcastAddr.0 = INTEGER: 1
// IP-MIB::ipAdEntBcastAddr.2130706433 = INTEGER: 0
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntAddr', $oid_data, 'IP-MIB');
}
}
// Rewrite IP-MIB array
foreach ($oid_data as $ip_address => $entry) {
$ifIndex = $entry['ipAdEntIfIndex'];
$ip_address_fix = explode('.', $ip_address);
switch (count($ip_address_fix)) {
case 4:
break; // Just normal IPv4 address
case 5:
if ($device['os_group'] === 'bintec') {
// Bintec Elmeg, see: http://jira.observium.org/browse/OBSERVIUM-1958
unset($ip_address_fix[4]);
} else {
// Cisco Nexus, see: http://jira.observium.org/browse/OBSERVIUM-728
unset($ip_address_fix[0]);
}
$ip_address = implode('.', $ip_address_fix);
break;
default:
if (isset($entry['ipAdEntAddr']) && get_ip_version($entry['ipAdEntAddr'])) {
$ip_address = $entry['ipAdEntAddr'];
} else {
print_debug("Detected unknown IPv4 address: $ip_address");
continue 2;
}
}
$ip_mask_fix = explode('.', $entry['ipAdEntNetMask']);
if ($ip_mask_fix[0] < 255 && $ip_mask_fix[1] <= '255' && $ip_mask_fix[2] <= '255' && $ip_mask_fix[3] == '255')
{
// On some D-Link used wrong masks: 252.255.255.255, 0.255.255.255
$entry['ipAdEntNetMask'] = $ip_mask_fix[3] . '.' . $ip_mask_fix[2] . '.' . $ip_mask_fix[1] . '.' . $ip_mask_fix[0];
}
if (empty($entry['ipAdEntNetMask']) || safe_count($ip_mask_fix) != 4)
{
$entry['ipAdEntNetMask'] = '255.255.255.255';
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'mask' => $entry['ipAdEntNetMask']
];
discover_add_ip_address($device, $mib, $data);
}
// Get IP addresses from IP-MIB (new table, both IPv4/IPv6)
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
$oid_data = array();
foreach (array('ipAddressIfIndex', 'ipAddressType', 'ipAddressPrefix', 'ipAddressOrigin') as $oid)
{
$oid_data = snmpwalk_cache_twopart_oid($device, $oid, $oid_data, 'IP-MIB', NULL, $flags);
if ($oid === 'ipAddressIfIndex' && !snmp_status()) {
break; // Stop walk, not exist table
}
}
//print_vars($oid_data);
// IPv4 addresses
if (!safe_count($ip_data[$ip_version])) {
//IP-MIB::ipAddressIfIndex.ipv4."198.237.180.2" = 8
//IP-MIB::ipAddressPrefix.ipv4."198.237.180.2" = ipAddressPrefixOrigin.8.ipv4."198.237.180.2".32
//IP-MIB::ipAddressOrigin.ipv4."198.237.180.2" = manual
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
// IPv4z (not sure, never seen)
if (isset($oid_data[$ip_version . 'z'])) {
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
}
// Rewrite IP-MIB array
foreach ($oid_data[$ip_version] as $ip_address => $entry) {
if (in_array($entry['ipAddressType'], $GLOBALS['config']['ip-address']['ignore_type'])) { continue; } // Skip broadcasts
//$ip_address = str_replace($ip_version.'.', '', $key);
$ifIndex = $entry['ipAddressIfIndex'];
// ipAddressOrigin.ipv4.169.254.1.1.23 = manual
$ip_address_fix = explode('.', $ip_address);
$index_prefix = NULL;
switch (safe_count($ip_address_fix)) {
case 5:
// get last number as prefix
$index_prefix = array_pop($ip_address_fix);
$ip_address = implode('.', $ip_address_fix);
break;
case 4:
// Common, no need for changes
break;
default:
print_debug("Unknown IP index: $ip_address");
continue 2;
}
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
$entry['ipAddressPrefix'] = end($tmp_prefix);
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
$entry['ipAddressPrefix'] = $index_prefix;
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['ipAddressPrefix'],
'type' => $entry['ipAddressType'],
'origin' => $entry['ipAddressOrigin']
];
discover_add_ip_address($device, $mib, $data);
}
}
// IPv6 addresses
$ip_version = 'ipv6';
//ipAddressIfIndex.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01" = 1
//ipAddressPrefix.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01" = ipAddressPrefixOrigin.1.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01".128
//ipAddressOrigin.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01" = manual
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
// IPv6z
if (isset($oid_data[$ip_version . 'z'])) {
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
}
// Rewrite IP-MIB array
$check_ipv6_mib = FALSE; // Flag for additionally check IPv6-MIB
foreach ($oid_data[$ip_version] as $ip_snmp => $entry) {
if (str_contains($ip_snmp, '.')) {
// incorrect indexes with prefix
// ipAddressOrigin.ipv6.65152.0.0.0.521.4095.65033.51218.27 = manual
$ip_address_fix = explode('.', $ip_snmp);
$index_prefix = NULL;
switch (count($ip_address_fix)) {
case 9:
// get last number as prefix
$index_prefix = array_pop($ip_address_fix);
//break;
case 8:
$ip_address_fix = array_map('dechex', $ip_address_fix);
$ip_address = ip_uncompress(implode(':', $ip_address_fix));
break;
default:
print_debug("Unknown IP index: $ip_snmp");
continue 2;
}
} else {
// Common address index
$ip_address = hex2ip($ip_snmp);
}
$ifIndex = $entry['ipAddressIfIndex'];
if ($entry['ipAddressPrefix'] === 'zeroDotZero') {
// Additionally walk IPV6-MIB, especially in JunOS because they spit at world standards
// See: http://jira.observium.org/browse/OBSERVIUM-1271
$check_ipv6_mib = TRUE;
} else {
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
$entry['ipAddressPrefix'] = end($tmp_prefix);
}
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
$entry['ipAddressPrefix'] = $index_prefix;
$check_ipv6_mib = FALSE;
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['ipAddressPrefix'],
'type' => $entry['ipAddressType'],
'origin' => $entry['ipAddressOrigin']
];
discover_add_ip_address($device, $mib, $data);
}
unset($ifIndex, $ip_address, $tmp_prefix, $oid_data);
// EOF

View File

@ -0,0 +1,55 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$ip_version = 'ipv6';
if ($check_ipv6_mib || !safe_count($ip_data[$ip_version])) { // Note, $check_ipv6_mib set in IP-MIB discovery
// Get IP addresses from IPV6-MIB
//ipv6AddrPfxLength.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = 64
//ipv6AddrPfxLength.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = 126
//ipv6AddrType.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = stateful
//ipv6AddrType.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = stateful
//ipv6AddrAnycastFlag.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = false
//ipv6AddrAnycastFlag.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = false
//ipv6AddrStatus.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = preferred
//ipv6AddrStatus.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = preferred
//Types: stateless(1), stateful(2), unknown(3)
$oid_data = snmpwalk_cache_twopart_oid($device, 'ipv6AddrEntry', array(), 'IPV6-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
//print_vars($oid_data);
// Rewrite IPV6-MIB array
foreach ($oid_data as $ifIndex => $entry1)
{
foreach ($entry1 as $ip_snmp => $entry)
{
$ip_address = snmp2ipv6($ip_snmp);
/*
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['ipv6AddrPfxLength'],
'origin' => $entry['ipv6AddrType']);
*/
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address,
'prefix' => $entry['ipv6AddrPfxLength'],
'origin' => $entry['ipv6AddrType']
];
discover_add_ip_address($device, $mib, $data);
}
}
}
unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data);
// EOF

View File

@ -0,0 +1,60 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
if (!safe_count($ip_data['ipv4']) && !safe_count($ip_data['ipv6'])) {
// arubaos-cx not have any other place for fetch IP addresses
$oid_data = snmpwalk_cache_twopart_oid($device, 'lldpLocManAddrTable', [], 'LLDP-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
print_debug_vars($oid_data);
// lldpLocManAddrLen.1.4.10.30.3.12 = 4
// lldpLocManAddrIfSubtype.1.4.10.30.3.12 = ifIndex
// lldpLocManAddrIfId.1.4.10.30.3.12 = 326
// lldpLocManAddrOID.1.4.10.30.3.12 = ifName.326
foreach ($oid_data as $ipv => $entry1) {
if ((int)$ipv === 1) {
$ip_version = 'ipv4';
} elseif ((int)$ipv === 2) {
$ip_version = 'ipv6';
} else {
// other types unknown
continue;
}
foreach ($entry1 as $ip_snmp => $entry) {
list($len, $ip_snmp) = explode('.', $ip_snmp, 2);
$ip_address = $ip_version === 'ipv6' ? snmp2ipv6($ip_snmp) : $ip_snmp;
if ($entry['lldpLocManAddrIfSubtype'] === 'ifIndex') {
$ifIndex = $entry['lldpLocManAddrIfId'];
} elseif ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['lldpLocManAddrIfId'])) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
} else {
continue;
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $ip_address
];
discover_add_ip_address($device, $mib, $data);
}
}
unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data);
}
// EOF

View File

@ -0,0 +1,54 @@
<?php
/*
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// NETAPP-MIB::nodeUuid.'WSLNetapp02-01' = STRING: d924dfcf-418e-11eb-91eb-d039ea255860
// NETAPP-MIB::nodeUuid.'WSLNetapp02-02' = STRING: 83eef39c-418e-11eb-b2bc-d039ea2575e5
$nodes = [];
foreach (snmpwalk_cache_oid($device, 'nodeUuid', [], $mib) as $node => $entry) {
$nodes[$entry['nodeUuid']] = $node;
}
print_vars($nodes);
//$flags = OBS_SNMP_ALL;
$oid_data = [];
foreach ([ 'logicalInterfaceNumericId', 'logicalInterfaceCurrNode', 'logicalInterfaceCurrPort',
'logicalInterfaceAddress', 'logicalInterfaceNetmaskLength', 'logicalInterfaceRole' ] as $oid) {
$oid_data = snmpwalk_cache_oid($device, $oid, $oid_data, $mib);
if ($oid === 'logicalInterfaceNumericId' && !snmp_status()) {
break; // Stop walk, not exist table
}
}
foreach ($oid_data as $index => $entry) {
if (isset($nodes[$entry['logicalInterfaceCurrNode']])) {
$ifDescr = $nodes[$entry['logicalInterfaceCurrNode']] . ':' . $entry['logicalInterfaceCurrPort'];
if ($port_id = get_port_id_by_ifDescr($device, $ifDescr)) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
} else {
print_debug("Port $ifDescr not found.");
$ifIndex = $entry['logicalInterfaceNumericId'];
//continue;
}
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['logicalInterfaceAddress'],
//'mask' => $entry['logicalInterfaceNetmask'],
'prefix' => $entry['logicalInterfaceNetmaskLength'],
'origin' => $entry['logicalInterfaceRole'],
];
discover_add_ip_address($device, $mib, $data);
}
// EOF

View File

@ -0,0 +1,65 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// IF-MIB::ifDescr.1 = STRING: LAN
// IF-MIB::ifDescr.2 = STRING: WAN 1-SACOFA
// IF-MIB::ifDescr.3 = STRING: WAN 2-TM
// IF-MIB::ifDescr.4 = STRING: WAN 3
// PEPLINK-WAN::wanName.0 = STRING: "WAN 1-SACOFA"
// PEPLINK-WAN::wanName.1 = STRING: "WAN 2-TM"
// PEPLINK-WAN::wanName.2 = STRING: "WAN 3"
// PEPLINK-WAN::wanName.3 = STRING: "Mobile Internet"
// PEPLINK-WAN::wanNetworkIpType.0.0 = INTEGER: static(1)
// PEPLINK-WAN::wanNetworkIpType.1.0 = INTEGER: static(1)
// PEPLINK-WAN::wanNetworkIpType.2.0 = INTEGER: dhcp(0)
// PEPLINK-WAN::wanNetworkIpType.3.0 = INTEGER: pppoe(2)
// PEPLINK-WAN::wanNetworkIpAddress.0.0 = IpAddress: 103.60.24.211
// PEPLINK-WAN::wanNetworkIpAddress.1.0 = IpAddress: 219.93.31.99
// PEPLINK-WAN::wanNetworkIpAddress.2.0 = IpAddress: 0.0.0.0
// PEPLINK-WAN::wanNetworkIpAddress.3.0 = IpAddress: 0.0.0.0
// PEPLINK-WAN::wanNetworkSubnetMask.0.0 = IpAddress: 255.255.255.240
// PEPLINK-WAN::wanNetworkSubnetMask.1.0 = IpAddress: 255.255.255.224
// PEPLINK-WAN::wanNetworkSubnetMask.2.0 = IpAddress: 0.0.0.0
// PEPLINK-WAN::wanNetworkSubnetMask.3.0 = IpAddress: 0.0.0.0
$ip_version = 'ipv4';
if (!safe_count($ip_data[$ip_version])) {
$oids = snmpwalk_cache_twopart_oid($device, 'wanNetworkIpTable', [], 'PEPLINK-WAN');
if (snmp_status()) {
$oids_int = snmpwalk_cache_oid($device, 'wanName', [], 'PEPLINK-WAN');
foreach ($oids as $wanid => $wan) {
$ifIndex = 0;
if (isset($oids_int[$wanid]) &&
$port_id = get_port_id_by_ifDescr($device['device_id'], $oids_int[$wanid]['wanName'])) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
}
foreach ($wan as $entry) {
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['wanNetworkIpAddress'],
'mask' => $entry['wanNetworkSubnetMask'],
//'type' => $entry[''],
'origin' => $entry['wanNetworkIpType']
];
discover_add_ip_address($device, $mib, $data);
}
}
}
}
// EOF

View File

@ -0,0 +1,74 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// IF-MIB::ifDescr.15 = STRING: LA/1
// IF-MIB::ifDescr.16 = STRING: LA/2
// SDX-ROOT-MIB::systemSvmIPAddressType.0 = INTEGER: ipv4(1)
// SDX-ROOT-MIB::systemSvmIPAddress.0 = STRING: "10.48.4.184"
// SDX-ROOT-MIB::systemXenIPAddressType.0 = INTEGER: ipv4(1)
// SDX-ROOT-MIB::systemXenIPAddress.0 = STRING: "10.48.4.186"
// SDX-ROOT-MIB::systemNetmaskType.0 = INTEGER: ipv4(1)
// SDX-ROOT-MIB::systemNetmask.0 = STRING: "255.255.255.0"
// SDX-ROOT-MIB::systemGatewayType.0 = INTEGER: ipv4(1)
// SDX-ROOT-MIB::systemGateway.0 = STRING: "10.48.4.1"
// SDX-ROOT-MIB::systemNetworkInterface.0 = STRING: "LA Management"
if ($data = snmp_get_multi_oid($device, 'systemSvmIPAddress.0 systemXenIPAddress.0 systemNetmask.0 systemNetworkInterface.0', [], 'SDX-ROOT-MIB')) {
$entry = $data[0];
$ifIndex = 0;
if ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['systemNetworkInterface'])) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
} else {
list($if) = explode(' ', $entry['systemNetworkInterface']);
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/1")) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['systemXenIPAddress'],
'mask' => $entry['systemNetmask'],
];
discover_add_ip_address($device, $mib, $data);
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/2")) {
$port = get_port_by_id_cache($port_id);
$ifIndex = $port['ifIndex'];
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['systemSvmIPAddress'],
'mask' => $entry['systemNetmask'],
];
discover_add_ip_address($device, $mib, $data);
return;
}
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['systemXenIPAddress'],
'mask' => $entry['systemNetmask'],
];
discover_add_ip_address($device, $mib, $data);
$data = [
'ifIndex' => $ifIndex,
'ip' => $entry['systemSvmIPAddress'],
'mask' => $entry['systemNetmask'],
];
discover_add_ip_address($device, $mib, $data);
}
// EOF

View File

@ -0,0 +1,64 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
# We're discovering this MIB
# snmpwalk -v2c -c <community> <hostname> -M mibs/junose/ -m Juniper-UNI-ATM-MIB juniAtmVpStatsEntry
// JunOSe ATM vps
if ($device['os'] == "junose" && ($attribs['enable_ports_junoseatmvp'] || ($config['enable_ports_junoseatmvp'] && !isset($attribs['enable_ports_junoseatmvp']))))
{
echo("JunOSe ATM vps : ");
$vp_array = snmpwalk_cache_oid($device, "juniAtmVpStatsInCells", $vp_array, "Juniper-UNI-ATM-MIB");
$valid_vp = array();
if (OBS_DEBUG && count($vp_array)) { print_vars($vp_array); }
if (is_array($vp_array))
{
foreach ($vp_array as $index => $entry)
{
list($ifIndex,$vp_id)= explode('.', $index);
$port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
if (is_numeric($port_id) && is_numeric($vp_id))
{
discover_juniAtmvp($valid_vp, $port_id, $vp_id, NULL);
}
} // End Foreach
} // End if array
unset ($vp_array);
// Remove ATM vps which weren't redetected here
// Fix Me - preferred method is to track existance by removing from an array.
if (OBS_DEBUG && count($valid_vp)) { print_vars ($valid_vp); }
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = ? AND J.port_id = P.port_id", array($device['device_id'])) as $test)
{
$port_id = $test['port_id'];
$vp_id = $test['vp_id'];
if (OBS_DEBUG > 1) { echo($port_id . " -> " . $vp_id . "\n"); }
if (!$valid_vp[$port_id][$vp_id])
{
echo("-");
dbDelete('juniAtmvp', '`juniAtmVp` = ?', array($test['juniAtmvp']));
}
unset($port_id); unset($vp_id);
}
unset($valid_vp);
echo(PHP_EOL);
}
// EOF

View File

@ -0,0 +1,46 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Include all discovery modules
$include_dir = "includes/discovery/lsp";
include("includes/include-dir-mib.inc.php");
if (OBS_DEBUG && count($valid['lsp']))
{
print_vars($valid['lsp']);
}
// Remove lsps which weren't redetected here
$query = 'SELECT * FROM `lsp` WHERE `device_id` = ?';
foreach (dbFetchRows($query, array($device['device_id'])) as $test_lsp)
{
$lsp_index = $test_lsp['lsp_index'];
$lsp_mib = $test_lsp['lsp_mib'];
$lsp_name = $test_lsp['lsp_name'];
print_debug($lsp_index . " -> " . $lsp_mib);
if (!$valid['lsp'][$lsp_mib][$lsp_index])
{
$GLOBALS['module_stats']['lsp']['deleted']++;
dbDelete('lsp', 'lsp_id = ?', array($test_lsp['lsp_id']));
log_event("LSP removed: index $lsp_index, mib $lsp_mib, name $lsp_name", $device, 'lsp', $test_lsp['lsp_id']);
}
}
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid[$module]);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status'])
{
print_vars($valid[$module]);
}
// EOF

View File

@ -0,0 +1,46 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mib = 'MPLS-MIB';
$lsps = snmpwalk_cache_oid($device, "mplsLspInfoEntry", NULL, $mib, mib_dirs('juniper'));
if (OBS_DEBUG && count($lsps))
{
print_vars($lsps);
}
if (count($lsps))
{
foreach ($lsps as $index => $lsp)
{
$proto = "RSVP-TE";
$name = trim($lsp['mplsLspInfoName'], "."); // name has trailing \0's that are converted to dots by snmp
$state = $lsp['mplsLspInfoState'];
$uptime = timeticks_to_sec($lsp['mplsLspInfoTimeUp']);
$total_uptime = timeticks_to_sec($lsp['mplsLspInfoAge']);
$primary_uptime = timeticks_to_sec($lsp['mplsLspInfoPrimaryTimeUp']);
$bandwidth = $lsp['mplsPathInfoBandwidth'] * 1000; // Convert kbps to bps for standardization
$transitions = $lsp['mplsLspInfoTransitions'];
$path_changes = $lsp['mplsLspInfoPathChanges'];
// using the 'Aggr' instances to avoid gaps on frenquently resignalled LSPs
$octets = $lsp['mplsLspInfoAggrOctets'];
$packets = $lsp['mplsLspInfoAggrPackets'];
discover_lsp($valid['lsp'], $device, $index, $mib, $name, $state, $uptime, $total_uptime,
$primary_uptime, $proto, $transitions, $path_changes, $bandwidth, $octets, $packets, time());
}
}
unset($lsps);
// EOF

View File

@ -0,0 +1,61 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mac_list = array();
// Disabled because we can do this better in poller now without performance hit
// CLEANME FIXME do we do it in poller? Can this code go?
if ($device['os_group'] == "cisco")
{
echo("Cisco MAC Accounting : ");
$datas = snmp_walk($device, "cipMacSwitchedBytes", "-OUqsX", "CISCO-IP-STAT-MIB");
foreach (explode("\n", $datas) as $data)
{
list(,$ifIndex,$dir,$mac,) = parse_oid2($data);
list($a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(":", $mac);
$ah_a = zeropad($a_a);
$ah_b = zeropad($a_b);
$ah_c = zeropad($a_c);
$ah_d = zeropad($a_d);
$ah_e = zeropad($a_e);
$ah_f = zeropad($a_f);
$clean_mac = "$ah_a$ah_b$ah_c$ah_d$ah_e$ah_f";
$mac_list[$ifIndex.'_'.$clean_mac] = array('ifIndex' => $ifIndex, 'mac' => $clean_mac);
}
foreach ($mac_list as $mac_entry)
{
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? LIMIT 1", array($device['device_id'], $mac_entry['ifIndex']));
if ($port)
{
echo($port['ifDescr'] . ' ('.$mac_entry['ifIndex'].') -> '.$mac_entry['mac']);
if (dbFetchCell("SELECT COUNT(*) from `mac_accounting` WHERE `port_id` = ? AND `mac` = ?", array($port['port_id'], $mac_entry['mac'])))
{
echo(".");
} else {
$ma_id = dbInsert(array('port_id' => $port['port_id'], 'device_id' => $device['device_id'], 'mac' => $mac_entry['mac'] ), 'mac_accounting');
echo("+");
}
} else {
echo("Couldn't work out interface!");
}
echo("\n");
}
echo("\n");
} # os_group=cisco
// FIXME - NEEDS TO REMOVE STALE ENTRIES?? :O
// EOF

View File

@ -0,0 +1,230 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Include all discovery modules
$include_dir = "includes/discovery/mempools";
include("includes/include-dir-mib.inc.php");
// Detect mempools by simple MIB-based discovery :
// FIXME - this should also be extended to understand multiple entries in a table, and take descr from an OID but this is all I need right now :)
// FIXME. In one day I'll rewrite this ;)
foreach (get_device_mibs_permitted($device) as $mib) {
if (is_array($config['mibs'][$mib]['mempool'])) {
print_cli_data_field($mib);
foreach ($config['mibs'][$mib]['mempool'] as $entry_name => $entry)
{
if (discovery_check_if_type_exist($entry, 'mempool')) { continue; }
// Check array requirements list
if (discovery_check_requires_pre($device, $entry, 'mempool')) { continue; }
$entry['found'] = FALSE;
// Init Precision (scale)
if (isset($entry['scale']) && is_numeric($entry['scale']) && $entry['scale']) {
$scale = $entry['scale'];
} else {
$scale = 1;
}
// Convert strings '3.40 TB' to value
// See QNAP NAS-MIB or HIK-DEVICE-MIB
$unit = isset($entry['unit']) ? $entry['unit'] : NULL;
if ($entry['type'] === 'table' || !isset($entry['type'])) {
/////////////////////
// Table Discovery //
/////////////////////
// If the type is table, walk the table!
if (!isset($entry['table'])) {
$entry['table'] = $entry_name;
}
// FIXME - cache this outside the mempools array and then just array_merge it in. Descr OIDs are probably shared a lot
// Fetch table or Oids
$table_oids = array('oid_used', 'oid_total', 'oid_free', 'oid_perc', 'oid_descr', 'extra_oids');
$mempools_array = discover_fetch_oids($device, $mib, $entry, $table_oids);
// FIXME - generify description generation code and just pass it template and OID array.
$i = 1; // Used in descr as %i%
$mempools_count = safe_count($mempools_array);
foreach ($mempools_array as $index => $mempool_entry) {
$oid_num = $entry['oid_num'] . '.' . $index;
// Generate mempool description
$mempool_entry['i'] = $i;
$mempool_entry['index'] = $index;
foreach (explode('.', $index) as $k => $i) {
$mempool_entry['index'.$k] = $i; // Index parts
}
$descr = entity_descr_definition('mempool', $entry, $mempool_entry, $mempools_count);
// Check array requirements list
if (discovery_check_requires($device, $entry, $mempool_entry, 'mempool')) { continue; }
// Init perc/total/used/free
$used = NULL;
$total = NULL;
$free = NULL;
$perc = NULL;
$options = [];
// Hardcoded total
if (!safe_empty($entry['total'])) { $total = $entry['total']; }
// Fetch used, total, free and percentage values, if OIDs are defined for them
foreach(array('oid_used', 'oid_total', 'oid_free') as $oid) {
if (!isset($entry[$oid])) { continue; }
$param = str_replace('oid_', '', $oid);
if (str_contains($entry[$oid], '.')) {
$mempool_entry[$entry[$oid]] = snmp_cache_oid($device, $entry[$oid], $mib);
}
$$param = snmp_fix_numeric($mempool_entry[$entry[$oid]], $unit);
}
//if ($entry['oid_used'] != '') { $used = snmp_fix_numeric($mempool_entry[$entry['oid_used']], $unit); }
//if ($entry['oid_free'] != '') { $free = snmp_fix_numeric($mempool_entry[$entry['oid_free']], $unit); }
if (!safe_empty($entry['oid_perc'])) { $perc = snmp_fix_numeric($mempool_entry[$entry['oid_perc']]); }
// Prefer hardcoded total over SNMP OIDs
//if ($entry['total'] != '') { $total = $entry['total']; }
//elseif ($entry['oid_total'] != '') { $total = snmp_fix_numeric($mempool_entry[$entry['oid_total']], $unit); }
// Extrapolate all values from the ones we have.
$mempool = calculate_mempool_properties($scale, $used, $total, $free, $perc, $options);
print_debug_vars(array($scale, $used, $total, $free, $perc, $options));
print_debug_vars($mempool_entry);
print_debug_vars($mempool);
print_debug_vars(array(is_numeric($mempool['used']),is_numeric($mempool['total'])));
// If we have valid used and total, discover the mempool
if (is_numeric($mempool['used']) && is_numeric($mempool['total'])) {
//print_r(array($valid['mempool'], $device, $index, $mib, $descr, $scale, $mempool['total'], $mempool['used'], $index, array('table' => $entry_name)));
$mempool_hc = 0; // // FIXME mempool_hc = ?? currently keep as 0
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, $scale, $mempool['total'], $mempool['used'], $mempool_hc, array('table' => $entry_name));
$entry['found'] = TRUE;
}
$i++;
}
} else {
////////////////////
// Static mempool //
////////////////////
// Init perc/total/used/free
$used = NULL;
$total = NULL;
$free = NULL;
$perc = NULL;
$index = 0; // FIXME. Need use same indexes style as in sensors
$mempool_entry = array('index' => $index);
if (isset($entry['oid_descr']) && $entry['oid_descr']) {
// Get description from specified OID
$mempool_entry[$entry['oid_descr']] = snmp_get_oid($device, $entry['oid_descr'], $mib);
}
$descr = entity_descr_definition('mempool', $entry, $mempool_entry);
// Hardcoded total
if (!safe_empty($entry['total'])) { $total = $entry['total']; }
// Fetch used, total, free and percentage values, if OIDs are defined for them
foreach(array('oid_used', 'oid_total', 'oid_free') as $oid) {
if (!isset($entry[$oid])) { continue; }
$param = str_replace('oid_', '', $oid);
$$param = snmp_fix_numeric(snmp_get_oid($device, $entry[$oid], $mib), $unit);
}
// Fetch used, total, free and percentage values, if OIDs are defined for them
// if ($entry['oid_used'] != '') {
// $used = snmp_fix_numeric(snmp_get_oid($device, $entry['oid_used'], $mib), $unit);
// }
// Prefer hardcoded total over SNMP OIDs
// if ($entry['total'] != '') {
// $total = $entry['total'];
// } else {
// // No hardcoded total, fetch OID if defined
// if ($entry['oid_total'] != '') {
// $total = snmp_fix_numeric(snmp_get_oid($device, $entry['oid_total'], $mib), $unit);
// }
// }
// if ($entry['oid_free'] != '') {
// $free = snmp_fix_numeric(snmp_get_oid($device, $entry['oid_free'], $mib), $unit);
// }
if (!safe_empty($entry['oid_perc'])) {
$perc = snmp_fix_numeric(snmp_get_oid($device, $entry['oid_perc'], $mib));
}
$mempool = calculate_mempool_properties($scale, $used, $total, $free, $perc, $entry);
// If we have valid used and total, discover the mempool
if (is_numeric($mempool['used']) && is_numeric($mempool['total'])) {
// Rename RRD if requested
if (isset($entry['rename_rrd'])) {
$old_rrd = 'mempool-' . $entry['rename_rrd'];
$new_rrd = 'mempool-' . strtolower($mib) . '-' . $index;
rename_rrd($device, $old_rrd, $new_rrd);
unset($old_rrd, $new_rrd);
}
$mempool_hc = 0; // // FIXME mempool_hc = ?? currently keep as 0
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, $scale, $mempool['total'], $mempool['used'], $mempool_hc, array('table' => $entry_name));
$entry['found'] = TRUE;
}
}
unset($mempools_array, $mempool, $dot_index, $descr, $i); // Clean up
if (isset($entry['stop_if_found']) && $entry['stop_if_found'] && $entry['found']) {
break;
} // Stop loop if mempool found
}
print_cli(PHP_EOL);
}
}
// Remove memory pools which weren't redetected here
foreach (dbFetchRows('SELECT * FROM `mempools` WHERE `device_id` = ?', array($device['device_id'])) as $test_mempool)
{
$mempool_index = $test_mempool['mempool_index'];
$mempool_mib = $test_mempool['mempool_mib'];
$mempool_descr = $test_mempool['mempool_descr'];
print_debug($mempool_index . " -> " . $mempool_mib);
if (!$valid['mempool'][$mempool_mib][$mempool_index])
{
$GLOBALS['module_stats'][$module]['deleted']++; //echo('-');
dbDelete('mempools', '`mempool_id` = ?', array($test_mempool['mempool_id']));
log_event("Memory pool removed: mib $mempool_mib, index $mempool_index, descr $mempool_descr", $device, 'mempool', $test_mempool['mempool_id']);
}
}
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid['mempool']);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status'])
{
print_vars($valid['mempool']);
}
// EOF

View File

@ -0,0 +1,41 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// DGS-3450
// AGENT-GENERAL-MIB::agentDRAMutilizationUnitID.0 = INTEGER: 0
// AGENT-GENERAL-MIB::agentDRAMutilizationTotalDRAM.0 = INTEGER: 262144 KB
// AGENT-GENERAL-MIB::agentDRAMutilizationUsedDRAM.0 = INTEGER: 174899 KB
// AGENT-GENERAL-MIB::agentDRAMutilization.0 = INTEGER: 66
// DES-3550, DES-3526, DES-3028 (and other Stacking switches)
// AGENT-GENERAL-MIB::agentDRAMutilizationUnitID.1 = INTEGER: 1
// AGENT-GENERAL-MIB::agentDRAMutilizationTotalDRAM.1 = INTEGER: 22495072 KB
// AGENT-GENERAL-MIB::agentDRAMutilizationUsedDRAM.1 = INTEGER: 12431462 KB
// AGENT-GENERAL-MIB::agentDRAMutilization.1 = INTEGER: 55
$mempool_array = snmpwalk_cache_oid($device, 'agentDRAMutilizationEntry', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['agentDRAMutilizationUsedDRAM'])) {
$descr = ($index === 0 ? 'Memory' : 'Unit ' . $index);
$used = $entry['agentDRAMutilizationUsedDRAM'];
$total = $entry['agentDRAMutilizationTotalDRAM'];
$precision = (strlen($total) > 7 ? 1 : 1024); // Stacking switches uses wrong units
//$used *= $precision;
//$total *= $precision;
discover_mempool($valid['mempool'], $device, $index, 'AGENT-GENERAL-MIB', $descr, $precision, $total, $used);
}
}
unset($mempool_array, $index, $descr, $precision, $total, $used);
// EOF

View File

@ -0,0 +1,56 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
/*
BIANCA-BRICK-MIBRES-MIB::memoryType.flash.0 = INTEGER: flash(1)
BIANCA-BRICK-MIBRES-MIB::memoryType.dram.1 = INTEGER: dram(2)
BIANCA-BRICK-MIBRES-MIB::memoryType.dpool.2 = INTEGER: dpool(3)
BIANCA-BRICK-MIBRES-MIB::memoryDescr.flash.0 = Hex-STRING: 4F 6E 62 6F 61 72 64 20 46 6C 61 73 68 00
BIANCA-BRICK-MIBRES-MIB::memoryDescr.dram.1 = Hex-STRING: 4D 61 69 6E 20 4D 65 6D 6F 72 79 00
BIANCA-BRICK-MIBRES-MIB::memoryDescr.dpool.2 = STRING: "STREAMS Class 0"
BIANCA-BRICK-MIBRES-MIB::memoryBlockSize.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryBlockSize.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryBlockSize.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryTotal.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 4194304
BIANCA-BRICK-MIBRES-MIB::memoryTotal.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 16711680
BIANCA-BRICK-MIBRES-MIB::memoryTotal.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 96
BIANCA-BRICK-MIBRES-MIB::memoryInuse.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryInuse.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 13639380
BIANCA-BRICK-MIBRES-MIB::memoryInuse.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryDramUse.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryDramUse.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryDramUse.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 6528
BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 3006
BIANCA-BRICK-MIBRES-MIB::memoryNAllocs.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 53354
BIANCA-BRICK-MIBRES-MIB::memoryNFrees.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryNFrees.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 89
BIANCA-BRICK-MIBRES-MIB::memoryNFrees.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 53434
BIANCA-BRICK-MIBRES-MIB::memoryNFails.flash.0 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryNFails.dram.1 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
BIANCA-BRICK-MIBRES-MIB::memoryNFails.dpool.2 = Wrong Type (should be Gauge32 or Unsigned32): INTEGER: 0
*/
$mempool_array = snmpwalk_cache_oid($device, 'memoryTable', array(), 'BIANCA-BRICK-MIBRES-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
foreach ($mempool_array as $index => $entry)
{
if ($entry['memoryType'] == 'dpool') { continue; }
$entry['memoryDescr'] = snmp_hexstring($entry['memoryDescr']);
discover_mempool($valid['mempool'], $device, $index, 'BIANCA-BRICK-MIBRES-MIB', $entry['memoryDescr'], 1, $entry['memoryTotal'], $entry['memoryInuse']);
}
unset ($mempool_array);
// EOF

View File

@ -0,0 +1,25 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'sgProxyMem', array(), $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($index) && is_numeric($entry['sgProxyMemAvailable'])) {
$total = $entry['sgProxyMemAvailable'];
$used = $entry['sgProxyMemSysUsage'];
discover_mempool($valid['mempool'], $device, $index, 'BLUECOAT-SG-PROXY-MIB', "Memory $index", 1, $total, $used);
}
}
unset($mempool_array, $index, $total, $used);
// EOF

View File

@ -0,0 +1,29 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// ProxyAV devices hide their CPUs/Memory/Interfaces in here
$av_array = snmpwalk_cache_oid($device, 'deviceUsage', [], $mib);
foreach ($av_array as $index => $entry) {
if (str_contains($entry['deviceUsageName'], 'Memory')) {
$descr = $entry['deviceUsageName'];
$oid = ".1.3.6.1.4.1.3417.2.4.1.1.1.4.$index";
$perc = $entry['deviceUsagePercent'];
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, 100, $perc);
}
}
unset($av_array);
// EOF

View File

@ -0,0 +1,44 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'cempMemPoolEntry', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['cempMemPoolUsed']) && $entry['cempMemPoolValid'] === 'true') {
if (is_numeric($entry['cempMemPoolHCUsed'])) {
// Use HC counters
$hc = 1;
print_debug('HC');
$used = $entry['cempMemPoolHCUsed'];
$free = $entry['cempMemPoolHCFree'];
} else {
// Use 32bit counters
$hc = 0;
$used = $entry['cempMemPoolUsed'];
$free = $entry['cempMemPoolFree'];
}
$total = $used + $free;
list($entPhysicalIndex) = explode('.', $index);
$entPhysicalName = trim(snmp_get_oid($device, "entPhysicalName.$entPhysicalIndex", 'ENTITY-MIB'));
$descr = $entPhysicalName.' ('.$entry['cempMemPoolName'].')';
$descr = str_replace([ 'Cisco ', 'Network Processing Engine', 'CPU of' ], '', $descr);
$descr = preg_replace('/Sub-Module (\d+) CFC Card/', "Module \\1 CFC", $descr);
discover_mempool($valid['mempool'], $device, $index, 'CISCO-ENHANCED-MEMPOOL-MIB', $descr, 1, $total, $used, $hc);
}
}
unset($mempool_array, $index, $descr, $total, $used, $free, $entPhysicalIndex, $entPhysicalName);
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'ceqfpMemoryResourceEntry', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['ceqfpMemoryResInUse'])) {
list($entPhysicalIndex, $entMemoryResource) = explode('.', $index);
$entPhysicalName = snmp_get($device, "entPhysicalName.$entPhysicalIndex", '-Oqv', 'ENTITY-MIB');
$descr = $entPhysicalName.' - '.$entMemoryResource;
$used = $entry['ceqfpMemoryResInUse'];
$total = $entry['ceqfpMemoryResTotal'];
discover_mempool($valid['mempool'], $device, $index, 'CISCO-ENTITY-QFP-MIB', $descr, 1, $total, $used);
}
}
unset($mempool_array, $index, $descr, $total, $used, $free, $entPhysicalIndex, $entPhysicalName, $entMemoryResource);
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Ignore this discovery module if we have already discovered things in CISCO-ENHANCED-MEMPOOL-MIB. Dirty duplication.
if (!isset($valid['mempool']['cisco-enhanced-mempool-mib']) && !isset($valid['mempool']['CISCO-ENHANCED-MEMPOOL-MIB'])) {
$mempool_array = snmpwalk_cache_oid($device, 'ciscoMemoryPool', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['ciscoMemoryPoolUsed']) && is_numeric($index) && $entry['ciscoMemoryPoolValid'] !== 'false') {
$descr = $entry['ciscoMemoryPoolName'];
$used = $entry['ciscoMemoryPoolUsed'];
$free = $entry['ciscoMemoryPoolFree'];
$total = $used + $free;
discover_mempool($valid['mempool'], $device, $index, 'CISCO-MEMORY-POOL-MIB', $descr, 1, $total, $used);
}
}
unset($mempool_array, $index, $descr, $total, $used, $free);
}
// EOF

View File

@ -0,0 +1,42 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Ignore this discovery module if we have already discovered things in CISCO-ENHANCED-MEMPOOL-MIB. Dirty duplication.
if (!isset($valid['mempool']['cisco-enhanced-mempool-mib']) && !isset($valid['mempool']['CISCO-ENHANCED-MEMPOOL-MIB']) &&
!isset($valid['mempool']['cisco-memory-pool-mib']) && !isset($valid['mempool']['CISCO-MEMORY-POOL-MIB']))
{
$mempool_array = snmpwalk_cache_oid($device, 'cpmCPUMemoryUsed', array(), $mib);
$mempool_array = snmpwalk_cache_oid($device, 'cpmCPUMemoryFree', $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, 'cpmCPUTotalPhysicalIndex', $mempool_array, $mib);
foreach ($mempool_array as $index => $entry)
{
if (is_numeric($entry['cpmCPUMemoryUsed']) && is_numeric($entry['cpmCPUMemoryFree']))
{
if ($entry['cpmCPUTotalPhysicalIndex'])
{
$descr = snmp_get($device, 'entPhysicalName.' . $entry['cpmCPUTotalPhysicalIndex'], '-Oqv', 'ENTITY-MIB');
} else {
$descr = "Memory Pool $index";
}
$used = $entry['cpmCPUMemoryUsed'];
$free = $entry['cpmCPUMemoryFree'];
$total = $used + $free;
discover_mempool($valid['mempool'], $device, $index, 'CISCO-PROCESS-MIB', $descr, 1024, $total, $used);
}
}
}
// EOF

View File

@ -0,0 +1,50 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// DELL-NETWORKING-CHASSIS-MIB::dellNetCpuUtilMemUsage.stack.1.1 = Gauge32: 41 percent
// DELL-NETWORKING-CHASSIS-MIB::dellNetProcessorMemSize.stack.1.1 = INTEGER: 2029
$mempool_array = snmpwalk_cache_threepart_oid($device, 'dellNetCpuUtilMemUsage', [], $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_threepart_oid($device, 'dellNetProcessorMemSize', $mempool_array, $mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
print_debug_vars($mempool_array);
foreach ($mempool_array as $type => $entry1) {
// Hrm, this is possible for multiple types?
$first_unit = array_key_first($entry1);
foreach ($entry1 as $unit => $entry2) {
$mempool_count = count($entry2);
foreach ($entry2 as $mempool => $entry) {
$index = "{$type}.{$unit}.{$mempool}";
$dot_index = ".{$index}";
$descr = 'Unit ' . ($unit - $first_unit);
if ($mempool_count > 1) {
$descr .= " Memory {$mempool}";
}
$oid_table = 'dellNetCpuUtilTable';
$oid_name = 'dellNetCpuUtilMemUsage';
$precision = 1024 * 1024;
$total = $entry['dellNetProcessorMemSize'];
$percent = $entry['dellNetCpuUtilMemUsage'];
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, $precision, $total, $used);
}
}
}
}
unset($mempool_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,27 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'extremeMemoryMonitorSystemTable', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['extremeMemoryMonitorSystemFree']) && is_numeric($index)) {
$descr = "Memory $index";
$free = $entry['extremeMemoryMonitorSystemFree'];
$total = $entry['extremeMemoryMonitorSystemTotal'];
$used = $total - $free;
discover_mempool($valid['mempool'], $device, $index, 'EXTREME-SOFTWARE-MONITOR-MIB', $descr, 1024, $total, $used);
}
}
unset($mempool_array, $index, $descr, $total, $used, $free);
// EOF

View File

@ -0,0 +1,43 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Force10 C-Series
// FIXME. Need snmpwalk for total size: F10-C-SERIES-CHASSIS-MIB::chSysProcessorMemSize
// F10-C-SERIES-CHASSIS-MIB::chRpmMemUsageUtil.1 = 5
$mempool_array = snmpwalk_cache_oid($device, 'chRpmMemUsageUtil', [], $mib);
if (!safe_empty($mempool_array)) {
$total_array = snmpwalk_cache_oid($device, 'chSysProcessorMemSize', [], $mib);
print_debug_vars($total_array);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['chRpmMemUsageUtil'])) {
if (is_numeric($total_array[$index]['chSysProcessorMemSize'])) {
$precision = 1024 * 1024;
$total = $total_array[$index]['chSysProcessorMemSize']; // FTOS display memory in MB
//$total *= $precision;
} else {
$precision = 1;
$total = 1090519040; // Hardcoded total.
}
$percent = $entry['chRpmMemUsageUtil'];
$used = $total * $percent / 100;
$descr = $index == 1 ? 'CP' : 'RP' . ($index - 1);
discover_mempool($valid['mempool'], $device, $index, 'F10-C-SERIES-CHASSIS-MIB', $descr, $precision, $total, $used);
}
}
}
unset($mempool_array, $total_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,46 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Force10 E-Series
// FIXME. Need snmpwalk for total size: F10-CHASSIS-MIB::chSysProcessorMemSize
// F10-CHASSIS-MIB::chRpmMemUsageUtil.1 = 5
// F10-CHASSIS-MIB::chRpmMemUsageUtil.2 = 36
// F10-CHASSIS-MIB::chRpmMemUsageUtil.3 = 9
$mempool_array = snmpwalk_cache_oid($device, 'chRpmMemUsageUtil', [], $mib);
if (!safe_empty($mempool_array)) {
$total_array = snmpwalk_cache_oid($device, 'chSysProcessorMemSize.1', [], $mib);
print_debug_vars($total_array);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['chRpmMemUsageUtil'])) {
if (is_numeric($total_array['1.'.$index]['chSysProcessorMemSize'])) {
$precision = 1024 * 1024;
$total = $total_array['1.'.$index]['chSysProcessorMemSize']; // FTOS display memory in MB
//$total *= $precision;
} else {
$precision = 1;
$total = 1090519040; // Hardcoded total. See FIXME above.
}
$percent = $entry['chRpmMemUsageUtil'];
$used = $total * $percent / 100;
$descr = $index == 1 ? 'CP' : 'RP' . ($index - 1);
discover_mempool($valid['mempool'], $device, $index, 'F10-CHASSIS-MIB', $descr, $precision, $total, $used);
}
}
}
unset($mempool_array, $total_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,41 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Force10 M-Series
$mempool_array = snmpwalk_cache_oid($device, 'chStackUnitMemUsageUtil', [], $mib);
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, 'chStackUnitSysType', $mempool_array, $mib);
$total_array = snmpwalk_cache_oid($device, 'chSysProcessorMemSize', [], $mib);
print_debug_vars($total_array);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['chStackUnitMemUsageUtil'])) {
if (is_numeric($total_array[$index]['chSysProcessorMemSize'])) {
$precision = 1024 * 1024;
$total = $total_array[$index]['chSysProcessorMemSize']; // FTOS display memory in MB
//$total *= $precision;
} else {
$precision = 1;
$total = 1090519040; // Hardcoded total.
}
$percent = $entry['chStackUnitMemUsageUtil'];
$used = $total * $percent / 100;
$descr = 'Unit ' . ($index - 1) . ' ' . $entry['chStackUnitSysType'];
discover_mempool($valid['mempool'], $device, $index, 'F10-M-SERIES-CHASSIS-MIB', $descr, $precision, $total, $used);
}
}
}
unset($mempool_array, $total_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,43 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Force10 S-Series
// F10-S-SERIES-CHASSIS-MIB::chStackUnitMemUsageUtil.1 = Gauge32: 86
$mempool_array = snmpwalk_cache_oid($device, 'chStackUnitMemUsageUtil', [], $mib);
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, 'chStackUnitSysType', $mempool_array, $mib);
$total_array = snmpwalk_cache_oid($device, 'chSysProcessorMemSize', [], $mib);
print_debug_vars($total_array);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['chStackUnitMemUsageUtil'])) {
if (is_numeric($total_array[$index]['chSysProcessorMemSize'])) {
$precision = 1024 * 1024;
$total = $total_array[$index]['chSysProcessorMemSize']; // FTOS display memory in MB
//$total *= $precision;
} else {
$precision = 1;
$total = 1090519040; // Hardcoded total
}
$percent = $entry['chStackUnitMemUsageUtil'];
$used = $total * $percent / 100;
$descr = 'Unit ' . ($index - 1) . ' ' . $entry['chStackUnitSysType'];
discover_mempool($valid['mempool'], $device, $index, 'F10-S-SERIES-CHASSIS-MIB', $descr, $precision, $total, $used);
}
}
}
unset($mempool_array, $total_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,29 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$tmm_memory = snmpwalk_cache_oid($device, 'sysTmmStatMemoryUsed', array(), $mib);
$tmm_memory = snmpwalk_cache_oid($device, 'sysTmmStatMemoryTotal', $tmm_memory, $mib);
foreach ($tmm_memory as $index => $entry)
{
$total = $entry['sysTmmStatMemoryTotal'];
if ($total == 0) continue;
$used = $entry['sysTmmStatMemoryUsed'];
$descr = "TMM $index Memory";
discover_mempool($valid['mempool'], $device, $index, 'F5-BIGIP-SYSTEM-MIB', $descr, 1, $total, $used);
}
unset ($mempool_array, $index, $total, $used);
// EOF

View File

@ -0,0 +1,46 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
//snAgGblDynMemUtil OBJECT-TYPE
// STATUS deprecated
// DESCRIPTION
// 'The system dynamic memory utilization, in unit of percentage.
// Deprecated: Refer to snAgSystemDRAMUtil.
// For NI platforms, refer to snAgentBrdMemoryUtil100thPercent'
$percent = snmp_get_oid($device, 'snAgSystemDRAMUtil.0', $mib);
$total = snmp_get_oid($device, 'snAgSystemDRAMTotal.0', $mib);
// This device some time have negative Total
// FOUNDRY-SN-AGENT-MIB::snAgSystemDRAMTotal.0 = -2147483648
if ($total < -1 && is_numeric($total)) { $total = abs($total); }
if (is_numeric($percent) && $total > 0)
{
// Use new OIDs
$hc = 1; // This is fake HC bit.
} else {
// Use old deprecated OIDs
$hc = 0;
$percent = snmp_get_oid($device, 'snAgGblDynMemUtil.0', $mib);
$total = snmp_get_oid($device, 'snAgGblDynMemTotal.0', $mib);
if ($total == -1 && is_numeric($total)) { $total = 100; }
}
if (is_numeric($percent) && is_numeric($total) && $total > 0) {
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, 0, 'FOUNDRY-SN-AGENT-MIB', 'Memory', 1, $total, $used, $hc);
}
unset ($total, $used, $percent, $hc);
// EOF

View File

@ -0,0 +1,43 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// HH3C-ENTITY-EXT-MIB::hh3cEntityExtMemUsage.30 = INTEGER: 58
// HH3C-ENTITY-EXT-MIB::hh3cEntityExtMemUsage.36 = INTEGER: 59
// HH3C-ENTITY-EXT-MIB::hh3cEntityExtMemUsage.42 = INTEGER: 58
// HH3C-ENTITY-EXT-MIB::hh3cEntityExtMemUsage.48 = INTEGER: 58
$oids = [ 'hh3cEntityExtMemUsage', 'hh3cEntityExtMemSize' ];
$mempool_array = [];
foreach ($oids as $oid) {
$mempool_array = snmpwalk_cache_oid($device, $oid, $mempool_array, $mib);
if (!snmp_status()) { break; }
}
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, 'entPhysicalName', $mempool_array, 'ENTITY-MIB');
foreach ($mempool_array as $index => $entry) {
$entry['hh3cEntityExtMemSize'] = snmp_dewrap32bit($entry['hh3cEntityExtMemSize']);
if (is_numeric($entry['hh3cEntityExtMemUsage']) && $entry['hh3cEntityExtMemSize'] > 0) {
$descr = $entry['entPhysicalName'];
$percent = $entry['hh3cEntityExtMemUsage'];
$total = $entry['hh3cEntityExtMemSize'];
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, $total, $used);
}
}
}
unset($mempool_array, $index, $descr, $total, $used, $chassis_count, $percent);
// EOF

View File

@ -0,0 +1,118 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$hrStorage = snmp_cache_table($device, "hrStorageEntry", [], "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
//$debug_stats = array('total' => 0, 'used' => 0);
if (!safe_empty($hrStorage)) {
if ($device['os'] === "arista_eos" && $hrStorage[1]['hrStorageDescr'] === 'RAM') {
// Arista EOS derp hack for correct free memory
// https://eos.arista.com/memory-utilization-on-eos-devices/
// hrStorageType.1 = hrStorageRam
// hrStorageType.2 = hrStorageRam
// hrStorageType.3 = hrStorageRam
// hrStorageType.100 = hrStorageRam
// hrStorageDescr.1 = RAM
// hrStorageDescr.2 = RAM (Buffers)
// hrStorageDescr.3 = RAM (Cache)
// hrStorageDescr.100 = RAM (Unavailable)
// hrStorageAllocationUnits.1 = 1024
// hrStorageAllocationUnits.2 = 1024
// hrStorageAllocationUnits.3 = 1024
// hrStorageAllocationUnits.100 = 1024
// hrStorageSize.1 = 8152456
// hrStorageSize.2 = 8152456
// hrStorageSize.3 = 8152456
// hrStorageSize.100 = 8152456
// hrStorageUsed.1 = 7376060
// hrStorageUsed.2 = 288472
// hrStorageUsed.3 = 2984372
// hrStorageUsed.100 = 1811664
$hrStorage[1]['hrStorageUsed'] = snmp_dewrap32bit($hrStorage[1]['hrStorageUsed']);
foreach ($hrStorage as $idx => $entry) {
if ($idx != '1' && $entry['hrStorageType'] === 'hrStorageRam' &&
str_starts($entry['hrStorageDescr'], 'RAM') && !str_contains($entry['hrStorageDescr'], 'Unavailable')) {
// Use only Buffers and Cache
$hrStorage[1]['hrStorageUsed'] -= snmp_dewrap32bit($entry['hrStorageUsed']);
unset($hrStorage[$idx]);
}
}
unset($idx);
}
foreach ($hrStorage as $index => $entry) {
$descr = $entry['hrStorageDescr'];
$units = $entry['hrStorageAllocationUnits'];
$total = snmp_dewrap32bit($entry['hrStorageSize']);
$used = snmp_dewrap32bit($entry['hrStorageUsed']);
$deny = TRUE;
switch($entry['hrStorageType']) {
case 'hrStorageVirtualMemory':
case 'hrStorageRam':
case 'hrStorageOther':
case 'hrStorageTypes.20':
case 'nwhrStorageDOSMemory':
case 'nwhrStorageMemoryAlloc':
case 'nwhrStorageMemoryPermanent':
case 'nwhrStorageCacheBuffers':
case 'nwhrStorageCacheMovable':
case 'nwhrStorageCacheNonMovable':
case 'nwhrStorageCodeAndDataMemory':
case 'nwhrStorageIOEngineMemory':
case 'nwhrStorageMSEngineMemory':
case 'nwhrStorageUnclaimedMemory':
$deny = FALSE;
break;
}
if ($device['os'] === "routeros" && $descr === "main memory") {
$deny = FALSE;
} elseif ($device['os'] === "mcd") {
// Yes, hardcoded logic for mcd, because they do not use standard
// See: http://jira.observium.org/browse/OBSERVIUM-1269
if ($index === 1) {
// hrStorageType.1 = hrStorageRam
// hrStorageDescr.1 = System Free Memory
// hrStorageAllocationUnits.1 = 1
// hrStorageSize.1 = 160481280
// hrStorageUsed.1 = 160481280
$descr = "Memory";
$free = $total;
$total = 536870912; // 512Mb, Really total memory calculates as summary of all memory pools from this mib
$used = $total - $free;
discover_mempool($valid['mempool'], $device, $index, "host-resources-mcd", $descr, $units, $total, $used);
}
$deny = TRUE;
continue;
}
if ($deny ||
str_contains_array($descr, [ "MALLOC", "UMA" ]) || // Ignore FreeBSD INSANITY
str_contains_array($descr, [ "procfs", "/proc" ]) || // Ignore ProcFS
in_array($descr, [ "Cached memory", "Shared memory", "Physical memory" ], TRUE)) { // Ignore worthless data on Unix hosts
continue;
}
if (is_numeric($entry['hrStorageSize']) && $total) {
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, $units, $total, $used);
//$debug_stats['total'] += $total;
//$debug_stats['used'] += $used;
}
}
}
unset($index, $descr, $total, $used, $units, $deny);
// EOF

View File

@ -0,0 +1,43 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// HPN-ICF-ENTITY-EXT-MIB::hpnicfEntityExtMemUsage.30 = INTEGER: 58
// HPN-ICF-ENTITY-EXT-MIB::hpnicfEntityExtMemUsage.36 = INTEGER: 59
// HPN-ICF-ENTITY-EXT-MIB::hpnicfEntityExtMemUsage.42 = INTEGER: 58
// HPN-ICF-ENTITY-EXT-MIB::hpnicfEntityExtMemUsage.48 = INTEGER: 58
$oids = [ 'hpnicfEntityExtMemUsage', 'hpnicfEntityExtMemSize' ];
$mempool_array = [];
foreach ($oids as $oid) {
$mempool_array = snmpwalk_cache_oid($device, $oid, $mempool_array, 'ENTITY-MIB:HPN-ICF-ENTITY-EXT-MIB');
if (!snmp_status()) { break; }
}
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, 'entPhysicalName', $mempool_array, 'ENTITY-MIB:HPN-ICF-ENTITY-EXT-MIB');
foreach ($mempool_array as $index => $entry) {
$entry['hpnicfEntityExtMemSize'] = snmp_dewrap32bit($entry['hpnicfEntityExtMemSize']);
if (is_numeric($entry['hpnicfEntityExtMemUsage']) && $entry['hpnicfEntityExtMemSize'] > 0) {
$descr = $entry['entPhysicalName'];
$percent = $entry['hpnicfEntityExtMemUsage'];
$total = $entry['hpnicfEntityExtMemSize'];
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, $total, $used);
}
}
}
unset($mempool_array, $index, $descr, $total, $used, $chassis_count, $percent);
// EOF

View File

@ -0,0 +1,47 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// Huawei VRP mempools
$mempool_array = snmpwalk_cache_oid($device, "hwEntityMemUsage", [], $mib);
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, "hwEntityMemSize", $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, "hwEntityMemUsageThreshold", $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, "entPhysicalName", $mempool_array, 'ENTITY-MIB');
foreach ($mempool_array as $index => $entry) {
if (isset($entry['hwEntityMemSize'])) {
// not all platforms have hwEntityMemSize.. what tf
if ($entry['hwEntityMemSize'] == 0) {
print_debug("Entity is not support Memory usage:");
print_debug_vars($entry);
continue;
}
} elseif (isset($entry['hwEntityMemUsageThreshold']) && $entry['hwEntityMemUsageThreshold'] == 0 && $entry['hwEntityMemUsage'] == 0) {
print_debug("Entity is not support Memory usage:");
print_debug_vars($entry);
continue;
}
$descr = rewrite_entity_name($entry['entPhysicalName']);
$percent = $entry['hwEntityMemUsage'];
if (!safe_empty($descr) && !str_contains($descr, 'No') && !str_contains($percent, 'No')) {
$total = isset($entry['hwEntityMemSize']) && $entry['hwEntityMemSize'] > 0 ? $entry['hwEntityMemSize'] : 100;
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, 'HUAWEI-ENTITY-EXTENT-MIB', $descr, 1, $total, $used);
}
}
}
unset($mempool_array, $index, $descr, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,40 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'jnxOperatingBuffer', [], $mib);
if (!safe_empty($mempool_array)) {
$mempool_array = snmpwalk_cache_oid($device, 'jnxOperatingMemory', $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, 'jnxOperatingDRAMSize', $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, 'jnxOperatingDescr', $mempool_array, $mib);
foreach ($mempool_array as $index => $entry) {
$descr = $entry['jnxOperatingDescr'];
if (!is_numeric($entry['jnxOperatingBuffer']) || str_icontains_array($descr, [ 'sensor', 'fan', 'pcmcia', 'no' ])) { continue; }
if ($entry['jnxOperatingDRAMSize']) {
$precision = 1;
$total = $entry['jnxOperatingDRAMSize']; // Size in bytes
} elseif ($entry['jnxOperatingMemory']) {
$precision = 1024 * 1024;
$total = $entry['jnxOperatingMemory']; // Size in megabytes
} else {
continue;
}
$percent = $entry['jnxOperatingBuffer'];
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, $precision, $total, $used);
}
}
unset($mempool_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,33 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$srx_spu_array = array();
$srx_spu_array = snmpwalk_cache_oid($device, 'jnxJsSPUMonitoringNodeDescr', $srx_spu_array, $mib);
$srx_spu_array = snmpwalk_cache_oid($device, 'jnxJsSPUMonitoringFPCIndex', $srx_spu_array, $mib);
$srx_spu_array = snmpwalk_cache_oid($device, 'jnxJsSPUMonitoringMemoryUsage', $srx_spu_array, $mib);
$srx_spu_array = snmpwalk_cache_oid($device, 'jnxJsSPUMonitoringNodeDescr', $srx_spu_array, $mib);
foreach ($srx_spu_array as $index => $entry)
{
if (is_numeric($entry['jnxJsSPUMonitoringMemoryUsage']))
{
$descr = ($entry['jnxJsSPUMonitoringNodeDescr'] == 'single' ? '' : $entry['jnxJsSPUMonitoringNodeDescr'] . ' ') . 'SPC slot ' . $entry['jnxJsSPUMonitoringFPCIndex'];
$usage = $entry['jnxJsSPUMonitoringMemoryUsage'];
discover_mempool($valid['mempool'], $device, $index, 'JUNIPER-SRX5000-SPU-MONITORING-MIB', $descr, 1, 100, $usage);
}
}
unset ($srx_spu_array, $index, $descr, $usage);
// EOF

View File

@ -0,0 +1,41 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// NETSWITCH-MIB::hpLocalMemSlotIndex.1 = INTEGER: 1
// NETSWITCH-MIB::hpLocalMemSlabCnt.1 = Counter32: 3966
// NETSWITCH-MIB::hpLocalMemFreeSegCnt.1 = Counter32: 166
// NETSWITCH-MIB::hpLocalMemAllocSegCnt.1 = Counter32: 3803
// NETSWITCH-MIB::hpLocalMemTotalBytes.1 = INTEGER: 11337704
// NETSWITCH-MIB::hpLocalMemFreeBytes.1 = INTEGER: 9669100
// NETSWITCH-MIB::hpLocalMemAllocBytes.1 = INTEGER: 1668732
// NETSWITCH-MIB::hpGlobalMemSlotIndex.1 = INTEGER: 1
// NETSWITCH-MIB::hpGlobalMemSlabCnt.1 = Counter32: 3966
// NETSWITCH-MIB::hpGlobalMemFreeSegCnt.1 = Counter32: 166
// NETSWITCH-MIB::hpGlobalMemAllocSegCnt.1 = Counter32: 3803
// NETSWITCH-MIB::hpGlobalMemTotalBytes.1 = INTEGER: 11337704
// NETSWITCH-MIB::hpGlobalMemFreeBytes.1 = INTEGER: 9669104
// NETSWITCH-MIB::hpGlobalMemAllocBytes.1 = INTEGER: 1668728
$mempool_array = snmpwalk_cache_oid($device, 'hpLocal', [], $mib);
foreach ($mempool_array as $index => $entry) {
if (is_numeric($index) && is_numeric($entry['hpLocalMemTotalBytes'])) {
$total = $entry['hpLocalMemTotalBytes'];
$used = $entry['hpLocalMemAllocBytes'];
discover_mempool($valid['mempool'], $device, $index, 'NETSWITCH-MIB', "Memory $index", 1, $total, $used);
}
}
unset($mempool_array, $index, $total, $used);
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'oacSysMemStatistics', array(), $mib);
foreach ($mempool_array as $index => $entry)
{
if (is_numeric($index) && is_numeric($entry['oacSysMemoryTotal']))
{
$free = $entry['oacSysMemoryFree'];
$used = $entry['oacSysMemoryAllocated'];
$total = $entry['oacSysMemoryTotal'];
$descr = 'System Memory';
discover_mempool($valid['mempool'], $device, $index, 'ONEACCESS-SYS-MIB', $descr, 1, $total, $used);
}
}
unset ($mempool_array, $index, $total, $used);
// EOF

View File

@ -0,0 +1,27 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
//PEAKFLOW-SP-MIB::devicePhysicalMemory.0 = INTEGER: 8293156
//PEAKFLOW-SP-MIB::devicePhysicalMemoryInUse.0 = INTEGER: 2493368
//PEAKFLOW-SP-MIB::devicePhysicalMemoryUsage.0 = INTEGER: 30
if (!is_device_mib($device, 'HOST-RESOURCES-MIB')) // Memory pools already available in HOST-RESOURCES-MIB
{
$mempool_array = snmp_get_multi_oid($device, 'devicePhysicalMemory.0 devicePhysicalMemoryInUse.0', array(), $mib);
discover_mempool($valid['mempool'], $device, 0, 'PEAKFLOW-SP-MIB', 'Physical Memory', 1024, $mempool_array[0]['devicePhysicalMemory'], $mempool_array[0]['devicePhysicalMemoryInUse']);
unset ($mempool_array);
}
// EOF

View File

@ -0,0 +1,39 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
// S5-CHASSIS-MIB::s5ChasUtilMemoryTotalMB.3.10.0 = Gauge32: 128 MegaBytes
// S5-CHASSIS-MIB::s5ChasUtilMemoryAvailableMB.3.10.0 = Gauge32: 65 MegaBytes
$mempool_array = snmpwalk_cache_oid($device, 's5ChasUtilEntry', array(), $mib);
//$mempool_array = snmpwalk_cache_oid($device, 's5ChasComTable', $mempool_array, 'S5-CHASSIS-MIB:S5-REG-MIB');
//print_vars($mempool_array);
if (!safe_empty($mempool_array)) {
$i = 1;
foreach ($mempool_array as $index => $entry) {
if (is_numeric($entry['s5ChasUtilMemoryAvailableMB']) && is_numeric($entry['s5ChasUtilMemoryTotalMB'])) {
$precision = 1024 * 1024;
$total = $entry['s5ChasUtilMemoryTotalMB'];
//$total *= $precision;
$free = $entry['s5ChasUtilMemoryAvailableMB'];
//$free *= $precision;
$used = $total - $free;
$descr = "Memory Unit $i";
discover_mempool($valid['mempool'], $device, $index, 'S5-CHASSIS-MIB', $descr, $precision, $total, $used);
$i++;
}
}
}
unset($mempool_array, $index, $descr, $precision, $total, $used, $free, $i);
// EOF

View File

@ -0,0 +1,30 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'memory', array(), $mib);
foreach ($mempool_array as $index => $entry)
{
if (is_numeric($index) && is_numeric($entry['memTotalBytes']))
{
$free = $entry['memFreeBytes'];
$used = $entry['memAllocatedBytes'];
$total = $free + $used; # memTotalBytes is 0 !
$descr = $entry['memDescr'];
discover_mempool($valid['mempool'], $device, $index, 'SMARTNODE-MIB', $descr, 1, $total, $used);
}
}
unset ($mempool_array, $index, $total, $used);
// EOF

View File

@ -0,0 +1,44 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// TIMETRA-SYSTEM-MIB::sgiMemoryUsed.0 = Gauge32: 300145144 bytes
// TIMETRA-SYSTEM-MIB::sgiMemoryAvailable.0 = Gauge32: 518611632 bytes
// TIMETRA-SYSTEM-MIB::sgiMemoryPoolAllocated.0 = Gauge32: 320917080 bytes
// TIMETRA-SYSTEM-MIB::sgiMemoryUsed.0 = Gauge32: 305605608 bytes
// TIMETRA-SYSTEM-MIB::sgiMemoryAvailable.0 = Gauge32: 600985024 bytes
// TIMETRA-SYSTEM-MIB::sgiMemoryPoolAllocated.0 = Gauge32: 325038952 bytes
/*
If the value is greater than the maximum value reportable by this
object then this object reports its maximum value (4,294,967,295)
and sgiKbMemoryPoolAllocated must be used to determine the total
memory allocated in memory-pools.
FIXME: sgiKbMemoryUsed, sgiKbMemoryAvailable, sgiKbMemoryPoolAllocated (use HC bit)
Used is used memory, Available is memory not assigned to pools, PoolAllocated is memory assigned to poools.
Total is calculated with Available+PoolAllocated
*/
$mempool_array = snmpwalk_cache_oid($device, 'sgiMemoryAvailable', array(), $mib);
$mempool_array = snmpwalk_cache_oid($device, 'sgiMemoryUsed', $mempool_array, $mib);
$mempool_array = snmpwalk_cache_oid($device, 'sgiMemoryPoolAllocated', array(), $mib);
if (is_numeric($mempool_array[0]['sgiMemoryUsed']))
{
discover_mempool($valid['mempool'], $device, 0, 'TIMETRA-SYSTEM-MIB', 'Memory', 1, ($mempool_array[0]['sgiMemoryAvailable']+$mempool_array[0]['sgiMemoryPoolAllocated']), $mempool_array[0]['sgiMemoryUsed']);
}
unset ($mempool_array);
// EOF

View File

@ -0,0 +1,115 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Poll mem for load memory utilisation stats on UNIX-like hosts running UCD/Net-SNMPd
#UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
#UCD-SNMP-MIB::memErrorName.0 = STRING: swap
#UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 32762248 kB
#UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 32199396 kB
#UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 8187696 kB
#UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 1211056 kB
#UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 33410452 kB
#UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000 kB
#UCD-SNMP-MIB::memBuffer.0 = INTEGER: 104388 kB
#UCD-SNMP-MIB::memCached.0 = INTEGER: 2595556 kB
#UCD-SNMP-MIB::memShared.0 = INTEGER: 595556 kB
#UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)
#UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:
//$snmpdata = snmpwalk_cache_oid($device, "mem", array(), "UCD-SNMP-MIB");
//$data = $snmpdata[0];
$data = snmp_get_multi_oid($device, 'memTotalReal.0 memAvailReal.0 memBuffer.0 memCached.0', array(), 'UCD-SNMP-MIB');
$data = $data[0];
//if(is_array($data) && isset($data['memTotalReal']) && isset($data['memBuffer']) && isset($data['memCached']) && isset($data['memAvailReal']) &&
// $data['memCached'] >= 0 && $data['memBuffer'] >= 0 && $data['memAvailReal'] >= 0 && $data['memTotalReal'] >= 0)
if (is_array($data) && isset($data['memTotalReal']) && isset($data['memAvailReal']) &&
$data['memAvailReal'] >= 0 && $data['memTotalReal'] >= 0)
{
$mempool['total'] = $data['memTotalReal'] * 1024;
$mempool_hc = 0;
/* BEGIN REDHAT BUG */
// CLEANME. remove in r11000, but not before CE 20.8
/**
* New RedHat net-snmp version updated memory calculations:
* https://bugzilla.redhat.com/show_bug.cgi?id=1250060
* https://bugzilla.redhat.com/show_bug.cgi?id=1779609
* See: https://jira.observium.org/browse/OBS-3090
* https://jira.observium.org/browse/OBS-3100
*
* 2019-12-09 - Josef Ridky <jridky@redhat.com> - 1:5.7.2-47
* - revert calculation of free space (#1779609)
* ...
* 2019-05-22 - Josef Ridky <jridky@redhat.com> - 1:5.7.2-43
* - fix available memory calculation (#1250060)
*/
$ucd_version = snmp_get_multi_oid($device, 'versionTag.0 versionCDate.0 versionConfigureOptions.0', array(), 'UCD-SNMP-MIB');
$ucd_version = $ucd_version[0];
// Detect if there redhat locally changed net-snmp package, this patch was added at 2019-05-22
// UCD-SNMP-MIB::versionTag.0 = 5.7.2
// UCD-SNMP-MIB::versionCDate.0 = Wed Sep 18 15:12:36 2019
// UCD-SNMP-MIB::versionConfigureOptions.0 = '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-static' '--enable-shared' '--with-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_RPM_4_4_COMPAT' '--with-ldflags=-Wl,-z,relro -Wl,-z,now' '--with-sys-location=Unknown' '--with-logfile=/var/log/snmpd.log' '--with-persistent-directory=/var/lib/net-snmp' '--with-mib-modules=host agentx smux ucd-snmp/diskio tcp-mib udp-mib mibII/mta_sendmail ip-mib/ipv4InterfaceTable ip-mib/ipv6InterfaceTable ip-mib/ipAddressPrefixTable/ipAddressPrefixTable ip-mib/ipDefaultRouterTable/ipDef
if (is_array($ucd_version) && str_contains_array($ucd_version['versionConfigureOptions'], '-redhat-') &&
version_compare($ucd_version['versionTag'], '5.7.2', '>=')
&& strtotime($ucd_version['versionCDate']) > 1558483200)
{
if (strtotime($ucd_version['versionCDate']) >= 1575849600)
{
del_entity_attrib('device', $device['device_id'], 'ucd_memory_bad');
} else {
$mempool['free'] = $data['memAvailReal'] * 1024;
$mempool_hc = 1;
set_entity_attrib('device', $device['device_id'], 'ucd_memory_bad', 1); // Set this attrib for poller/graph
}
}
/* END REDHAT BUG */
if ($mempool_hc === 0)
{
$mempool['free'] = ($data['memAvailReal'] + ($data['memBuffer'] + $data['memCached'])) * 1024;
}
$mempool['used'] = $mempool['total'] - $mempool['free'];
$mempool['perc'] = percent($mempool['free'], $mempool['total'], FALSE);
$index = '0';
$descr = 'Physical Memory';
discover_mempool($valid['mempool'], $device, $index, 'UCD-SNMP-MIB', $descr, 1, $mempool['total'], $mempool['used'], $mempool_hc);
}
/**
This is already collected from HOST-RESOURCES-MIB accurately.
$data = snmp_get_multi_oid($device, 'memTotalSwap.0 memAvailSwap.0', array(), 'UCD-SNMP-MIB');
$data = $data[0];
if(is_array($data) && isset($data['memTotalSwap']) && isset($data['memAvailSwap']) && $data['memTotalSwap'] != 0)
{
$total = $data['memTotalSwap'] * 1024;
$free = $data['memAvailSwap'] * 1024;
$used = $total - $free;
$perc = $free / $total * 100;
$index = 'swap';
$descr = 'Swap memory';
discover_mempool($valid['mempool'], $device, $index, 'UCD-SNMP-MIB', $descr, "1", $total, $used);
}
**/
// EOF

View File

@ -0,0 +1,41 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// ZHONE-CARD-RESOURCES-MIB::cardRuntimeTable
// ZHONE-CARD-RESOURCES-MIB::cardPeakMemUsage.1.1 = INTEGER: 80762
// ZHONE-CARD-RESOURCES-MIB::cardAvailMem.1.1 = INTEGER: 145131
// ZHONE-CARD-RESOURCES-MIB::cardTotalMem.1.1 = INTEGER: 225421
// ZHONE-CARD-RESOURCES-MIB::cardMemStatus.1.1 = INTEGER: ramMemOK(1)
$mempool_array = snmpwalk_cache_oid($device, "cardAvailMem", array(), $mib);
$mempool_array = snmpwalk_cache_oid($device, "cardTotalMem", $mempool_array, $mib);
$mempool_count = count($mempool_array);
foreach ($mempool_array as $index => $entry)
{
$descr = "Memory";
if ($mempool_count > 1)
{
list($zhoneShelfIndex, $zhoneSlotIndex) = explode('.', $index);
$descr .= " - Shelf $zhoneShelfIndex, Slot $zhoneSlotIndex";
}
$oid_name = 'cardAvailMem';
$used = $entry['cardTotalMem'] - $entry[$oid_name];
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1024, $entry['cardTotalMem'], $used);
}
unset ($mempool_array);
// EOF

View File

@ -0,0 +1,41 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$mempool_array = snmpwalk_cache_oid($device, 'zxr10SystemUnitTable', array(), $mib);
$mempool_count = count($mempool_array);
if (OBS_DEBUG > 1 && $mempool_count) { print_vars($mempool_array); }
foreach ($mempool_array as $index => $entry)
{
if ($entry['zxr10SystemUnitRunStatus'] == 'down') { continue; }
$descr = 'Memory';
if ($mempool_count > 1)
{
$descr = 'Unit ' . $index . ' ' . $descr;
}
$oid_name = 'zxr10SystemMemUsed'; // Percent
$oid_num = '.1.3.6.1.4.1.3902.3.3.1.1.4.'.$index;
$type = $mib . '-' . $oid_name;
$percent = $entry[$oid_name];
$total = $entry['zxr10SystemMemSize'];
$used = $total * $percent / 100;
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, $total, $used);
}
unset ($mempool_array, $index, $descr, $precision, $total, $used, $percent);
// EOF

View File

@ -0,0 +1,39 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
//ZYXEL-SYS-MEMORY-MIB::zySysMemoryPoolName.1 = STRING: "common"
//ZYXEL-SYS-MEMORY-MIB::zySysMemoryPoolTotalSize.1 = Gauge32: 17636992
//ZYXEL-SYS-MEMORY-MIB::zySysMemoryPoolUsedSize.1 = Gauge32: 7209008
//ZYXEL-SYS-MEMORY-MIB::zySysMemoryPoolUtilization.1 = Gauge32: 40
$mempool_array = snmpwalk_cache_oid($device, 'zyxelSysMemoryPoolEntry', array(), $mib);
print_debug_vars($mempool_array);
foreach ($mempool_array as $index => $entry)
{
$descr = $entry['zySysMemoryPoolName'];
$oid_name = 'zySysMemoryPoolUsedSize';
$oid_num = '.1.3.6.1.4.1.890.1.15.3.50.1.1.1.4.'.$index;
$type = $mib . '-' . $oid_name;
$total = $entry['zySysMemoryPoolTotalSize'];
$used = $entry[$oid_name];
discover_mempool($valid['mempool'], $device, $index, $mib, $descr, 1, $total, $used);
}
unset($mempool_array, $index, $descr, $precision, $total, $used);
// EOF

View File

@ -0,0 +1,392 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// Init vars
$identities = [];
$identities_found = [];
$mibs_found = []; // 'MIB' => 'where founded' (sysorid, sysordescr, discovery)
$mibs_disable = []; // List mibs for disable
$mibs_rename = [
'ETHERLIKE-MIB' => 'EtherLike-MIB', // Fix camel-case mib name
'Printer-MIB' => 'SKIP-Printer-MIB', // do not discover it by AGENT-CAPABILITIES, that incorrect
'Job-Monitoring-MIB' => 'SKIP-Job-Monitoring-MIB', // do not discover it by AGENT-CAPABILITIES, that incorrect
];
// Agent capabilities for the CISCO-SIP-UA-MIB. LAST-UPDATED 200506220000Z ciscoSipUaCapabilityV12R0402T AGENT-CAPABILITIES SUPPORTS CISCO-SIP-UA-MIB File name: sys
$sysordescr_patterns[] = '/AGENT-CAPABILITIES\s+SUPPORTS\s+(?<mib>\S+)/';
//LLDP-V2-MIB, REVISION 200906080000Z
//ENTITY-MIB, RFC 4133
$sysordescr_patterns[] = '/^(?<mib>\S+), (REVISION \d{12}[A-Z]|RFC \d+)$/i';
$device_sysORID = snmpwalk_oid_num($device, 'sysORID', array(), 'SNMPv2-MIB');
$device_sysORID = snmpwalk_cache_oid($device, 'sysORDescr', $device_sysORID, 'SNMPv2-MIB', NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($device_sysORID);
foreach ($device_sysORID as $entry) {
// Collect founded identities
if (strlen($entry['sysORID'])) {
$identities[] = $entry['sysORID'];
}
// Collect founded MIBs by sysORDescr
foreach ($sysordescr_patterns as $pattern) {
if (preg_match($pattern, $entry['sysORDescr'], $matches)) {
$mib = array_str_replace($mibs_rename, $matches['mib']);
if (!isset($mibs_found[$mib])) {
$mibs_found[$mib] = [ 'source' => 'sysORDescr' ];
// If identity found, append
if (strlen($entry['sysORID'])) {
$mibs_found[$mib]['identity'] = $entry['sysORID'];
}
} else {
print_debug("MIB [$mib] already found");
}
break;
}
}
}
// OS defined sysORID
$os_identities = [];
if (isset($config['os'][$device['os']]['sysorid'])) {
// Ekinops example
// EKINOPS-MGNT2-MIB::mgnt2RootOIDInventory.1 = OID: EKINOPS-Pm200frs02-MIB::pm200frs02ri
// EKINOPS-MGNT2-MIB::mgnt2RootOIDInventory.2 = OID: EKINOPS-PmPassive-MIB::pmpassiveri
$device_sysORID = snmpwalk_oid_num($device, $config['os'][$device['os']]['sysorid'], [], NULL);
print_debug_vars($device_sysORID);
foreach ($device_sysORID as $entry) {
// Collect founded identities
$oid_num = array_shift($entry);
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid_num)) {
$os_identities[] = $oid_num;
}
}
print_debug_vars($os_identities);
}
unset($device_sysORID);
$device_mibs = get_device_mibs($device, FALSE); // MIBs defined by os/model
$device_mibs_bl = get_device_mibs_blacklist($device); // MIBs blacklisted for os/model
// Loop all known MIBs, discovery by snmp requests and validate founded MIB
$GLOBALS['table_rows'] = [];
foreach ($config['mibs'] as $mib => $mib_def) {
if (in_array($mib, $device_mibs_bl)) { continue; } // Skip blacklisted MIB
// Detect MIB by identities
if (!empty($mib_def['identity_num']) && !isset($mibs_found[$mib])) {
foreach ((array)$mib_def['identity_num'] as $identity_num) {
if (in_array($identity_num, $identities)) {
$mibs_found[$mib] = [ 'source' => 'sysORID', 'identity' => $identity_num ];
break;
}
}
if (!isset($mibs_found[$mib]) && count($os_identities)) {
foreach ($os_identities as $identity_num) {
if (match_oid_num($identity_num, $mib_def['identity_num'])) {
$mibs_found[$mib] = [ 'source' => 'OSsysORID', 'identity' => $identity_num ];
break;
}
}
}
}
// Discovery MIB by additional snmp walks
if (isset($mib_def['discovery']) && !isset($mibs_found[$mib])) {
$mib_defined = in_array($mib, $device_mibs); // MIB already defined for os/model
foreach ($mib_def['discovery'] as $def) {
// When MIB defined in os/model, match discovery without filter os/group
// if ($mib_defined)
// {
// unset($def['os'], $def['os_group']);
// }
if (match_discovery_oids($device, $def)) {
$mibs_found[$mib] = [ 'source' => 'Discovery' ];
// If identity found, append
if (!safe_empty($mib_def['identity_num'])) {
$mibs_found[$mib]['identity'] = is_array($mib_def['identity_num']) ? array_shift($mib_def['identity_num']) : $mib_def['identity_num'];
}
break;
}
}
// If mib discovery not found, but os/model have mib defined, opposite disable it
// See FS.COM FS-SWITCH-MIB
// HP
if (!isset($mibs_found[$mib]) && $mib_defined) {
$mibs_disable[$mib] = [ 'source' => 'Discovery' ];
}
}
}
// Just show model specific MIBs
$model = get_model_array($device);
if (isset($model['mibs'])) {
//print_vars($model);
foreach ($model['mibs'] as $mib) {
$mibs_found[$mib] = ['source' => 'Model'];
// If identity found, append
$mib_def = $config['mibs'][$mib];
if (!empty($mib_def['identity_num'])) {
$mibs_found[$mib]['identity'] = is_array($mib_def['identity_num']) ? array_shift($mib_def['identity_num']) : $mib_def['identity_num'];
}
}
}
// Show matched discovery mibs
if (safe_count($GLOBALS['table_rows'])) {
//$table_opts = array('max-table-width' => 200);
$table_headers = array('%WOID%n', '%WMatched definition%n', '%WValue%n');
print_cli_table($GLOBALS['table_rows'], $table_headers);
}
unset($GLOBALS['table_rows']);
/* Detect correct (new) version of FASTPATH mibs */
$old_fastpath_mibs = [
'BROADCOM-POWER-ETHERNET-MIB',
'FASTPATH-BOXSERVICES-PRIVATE-MIB',
'FASTPATH-SWITCHING-MIB',
'FASTPATH-ISDP-MIB'
];
if (safe_count($mibs_found) && !empty(array_intersect(array_keys($mibs_found), $old_fastpath_mibs))) {
$use_fastpath_new = FALSE;
// OID tree: .1.3.6.1.4.1.4413.1.1
// FASTPATH is old reference BROADCOM mibs
// First detect by CPU by 'EdgeSwitch-SWITCHING-MIB'
//FASTPATH-SWITCHING-MIB::agentSwitchCpuProcessGroup.9.0 = STRING: " 5 Secs ( 99.9999%) 60 Secs ( 99.6646%) 300 Secs ( 99.2548%)"
//EdgeSwitch-SWITCHING-MIB::agentSwitchCpuProcessTotalUtilization.0 = STRING: " 5 Secs ( 99.9999%) 60 Secs ( 99.9224%) 300 Secs ( 99.4892%)"
$data = snmp_get_oid($device, 'agentSwitchCpuProcessTotalUtilization.0', 'EdgeSwitch-SWITCHING-MIB');
$use_fastpath_new = preg_match('/300 Secs \(\s*(?<proc>[\d\.]+)%\)/', $data);
// Second detect by Temperature indexes by 'EdgeSwitch-BOXSERVICES-PRIVATE-MIB'
if (empty($data)) {
$oids = snmpwalk_cache_oid($device, 'boxServicesTempSensorsTable', array(), 'EdgeSwitch-BOXSERVICES-PRIVATE-MIB');
// By first detect if device used old FAST-BOXSERVICES-PRIVATE-MIB, it use single key in boxServicesTempSensorsTable
$first_key = current(array_keys($oids));
$use_fastpath_new = count(explode('.', $first_key)) > 1;
}
// Rewrite all founded FASTPATH MIBs
if ($use_fastpath_new) {
foreach ($old_fastpath_mibs as $mib) {
if (isset($mibs_found[$mib])) {
$new_mib = str_replace(array('BROADCOM', 'FASTPATH'), 'EdgeSwitch', $mib);
$mibs_found[$new_mib] = $mibs_found[$mib];
$mibs_found[$new_mib]['source'] .= ' (FASTPATH)';
unset($mibs_found[$mib]);
print_debug("FASTPATH detect hack, mib renamed: $mib -> $new_mib");
}
}
}
}
unset($new_mib, $use_fastpath_new, $data, $first_key);
/* End of FASTPATH hack */
// Now filter known MIBs and pretty print
print_cli_data_field('MIBs discovered');
$table_rows = [];
foreach ($mibs_found as $mib => $entry) {
$identity_num = $entry['identity'];
$identities_found[] = $identity_num;
if (in_array($mib, $device_mibs_bl)) {
// MIB is in our blacklist, bail out
$table_rows[] = [ $identity_num, $mib, $entry['source'], '%mMIB blacklisted%n' ];
unset($mibs_found[$mib]);
continue;
} elseif (!isset($config['mibs'][$mib])) {
// MIB is currently unsupported by Observium
$table_rows[] = [ $identity_num, $mib, $entry['source'], 'MIB not used' ];
unset($mibs_found[$mib]);
continue;
} elseif (isset($config['mibs'][$mib]['enable']) && !$config['mibs'][$mib]['enable']) {
// MIB is currently unsupported by Observium
$table_rows[] = [ $identity_num, $mib, $entry['source'], '%rMIB disabled globally%n' ];
unset($mibs_found[$mib]);
continue;
} elseif (in_array($mib, $device_mibs)) {
// Already mapped
$table_rows[] = [ $identity_num, "%y$mib%n", $entry['source'], '%yMIB already defined%n' ];
unset($mibs_found[$mib]);
continue;
}
// Checks ended, this MIB will add
echo("$mib ");
$table_rows[] = array($identity_num, "%g$mib%n", $entry['source'], '%gMIB added%n');
}
foreach ($mibs_disable as $mib => $entry) {
// MIB defined for os/model, but not discovered by snmp check
$table_rows[] = array('', "%r$mib%n", $entry['source'], '%rMIB defined for os but not found%n');
// Not correctly for cases when discovery limited with os/group
// Currently only inform
//set_device_mib_disable($device, $mib);
}
// Clean cached device mibs
if (safe_count($mibs_disable) && isset($cache['devices']['mibs_disabled'][$device['device_id']])) {
//$cache['devices']['mibs'][$device['device_id']] = array_diff($cache['devices']['mibs'][$device['device_id']], array_keys($mibs_disable));
unset($cache['devices']['mibs_disabled'][$device['device_id']]);
}
// Additionally filter found identities, just for show that exist but unknown
$identities = array_diff((array)$identities, (array)$identities_found);
foreach ($identities as $identity_num) {
$table_rows[] = array($identity_num, '-', 'sysORID', '%cUnknown Identity%n');
}
// Set device attribute if we found any new MIBs, else delete the attribute
if (count($mibs_found)) {
$sysORID_db = safe_json_decode(get_entity_attrib('device', $device, 'sysORID'));
$sysORID_mibs = array_keys($mibs_found);
$update_array = array_diff($sysORID_mibs, (array)$sysORID_db);
$delete_array = array_diff((array)$sysORID_db, $sysORID_mibs);
//print_vars($sysORID_db);
//print_vars($sysORID_mibs);
//print_vars($update_array);
//print_vars($delete_array);
if (count($update_array)) {
set_entity_attrib('device', $device, 'sysORID', safe_json_encode($sysORID_mibs));
log_event("MIBs discovered: '" . implode("', '", $update_array) . "'", $device, 'device', $device['device_id']);
// reset cache
if (isset($GLOBALS['cache']['devices']['mibs'][$device['device_id']])) {
unset($GLOBALS['cache']['devices']['mibs'][$device['device_id']]);
unset($GLOBALS['cache']['entity_attribs']['device'][$device['device_id']]['sysORID']);
}
} elseif (count($delete_array)) {
set_entity_attrib('device', $device, 'sysORID', safe_json_encode($sysORID_mibs));
log_event("MIBs removed: '" . implode("', '", $delete_array) . "'", $device, 'device', $device['device_id']);
// reset cache
if (isset($GLOBALS['cache']['devices']['mibs'][$device['device_id']])) {
unset($GLOBALS['cache']['devices']['mibs'][$device['device_id']]);
unset($GLOBALS['cache']['entity_attribs']['device'][$device['device_id']]['sysORID']);
}
}
} else {
echo('<empty>');
del_entity_attrib('device', $device, 'sysORID');
// reset cache
if (isset($GLOBALS['cache']['devices']['mibs'][$device['device_id']])) {
unset($GLOBALS['cache']['devices']['mibs'][$device['device_id']]);
unset($GLOBALS['cache']['entity_attribs']['device'][$device['device_id']]['sysORID']);
}
}
if (count($table_rows)) {
echo(PHP_EOL);
$table_headers = array('%WIdentity%n', '%WMIB%n', '%WSource%n', '%WStatus%n');
print_cli_table($table_rows, $table_headers);
}
// Need to check if module disabled?
if (FALSE) {
// sysORID table disabled, delete the attribute
del_entity_attrib('device', $device, 'sysORID');
}
print_debug_vars(get_device_mibs_permitted($device), 1);
///FIXME. This is not exactly related to mibs, but this need check before all other discovery modules
// Detect (if possible) exist snmp contexts on device (currently only on Cisco IOS, IOS-XE and NX-OS
/* DISABLED, while not know what TODO with this,
* currently same functionality only for Cisco Nexis in VRF module
if (isset($config['os'][$device['os']]['snmp']['virtual_oid']))
{
$contexts = [];
foreach (snmpwalk_values($device, $config['os'][$device['os']]['snmp']['virtual_oid'], []) as $context)
{
if ($context !== '')
{
$contexts[] = $context;
}
}
$contexts = array_unique($contexts);
print_debug_vars($contexts);
// Add non VLAN contexts to device array, for use in discovery modules
foreach ($contexts as $context)
{
// Detect Vlan specific contexts
if (preg_match('/^(vlan\-)?(?<vlan>\d{1,4})$/', $context, $matches) &&
$matches['vlan'] > 0 && $matches['vlan'] < 4096)
{
continue;
}
$device['snmp_contexts'][] = $context;
}
$contexts_db = safe_json_decode(get_entity_attrib('device', $device, 'snmp_contexts'));
print_debug_vars($contexts_db);
$update_array = array_diff($contexts, (array)$contexts_db);
print_debug_vars($update_array);
$delete_array = array_diff((array)$contexts_db, $contexts);
print_debug_vars($delete_array);
if (count($contexts_db) && empty($contexts))
{
del_entity_attrib('device', $device, 'snmp_contexts');
log_event("SNMP contexts removed.", $device, 'device', $device['device_id']);
}
elseif (count($update_array))
{
set_entity_attrib('device', $device, 'snmp_contexts', safe_json_encode($contexts));
$update_vlans = [];
foreach ($update_array as $k => $context)
{
// Detect Vlan specific contexts
if (preg_match('/^(vlan\-)?(?<vlan>\d{1,4})$/', $context, $matches) &&
$matches['vlan'] > 0 && $matches['vlan'] < 4096)
{
$update_vlans[] = $matches['vlan'];
unset($update_array[$k]);
}
}
print_debug_vars($update_vlans);
$log_msg = 'SNMP contexts found: ';
if ($update_array)
{
log_event("SNMP contexts found: '" . implode("', '", $update_array) . "'", $device, 'device', $device['device_id']);
}
if ($update_vlans)
{
log_event("SNMP contexts found: VLANs " . range_to_list(array_unique($update_vlans), ', '), $device, 'device', $device['device_id']);
}
}
elseif (count($delete_array))
{
set_entity_attrib('device', $device, 'snmp_contexts', safe_json_encode($contexts));
log_event("SNMP contexts removed: '" . implode("', '", $delete_array) . "'", $device, 'device', $device['device_id']);
}
}
*/
// EOF

View File

@ -0,0 +1,66 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
$valid['neighbours'] = array();
// SELECT * FROM `autodiscovery` WHERE `remote_device_id` IS NOT NULL AND `remote_device_id` NOT IN (SELECT `device_id` FROM `devices`)
// Include all discovery modules
$include_dir = "includes/discovery/neighbours";
include("includes/include-dir-mib.inc.php");
$table_rows = array();
$neighbours_db = dbFetchRows('SELECT * FROM `neighbours` WHERE `device_id` = ?', array($device['device_id']));
foreach ($neighbours_db as $neighbour)
{
$local_port_id = $neighbour['port_id'];
$remote_hostname = $neighbour['remote_hostname'];
$remote_address = $neighbour['remote_address'];
$remote_port = $neighbour['remote_port'];
$valid_host_key = $remote_hostname;
if (strlen($remote_address))
{
$valid_host_key .= '-' . $remote_address;
}
print_debug("$local_port_id -> $remote_hostname ($remote_address) -> $remote_port");
if (!$valid['neighbours'][$local_port_id][$valid_host_key][$remote_port])
{
// Do not remove deleted from db
//dbDelete('neighbours', '`neighbour_id` = ?', array($neighbour['neighbour_id']));
if ($neighbour['active'] == '1')
{
dbUpdate([ 'active' => 0 ], 'neighbours', '`neighbour_id` = ?', [ $neighbour['neighbour_id'] ]);
$GLOBALS['module_stats'][$module]['deleted']++;
}
} else {
$port = get_port_by_id_cache($local_port_id);
if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id'])
{
$remote_port_array = get_port_by_id_cache($neighbour['remote_port_id']);
$remote_port = $remote_port_array['port_label'];
}
if (strlen($remote_address)) { $remote_hostname .= " ($remote_address)"; }
$table_rows[] = array(nicecase($neighbour['protocol']), $port['port_label'], $remote_hostname, $remote_port, truncate($neighbour['remote_platform'], 20), truncate($neighbour['remote_version'], 40));
}
}
echo(PHP_EOL);
$table_headers = array('%WProtocol%n', '%WifName%n', '%WRemote: hostname%n', '%Wport%n', '%Wplatform%n', '%Wversion%n');
print_cli_table($table_rows, $table_headers);
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid[$module]);
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) { print_vars($valid[$module]); }
unset($valid['neighbours']);
echo(PHP_EOL);
// EOF

View File

@ -0,0 +1,15 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
include('alcatel-ind1-interswitch-protocol-mib.inc.php');
// EOF

View File

@ -0,0 +1,126 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// $mib is "ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB" or "ALCATEL-ENT1-INTERSWITCH-PROTOCOL-MIB"
// Same mib type, but different Oid tree
$amap_array = snmpwalk_cache_threepart_oid($device, "aipAMAPportConnectionTable", [], $mib, NULL, OBS_SNMP_ALL_TABLE);
if ($amap_array)
{
$amap_hosts = snmpwalk_cache_twopart_oid($device, 'aipAMAPIpAddr', [], $mib, NULL, OBS_SNMP_ALL_TABLE);
print_debug_vars($amap_array);
print_debug_vars($amap_hosts);
foreach ($amap_array as $aipAMAPLocalConnectionIndex => $entry1)
{
foreach ($entry1 as $remote_mac => $entry2)
{
foreach ($entry2 as $aipAMAPRemConnectionIndex => $amap)
{
$port = get_port_by_index_cache($device, $amap['aipAMAPLocalIfindex']);
// Remote Hostname
$remote_hostname = $amap['aipAMAPRemHostname'];
// Remote address(es)
$remote_address = NULL;
if (isset($amap_hosts[$remote_mac]))
{
// Can be multiple?
$addresses = array_keys($amap_hosts[$remote_mac]);
if (count($addresses) > 1)
{
foreach ($addresses as $addr)
{
$addr_version = get_ip_version($addr);
$addr_type = get_ip_type($addr);
if (in_array($addr_type, [ 'unspecified', 'loopback', 'reserved', 'multicast' ]))
{
continue;
}
elseif ($addr_version == 6 && $addr_type == 'link-local')
{
continue;
}
elseif ($addr_type == 'unicast')
{
// Prefer IPv4/IPv6 unicast
$remote_address = $addr;
break;
}
elseif ($addr_version == 4)
{
// Than prefer IPv4
$remote_address = $addr;
break;
}
$remote_address = $addr;
}
print_debug("Multiple remote IP addresses detect, selected: $remote_address");
} else {
$remote_address = array_shift($addresses);
}
}
$remote_device_id = FALSE;
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $remote_hostname, $remote_address, $remote_mac);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($remote_hostname, $remote_address)) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($remote_hostname, $remote_address, 'AMAP', $amap['aipAMAPRemDevModelName'], $device, $port);
}
$remote_port_id = NULL;
$if = $amap['aipAMAPRemSlot']."/".$amap['aipAMAPRemPort'];
if ($remote_device_id)
{
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
if (!$remote_port_id)
{
if (!is_null($remote_mac))
{
// By MAC
$remote_port_id = get_port_id_by_mac($remote_device_id, $remote_mac);
} else {
// Try by IP
$peer_where = generate_query_values($remote_device_id, 'device_id'); // Additional filter for include self IPs
// Fetch all ports with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $remote_address, $peer_where))
{
$remote_port_id = $ids[0];
//$port = get_port_by_id_cache($ids[0]);
}
}
}
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $remote_hostname,
'remote_port' => $amap['aipAMAPRemSlot']."/".$amap['aipAMAPRemPort'],
'remote_platform' => $amap['aipAMAPRemDevModelName'],
'remote_version' => NULL,
'remote_address' => $remote_address,
//'last_change' => $last_change
];
discover_neighbour($port, 'amap', $neighbour);
}
}
}
}
// EOF

View File

@ -0,0 +1,192 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
/*
CISCO-CDP-MIB::cdpCacheAddressType.1.0 = INTEGER: ip(1)
CISCO-CDP-MIB::cdpCacheAddress.1.0 = Hex-STRING: CD EB 52 C2
CISCO-CDP-MIB::cdpCacheVersion.1.0 = STRING: 2007656304
CISCO-CDP-MIB::cdpCacheDeviceId.1.0 = STRING: ASW10.SPN.WPA1.imdc.com
CISCO-CDP-MIB::cdpCacheDevicePort.1.0 = STRING: GigabitEthernet1/27
CISCO-CDP-MIB::cdpCachePlatform.1.0 = STRING: cisco WS-C4948-10GE
CISCO-CDP-MIB::cdpCacheCapabilities.1.0 = Hex-STRING: 00 00 00 29
CISCO-CDP-MIB::cdpCacheVTPMgmtDomain.1.0 = STRING: IMDC-1
CISCO-CDP-MIB::cdpCacheNativeVLAN.1.0 = INTEGER: 0
CISCO-CDP-MIB::cdpCacheDuplex.1.0 = INTEGER: unknown(1)
CISCO-CDP-MIB::cdpCacheApplianceID.1.0 = Gauge32: 0
CISCO-CDP-MIB::cdpCacheVlanID.1.0 = Gauge32: 0
CISCO-CDP-MIB::cdpCachePowerConsumption.1.0 = Gauge32: 0 milliwatts
CISCO-CDP-MIB::cdpCacheMTU.1.0 = Gauge32: 0
CISCO-CDP-MIB::cdpCacheSysName.1.0 = STRING: ASW10.SPN.WPA1.imdc.com
CISCO-CDP-MIB::cdpCacheSysObjectID.1.0 = OID: SNMPv2-SMI::zeroDotZero.0
CISCO-CDP-MIB::cdpCachePrimaryMgmtAddrType.1.0 = INTEGER: ip(1)
CISCO-CDP-MIB::cdpCachePrimaryMgmtAddr.1.0 = STRING: "205.235.82.194"
CISCO-CDP-MIB::cdpCacheSecondaryMgmtAddrType.1.0 = INTEGER: 0
CISCO-CDP-MIB::cdpCacheSecondaryMgmtAddr.1.0 = ""
CISCO-CDP-MIB::cdpCachePhysLocation.1.0 = STRING:
CISCO-CDP-MIB::cdpCacheLastChange.1.0 = Timeticks: (120) 0:00:01.20
CISCO-CDP-MIB::cdpGlobalLastChange.0 = Timeticks: (600708689) 69 days, 12:38:06.89
*/
$cdp_flags = OBS_SNMP_ALL_MULTILINE | OBS_SNMP_DISPLAY_HINT; // disable hints
//$cdp_flags = OBS_SNMP_ALL_NUMERIC_INDEX | OBS_SNMP_DISPLAY_HINT | OBS_SNMP_CONCAT;
$cdp_array = snmpwalk_cache_twopart_oid($device, "cdpCache", [], "CISCO-CDP-MIB", NULL, $cdp_flags);
// If we get timeout error and device has 'CISCO-FLASH-MIB', sleep and try re-walk
if (snmp_status() === FALSE && is_device_mib($device, 'CISCO-FLASH-MIB') &&
(snmp_error_code() === OBS_SNMP_ERROR_REQUEST_TIMEOUT || snmp_error_code() === OBS_SNMP_ERROR_BULK_REQUEST_TIMEOUT))
{
print_debug('Try to re-walk "CISCO-CDP-MIB"..');
sleep(5); // Additional sleep, see comments in includes/discovery/storage/cisco-flash-mib-inc.php
$cdp_array = snmpwalk_cache_twopart_oid($device, "cdpCache", $cdp_array, "CISCO-CDP-MIB", NULL, $cdp_flags);
}
print_debug_vars($cdp_array);
if ($cdp_array) {
// fetch sysUptime for correct last change
// $device_sysUptime = timeticks_to_sec(snmp_get_oid($device, "sysUpTime.0", "SNMPv2-MIB"));
// Force fetch cdpCacheAddress as HEX strings!
$cdp_array = snmpwalk_cache_twopart_oid($device, "cdpCacheAddress", $cdp_array, "CISCO-CDP-MIB", NULL, OBS_SNMP_ALL_HEX);
foreach ($cdp_array as $ifIndex => $port_neighbours) {
$port = get_port_by_index_cache($device, $ifIndex);
//$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
foreach ($port_neighbours as $cdpCacheDeviceIndex => $cdp_entry) {
// Init
$remote_mac = NULL;
$remote_hostname = '';
// Remote hostname
// NOTE. cdpCacheDeviceId have undocumented limit by 40 chars!
if (preg_match('/^([A-F\d]{2}\s?){6}$/', $cdp_entry['cdpCacheDeviceId'])) {
// HEX mac address
// cdpCacheDeviceId.3.1 = "98 90 96 D1 59 5A "
$remote_hostname = $cdp_entry['cdpCacheDeviceId'];
$remote_mac = str_replace(' ', '', $cdp_entry['cdpCacheDeviceId']);
} elseif (preg_match('/^01 (?<ip>([A-F\d]{2}\s?){4})$/', $cdp_entry['cdpCacheDeviceId'], $matches)) {
// HEX ip address
// cdpCacheDeviceId.5.2 = "01 90 7F 93 3E "
$remote_hostname = hex2ip($matches['ip']);
} else {
$remote_hostname = snmp_hexstring($cdp_entry['cdpCacheDeviceId']);
if (preg_match('/^(?:SEP|SIP|\w+\-)?([a-f\d]{12})$/i', $remote_hostname, $matches)) {
// Meraki report mac instead hostname
// Axis: axis-<mac>
// Cisco IP Phone: SEP<mac>
// SIP-<platform><mac>,
$remote_hostname = $cdp_entry['cdpCacheDeviceId'];
$remote_mac = $matches[1];
} elseif (preg_match(OBS_PATTERN_NOPRINT, $remote_hostname)) {
// Non-printable chars, seems as ID is not hostname, keep as is
$tmp = preg_replace(OBS_PATTERN_NOPRINT, '', $remote_hostname);
if (is_valid_hostname($tmp)) {
print_debug("Probably valid hostname with broken chars? '".$cdp_entry['cdpCacheDeviceId']."' => '$tmp'");
}
$remote_hostname = $cdp_entry['cdpCacheDeviceId'];
} else {
list($remote_hostname) = explode('(', $remote_hostname); // Fix for Nexus CDP neighbors: <hostname>(serial number)
}
}
$hostname_len = strlen($remote_hostname);
// cdpCacheSysName
if (isset($cdp_entry['cdpCacheSysName'])) {
$cdp_entry['cdpCacheSysName'] = snmp_hexstring($cdp_entry['cdpCacheSysName']);
$sysname_len = strlen($cdp_entry['cdpCacheSysName']);
if (is_valid_hostname($cdp_entry['cdpCacheSysName']) && $sysname_len > $hostname_len) {
$remote_hostname = $cdp_entry['cdpCacheSysName'];
} elseif ($sysname_len && preg_match('/^[a-f\d]{12}$/i', $cdp_entry['cdpCacheDeviceId'])) {
// DeviceId is mac, prefer sysName
$remote_hostname = $cdp_entry['cdpCacheSysName'];
}
}
// Remote address
$remote_address = hex2ip($cdp_entry['cdpCacheAddress']);
// Last change
/* Derp. Do not use Last change from neighbour, it's not correct for us
* (seems as changed uptime by remote host, not possible correct calculate unixtime)
$last_change = timeticks_to_sec($cdp_entry['cdpCacheLastChange']);
if ($last_change > 0)
{
$last_change = get_time() - $device_sysUptime + $last_change;
}
*/
// Remote MAC on some devices
$if = NULL;
if (preg_match('/^([A-F\d]{2}\s?){6}$/', $cdp_entry['cdpCacheDevicePort'])) {
$remote_mac = $cdp_entry['cdpCacheDevicePort'];
} else {
$cdp_entry['cdpCacheDevicePort'] = snmp_hexstring($cdp_entry['cdpCacheDevicePort']);
if (preg_match('/^[a-f\d]{12}$/i', $cdp_entry['cdpCacheDevicePort'])) {
$remote_mac = $cdp_entry['cdpCacheDevicePort'];
} else {
$if = $cdp_entry['cdpCacheDevicePort'];
}
}
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $remote_hostname, $remote_address, $remote_mac);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($remote_hostname, $remote_address)) { // Check all previous autodiscovery rounds
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($remote_hostname, $remote_address, 'CDP', $cdp_entry['cdpCachePlatform'], $device, $port);
}
$remote_port_id = NULL;
if ($remote_device_id) {
//$if = $cdp_entry['cdpCacheDevicePort'];
if (!is_null($if)) {
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
}
if (!$remote_port_id) {
if (!is_null($remote_mac)) {
// By MAC
$remote_port_id = get_port_id_by_mac($remote_device_id, $remote_mac);
} elseif (!is_null($if)) {
// Try by ifAlias
$query = 'SELECT `port_id` FROM `ports` WHERE `ifAlias` = ? AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $remote_device_id, 0));
}
if (!$remote_port_id) {
// Try by IP
$peer_where = generate_query_values($remote_device_id, 'device_id'); // Additional filter for include self IPs
// Fetch all ports with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $remote_address, $peer_where))
{
$remote_port_id = $ids[0];
//$port = get_port_by_id_cache($ids[0]);
}
}
}
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $remote_hostname,
'remote_port' => $cdp_entry['cdpCacheDevicePort'],
'remote_platform' => $cdp_entry['cdpCachePlatform'],
'remote_version' => $cdp_entry['cdpCacheVersion'],
'remote_address' => $remote_address,
//'last_change' => $last_change
];
discover_neighbour($port, 'cdp', $neighbour);
}
}
}
// EOF

View File

@ -0,0 +1,65 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
/*
DCP-LINKVIEW-MIB::dcpLinkviewLocalHostname.100111 = STRING: DCP-M40-HEID
DCP-LINKVIEW-MIB::dcpLinkviewLocalName.100111 = STRING: if-1/line-tx
DCP-LINKVIEW-MIB::dcpLinkviewLocalStatus.100111 = INTEGER: up(3)
DCP-LINKVIEW-MIB::dcpLinkviewLocalPower.100111 = INTEGER: 7.5
DCP-LINKVIEW-MIB::dcpLinkviewFiberLoss.100111 = Gauge32: 16.7
DCP-LINKVIEW-MIB::dcpLinkviewFiberAttenuation.100111 = Gauge32: .29
DCP-LINKVIEW-MIB::dcpLinkviewFiberLength.100111 = Gauge32: 55.4
DCP-LINKVIEW-MIB::dcpLinkviewFiberDispersion.100111 = Gauge32: 924
DCP-LINKVIEW-MIB::dcpLinkviewFiberType.100111 = STRING: G.652
DCP-LINKVIEW-MIB::dcpLinkviewFiberDispComp.100111 = INTEGER: -918
DCP-LINKVIEW-MIB::dcpLinkviewFiberDispFinal.100111 = INTEGER: 0
DCP-LINKVIEW-MIB::dcpLinkviewFiberUtilization.100111 = Gauge32: 5
DCP-LINKVIEW-MIB::dcpLinkviewRemotePower.100111 = INTEGER: -9.2
DCP-LINKVIEW-MIB::dcpLinkviewRemoteName.100111 = STRING: if-1/line-rx
DCP-LINKVIEW-MIB::dcpLinkviewRemoteHostname.100111 = STRING: DCP-M40-W379
*/
$dcp_array = snmp_cache_table($device, 'dcpLinkviewTable', [], $mib);
print_debug_vars($dcp_array);
foreach ($dcp_array as $ifIndex => $dcp) {
if ($dcp['dcpLinkviewLocalStatus'] !== 'up') { continue; }
$port = get_port_by_index_cache($device, $ifIndex);
$remote_hostname = $dcp['dcpLinkviewRemoteHostname'];
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $remote_hostname);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($remote_hostname)) { // Check all previous autodiscovery rounds
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($remote_hostname, NULL, 'DCP', '', $device, $port);
}
$remote_port_id = NULL;
if ($remote_device_id) {
$if = $dcp['dcpLinkviewRemoteName'];
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $remote_hostname,
'remote_port' => $dcp['dcpLinkviewRemoteName'],
'remote_platform' => '',
'remote_version' => '',
];
discover_neighbour($port, 'dcp', $neighbour);
}
// EOF

View File

@ -0,0 +1,26 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// DNOS-ISDP-MIB::agentIsdpCacheAddress.50.1 = STRING: "0.0.0.0"
// DNOS-ISDP-MIB::agentIsdpCacheLocalIntf.50.1 = STRING: "Fo1/0/2"
// DNOS-ISDP-MIB::agentIsdpCacheVersion.50.1 = STRING: "6.3.3.10"
// DNOS-ISDP-MIB::agentIsdpCacheDeviceId.50.1 = STRING: "dc-cores-n4032f"
// DNOS-ISDP-MIB::agentIsdpCacheDevicePort.50.1 = STRING: "Fo2/1/2"
// DNOS-ISDP-MIB::agentIsdpCachePlatform.50.1 = STRING: "N4032F"
// DNOS-ISDP-MIB::agentIsdpCacheCapabilities.50.1 = STRING: "Router "
// DNOS-ISDP-MIB::agentIsdpCacheLastChange.50.1 = Timeticks: (924574000) 107 days, 0:15:40.00
// DNOS-ISDP-MIB::agentIsdpCacheProtocolVersion.50.1 = STRING: "2"
// DNOS-ISDP-MIB::agentIsdpCacheHoldtime.50.1 = INTEGER: -83 seconds
include(__DIR__ . "/isdp-mib.inc.php");
// EOF

View File

@ -0,0 +1,29 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// EdgeSwitch-ISDP-MIB::agentIsdpCacheAddress.25.1 = STRING: "119.59.109.140"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheLocalIntf.25.1 = STRING: "0/25"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheVersion.25.1 = STRING: "Cisco IOS Software, C3560E Software (C3560E-UNIVERSALK9-M), Version 15.0(2)SE11, RELEASE SOFTWARE (fc3)
// Technical Support: http://www.cisco.com/techsupport
// Copyright (c) 1986-2017 by Cisco Systems, Inc.
// Compiled Sat 19-Aug-17 09:04 by prod_rel_team"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheDeviceId.25.1 = STRING: "Cisco3560E-10G-Rack207.metrabyte.net"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheDevicePort.25.1 = STRING: "GigabitEthernet0/32"
// EdgeSwitch-ISDP-MIB::agentIsdpCachePlatform.25.1 = STRING: "cisco WS-C3560E-48TD"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheCapabilities.25.1 = STRING: "Switch IGMP "
// EdgeSwitch-ISDP-MIB::agentIsdpCacheLastChange.25.1 = Timeticks: (1581770900) 183 days, 1:48:29.00
// EdgeSwitch-ISDP-MIB::agentIsdpCacheProtocolVersion.25.1 = STRING: "2"
// EdgeSwitch-ISDP-MIB::agentIsdpCacheHoldtime.25.1 = INTEGER: 120 seconds
include(__DIR__ . "/isdp-mib.inc.php");
// EOF

View File

@ -0,0 +1,15 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
include("isdp-mib.inc.php");
// EOF

View File

@ -0,0 +1,73 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
$fdp_array = snmpwalk_cache_twopart_oid($device, "snFdpCacheEntry", [], "FOUNDRY-SN-SWITCH-GROUP-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($fdp_array);
if ($fdp_array)
{
foreach ($fdp_array as $ifIndex => $entry)
{
$port = get_port_by_index_cache($device, $ifIndex);
foreach ($entry as $fdp)
{
// Remote Hostname
$remote_hostname = $fdp['snFdpCacheDeviceId'];
// Remote address
$remote_address = hex2ip($fdp['snFdpCacheAddress']);
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $remote_hostname, $remote_address);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($remote_hostname, $remote_address)) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($remote_hostname, $remote_address, 'FDP', $fdp['snFdpCachePlatform'], $device, $port);
}
$remote_port_id = NULL;
$if = $fdp['snFdpCacheDevicePort'];
if ($remote_device_id)
{
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
if (!$remote_port_id)
{
// Try by IP
$peer_where = generate_query_values($remote_device_id, 'device_id'); // Additional filter for include self IPs
// Fetch all ports with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $remote_address, $peer_where))
{
$remote_port_id = $ids[0];
//$port = get_port_by_id_cache($ids[0]);
}
}
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $remote_hostname,
'remote_port' => $fdp['snFdpCacheDevicePort'],
'remote_platform' => $fdp['snFdpCachePlatform'],
'remote_version' => $fdp['snFdpCacheVersion'],
'remote_address' => $remote_address,
//'last_change' => $last_change
];
discover_neighbour($port, 'fdp', $neighbour);
}
}
}
// EOF

View File

@ -0,0 +1,93 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// This is generic *-ISDP-MIB discovery.
$isdp_array = snmpwalk_cache_twopart_oid($device, 'agentIsdpCacheTable', [], $mib, NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($isdp_array);
if ($isdp_array) {
foreach ($isdp_array as $ifIndex => $port_neighbours) {
//$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ifIndex));
$port = get_port_by_index_cache($device, $ifIndex);
foreach ($port_neighbours as $entry_id => $isdp) {
if (safe_empty($isdp['agentIsdpCacheDevicePort']) && safe_empty($isdp['agentIsdpCachePlatform']) &&
safe_empty($isdp['agentIsdpCacheAddress']) && safe_empty($isdp['agentIsdpCacheVersion'])) {
// All neighbour fields is empty, ignore
print_debug("Neighbour ignored: proto[isdp], ".$isdp['agentIsdpCacheDeviceId']);
continue;
}
// Normally not possible, but I keep this ability for search local port
if (!$port && strlen($isdp['agentIsdpCacheLocalIntf'])) {
$if = $isdp['agentIsdpCacheLocalIntf'];
$query = 'SELECT * FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$port = dbFetchRow($query, array($if, $if, $if, $device['device_id'], 0));
}
// Remote Hostname
list($isdp['agentIsdpCacheDeviceId']) = explode('(', $isdp['agentIsdpCacheDeviceId']); // Fix for Nexus ISDP neighbors: <hostname>(serial number)
$remote_hostname = trim($isdp['agentIsdpCacheDeviceId']);
// Remote address
$remote_address = hex2ip($isdp['agentIsdpCacheAddress']);
// Last change
$last_change = timeticks_to_sec($isdp['agentIsdpCacheLastChange']);
if ($last_change > 0)
{
$last_change = get_time() - $last_change;
}
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $remote_hostname, $remote_address);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($remote_hostname, $remote_address)) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($remote_hostname, $remote_address, 'ISDP', $isdp['agentIsdpCachePlatform'], $device, $port);
}
$remote_port_id = NULL;
$if = $isdp['agentIsdpCacheDevicePort'];
if ($remote_device_id)
{
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
if (!$remote_port_id)
{
// Try by IP
$peer_where = generate_query_values($remote_device_id, 'device_id'); // Additional filter for include self IPs
// Fetch all ports with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $remote_address, $peer_where))
{
$remote_port_id = $ids[0];
//$port = get_port_by_id_cache($ids[0]);
}
}
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $remote_hostname,
'remote_port' => $isdp['agentIsdpCacheDevicePort'],
'remote_platform' => $isdp['agentIsdpCachePlatform'],
'remote_version' => $isdp['agentIsdpCacheVersion'],
'remote_address' => $remote_address,
'last_change' => $last_change
];
discover_neighbour($port, 'isdp', $neighbour);
}
}
}
// EOF

View File

@ -0,0 +1,434 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// lldpRemoteSystemsData: lldpRemTable + lldpRemManAddrTable + lldpRemUnknownTLVTable + lldpRemOrgDefInfoTable
$lldpRemTable_oids = array('lldpRemChassisIdSubtype', 'lldpRemChassisId',
'lldpRemPortIdSubtype', 'lldpRemPortId', 'lldpRemPortDesc',
'lldpRemSysName');
$lldp_array = array();
foreach ($lldpRemTable_oids as $oid) {
//$lldp_array = snmpwalk_cache_threepart_oid($device, $oid, $lldp_array, "LLDP-MIB");
$lldp_array = snmpwalk_cache_oid($device, $oid, $lldp_array, "LLDP-MIB");
if (empty($lldp_array)) { break; } // Stop walk if no data
}
if ($lldp_array) {
// lldpRemSysDesc can be multiline
//$lldp_array = snmpwalk_cache_threepart_oid($device, 'lldpRemPortDesc', $lldp_array, "LLDP-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
//$lldp_array = snmpwalk_cache_threepart_oid($device, 'lldpRemSysDesc', $lldp_array, "LLDP-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
$lldp_array = snmpwalk_cache_oid($device, 'lldpRemSysDesc', $lldp_array, "LLDP-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
if (is_device_mib($device, 'LLDP-EXT-MED-MIB')) {
// See Cumulus Linux
// not exist lldpRemSysName, lldpRemSysDesc
$lldp_array = snmpwalk_cache_oid($device, 'lldpXMedRemSoftwareRev', $lldp_array, "LLDP-EXT-MED-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
$lldp_array = snmpwalk_cache_oid($device, 'lldpXMedRemMfgName', $lldp_array, "LLDP-EXT-MED-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
$lldp_array = snmpwalk_cache_oid($device, 'lldpXMedRemModelNam', $lldp_array, "LLDP-EXT-MED-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
}
// lldpRemManAddrTable
// Case 1:
// LLDP-MIB::lldpRemManAddrSubtype.120.30001.1582.1.4.10.133.3.10 = INTEGER: ipV4(1)
// LLDP-MIB::lldpRemManAddr.120.30001.1582.1.4.10.133.3.10 = Hex-STRING: 0A 85 03 0A
// LLDP-MIB::lldpRemManAddrIfSubtype.120.30001.1582.1.4.10.133.3.10 = INTEGER: ifIndex(2)
// LLDP-MIB::lldpRemManAddrIfId.120.30001.1582.1.4.10.133.3.10 = INTEGER: 2009
// LLDP-MIB::lldpRemManAddrOID.120.30001.1582.1.4.10.133.3.10 = OID: SNMPv2-SMI::zeroDotZero.0
// Case 2:
// LLDP-MIB::lldpRemManAddrIfSubtype.1173570000.129.2.1.4.10.0.10.5 = INTEGER: unknown(1)
// LLDP-MIB::lldpRemManAddrIfSubtype.1173834000.4.6.0.6.132.181.156.89.235.128 = INTEGER: unknown(1)
// LLDP-MIB::lldpRemManAddrIfId.1173570000.129.2.1.4.10.0.10.5 = INTEGER: 0
// LLDP-MIB::lldpRemManAddrIfId.1173834000.4.6.0.6.132.181.156.89.235.128 = INTEGER: 0
// LLDP-MIB::lldpRemManAddrOID.1173570000.129.2.1.4.10.0.10.5 = OID: SNMPv2-SMI::enterprises.14823.2.2.1.2.1.1
// LLDP-MIB::lldpRemManAddrOID.1173834000.4.6.0.6.132.181.156.89.235.128 = OID: SNMPv2-SMI::enterprises.14823.2.2.1.2.1.7
// Case 3:
// LLDP-MIB::lldpRemManAddrIfId.0.2.1.1.4.10.137.41.4 = INTEGER: 0
// LLDP-MIB::lldpRemManAddrIfId.0.3.1.1.4.10.137.41.57 = INTEGER: 2009
// LLDP-MIB::lldpRemManAddrIfId.0.47.1.1.4.10.137.41.19 = INTEGER: 2009
// LLDP-MIB::lldpRemManAddrIfId.0.49.3.1.4.10.129.2.171 = INTEGER: 34
// LLDP-MIB::lldpRemManAddrIfId.0.49.3.2.16.42.2.32.40.255.0.0.0.0.0.0.1.0.0.1.113 = INTEGER: 34
// LLDP-MIB::lldpRemManAddrIfId.0.49.4.1.4.10.129.2.171 = INTEGER: 19
// LLDP-MIB::lldpRemManAddrIfId.0.49.4.2.16.42.2.32.40.255.0.0.0.0.0.0.1.0.0.1.113 = INTEGER: 19
// LLDP-MIB::lldpRemManAddrIfId.0.53.2.1.4.10.129.2.171 = INTEGER: 23
// LLDP-MIB::lldpRemManAddrIfId.0.53.2.2.16.42.2.32.40.255.0.0.0.0.0.0.1.0.0.1.113 = INTEGER: 23
// Case 4:
// LLDP-MIB::lldpRemManAddrSubtype.22 = INTEGER: ipV4(1)
// LLDP-MIB::lldpRemManAddrSubtype.86 = INTEGER: ipV6(2)
// LLDP-MIB::lldpRemManAddr.22 = STRING: "10.31.0.2"
// LLDP-MIB::lldpRemManAddr.86 = STRING: "fe80::d6ca:6dff:fe8e:8b3f"
// Case 5 (multiple IP addresses):
// lldpRemManAddrIfId.31300.2.2.1.4.192.168.13.1 = 5
// lldpRemManAddrIfId.31300.2.2.2.16.32.1.4.112.0.40.11.253.0.0.0.0.0.0.0.0 = 5
// lldpRemManAddrIfId.31300.2.2.2.16.254.128.0.0.0.0.0.0.198.173.52.255.254.216.108.126 = 5
$lldp_addr = snmpwalk_cache_oid($device, 'lldpRemManAddrIfId', [], "LLDP-MIB", NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
$lldp_addr = snmpwalk_cache_oid($device, 'lldpRemManAddr', $lldp_addr, "LLDP-MIB", NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
foreach ($lldp_addr as $index => $entry) {
if (isset($lldp_array[$index])) {
$lldp_array[$index] = array_merge($lldp_array[$index], $entry);
if (isset($entry['lldpRemManAddr'])) {
$addr = hex2ip($entry['lldpRemManAddr']);
$lldp_array[$index]['lldpRemMan'][$addr] = $entry; // For multiple entries
}
continue;
}
$index_array = explode('.', $index);
// LLDP index
$lldpRemTimeMark = array_shift($index_array);
$lldpRemLocalPortNum = array_shift($index_array);
$lldpRemIndex = array_shift($index_array);
$lldp_index = "$lldpRemTimeMark.$lldpRemLocalPortNum.$lldpRemIndex";
if (!isset($lldp_array[$lldp_index])) {
continue;
}
$lldp_array[$lldp_index] = array_merge($lldp_array[$lldp_index], $entry);
// Already exist Oid, just merge
// if (isset($entry['lldpRemManAddr']))
// {
// continue;
// }
// Convert from index part
$lldpAddressFamily = array_shift($index_array);
$len = array_shift($index_array);
$addr = implode('.', $index_array);
if (isset($entry['lldpRemManAddr'])) {
// Already exist Oid, just merge
$addr = hex2ip($entry['lldpRemManAddr']);
//continue;
} elseif ($lldpAddressFamily == 1 || $len == 4) {
// IPv4, ie: 4.10.129.2.171
$lldp_array[$lldp_index]['lldpRemManAddr'] = $addr;
} elseif ($lldpAddressFamily == 2 || $len == 16) {
// IPv6, ie: 16.42.2.32.40.255.0.0.0.0.0.0.1.0.0.1.113
$addr = snmp2ipv6($addr);
$lldp_array[$lldp_index]['lldpRemManAddr'] = $addr;
} elseif ($lldpAddressFamily == 0 && $len == 6) {
// Hrm, I really not know what is this, ie, seems as MAC address:
// 6 132.181.156.89.235.128 84:B5:9C:59:EB:80
continue;
}
$lldp_array[$lldp_index]['lldpRemMan'][$addr] = $entry; // For multiple entries
}
}
print_debug_vars($lldp_array, 1);
if ($lldp_array) {
$dot1d_array = snmp_cache_table($device, "dot1dBasePortIfIndex", array(), "BRIDGE-MIB");
//$lldp_local_array = snmpwalk_cache_oid($device, "lldpLocalSystemData", array(), "LLDP-MIB");
$lldp_local_array = snmpwalk_cache_oid($device, "lldpLocPortEntry", array(), "LLDP-MIB");
foreach ($lldp_array as $index => $lldp) {
if (str_contains_array($index, '.')) {
// This is correct RFC case:
// LLDP-MIB::lldpRemChassisIdSubtype.0.0.1 = INTEGER: macAddress(4)
list($lldpRemTimeMark, $lldpRemLocalPortNum, $lldpRemIndex) = explode('.', $index);
} else {
// Incorrect case (ie on old RouterOS):
// LLDP-MIB::lldpRemChassisIdSubtype.1495 = INTEGER: macAddress(4)
$lldpRemTimeMark = 0;
$lldpRemLocalPortNum = 0;
$lldpRemIndex = $index;
}
// Detect local device port
$port = NULL;
// Prefer by LLDP-MIB
if (!$port && !empty($lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortDesc'])) {
//lldpLocPortIdSubtype.15 = interfaceName
//lldpLocPortIdSubtype.16 = interfaceName
//lldpLocPortId.15 = "Te1/15"
//lldpLocPortId.16 = "Te1/16"
//lldpLocPortDesc.15 = TenGigabitEthernet1/15
//lldpLocPortDesc.16 = TenGigabitEthernet1/16
$ifName = $lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortDesc'];
if ($ifName === 'OOBM') {
// procurve:
// ifDescr.5481 = Out Of Band Management Port
// ifDescr.5492 = Out Of Band Management loopback Interface
// ifName.5481 = oobm0
// ifName.5492 = lo0
// lldpLocPortIdSubtype.4000 = local
// lldpLocPortId.4000 = "4000"
// lldpLocPortDesc.4000 = OOBM
$ifName .= '0';
}
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND (`ifName`= ? OR `ifDescr` = ? OR `port_label_short` = ?)", [ $device['device_id'], 0, $ifName, $ifName, $ifName ]);
}
// By BRIDGE-MIB (Warning, seems as more hard on multiple platforms not correctly association with ifIndex for LLDP)
if (!$port && is_numeric($dot1d_array[$lldpRemLocalPortNum]['dot1dBasePortIfIndex']) &&
!in_array($device['os'], [ 'junos', 'dell-os10' ])) { // Incorrect association on this platforms
// Get the port using BRIDGE-MIB
$ifIndex = $dot1d_array[$lldpRemLocalPortNum]['dot1dBasePortIfIndex'];
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", [ $device['device_id'], 0, $ifIndex ]);
}
// last try by lldpLocPortId, also see below for remote port
if (!$port) {
switch ($lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortIdSubtype']) {
case 'interfaceName':
$ifName = snmp_hexstring($lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortId']);
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?)", [ $device['device_id'], 0, $ifName, $ifName, $ifName ]);
break;
case 'interfaceAlias':
$ifAlias = snmp_hexstring($lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortId']);
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND `ifAlias` = ?", [ $device['device_id'], 0, $ifAlias ]);
break;
case 'macAddress':
$ifPhysAddress = strtolower(str_replace(' ', '', $lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortId']));
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND `ifPhysAddress` = ?", [ $device['device_id'], 0, $ifPhysAddress ]);
break;
case 'networkAddress':
$ip = snmp_hexstring($lldp_local_array[$lldpRemLocalPortNum]['lldpLocPortId']);
/*
$ip_version = get_ip_version($id);
if ($ip_version)
{
$ip = ($ip_version === 6 ? Net_IPv6::uncompress($id, TRUE) : $id);
$port = dbFetchRow("SELECT * FROM `ipv".$ip_version."_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv".$ip_version."_address` = ? AND `device_id` = ?", array($ip, $device['device_id']));
}
unset($id, $ip);
*/
$peer_where = generate_query_values($device['device_id'], 'device_id'); // Additional filter for include self IPs
// Fetch all devices with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $ip, $peer_where)) {
$port = get_port_by_id_cache($ids[0]);
}
break;
}
}
// Ohh still unknown port? this is not should happen, but this derp LLDP implementation on your device
if (!$port && is_numeric($lldpRemLocalPortNum)) {
print_debug('WARNING. Local port for neighbour not found, used incorrect lldpRemLocalPortNum as ifIndex.');
$ifIndex = $lldpRemLocalPortNum; // This is incorrect, not really ifIndex, but seems sometime this numbers same
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", [ $device['device_id'], 0, $ifIndex ]);
}
$remote_device_id = FALSE;
$remote_port_id = NULL;
// Sometime lldpRemPortDesc is not set
if (!isset($lldp['lldpRemPortDesc'])) {
$lldp['lldpRemPortDesc'] = '';
}
$remote_mac = $lldp['lldpRemChassisIdSubtype'] === 'macAddress' ? $lldp['lldpRemChassisId'] : NULL;
// lldpRemPortId can be hex string
if ($lldp['lldpRemPortIdSubtype'] !== 'macAddress') {
// On Extreme platforms, they remove the leading 1: from ports. Put it back if there isn't a :.
if (preg_match ('/^ExtremeXOS.*$/', $lldp['lldpRemSysDesc'])) {
if (!preg_match ('/\:/',$lldp['lldpRemPortId'])) {
$lldp['lldpRemPortId'] = '1:'.$lldp['lldpRemPortId'];
}
} else {
//$lldp['lldpRemPortId'] = snmp_hexstring($lldp['lldpRemPortId']);
}
} elseif (safe_empty($remote_mac)) {
$remote_mac = $lldp['lldpRemPortId'];
}
// Clean MAC & IP
if (isset($lldp['lldpRemMan']) && count($lldp['lldpRemMan']) > 1) {
// Multiple IP addresses.. detect best?
foreach (array_keys($lldp['lldpRemMan']) as $addr) {
$addr_version = get_ip_version($addr);
$addr_type = get_ip_type($addr);
if (in_array($addr_type, [ 'unspecified', 'loopback', 'reserved', 'multicast' ])) {
continue;
}
if ($addr_version == 6 && $addr_type === 'link-local') {
continue;
}
if ($addr_type === 'unicast') {
// Prefer IPv4/IPv6 unicast
$lldp['lldpRemManAddr'] = $addr;
break;
}
if ($addr_version == 4) {
// Than prefer IPv4
$lldp['lldpRemManAddr'] = $addr;
break;
}
$lldp['lldpRemManAddr'] = $addr;
}
print_debug("Multiple remote IP addresses detect, selected: $addr");
print_debug_vars($lldp);
}
if (isset($lldp['lldpRemManAddr'])) {
$lldp['lldpRemManAddr'] = hex2ip($lldp['lldpRemManAddr']);
}
// Cumulus Linux have empty lldpRemSysDesc
if (!isset($lldp['lldpRemSysDesc']) && isset($lldp['lldpXMedRemModelName'])) {
$lldp['lldpRemSysDesc'] = trim($lldp['lldpXMedRemMfgName'] . ' ' . $lldp['lldpXMedRemModelName']);
}
$lldp['lldpRemSysVersion'] = safe_empty($lldp['lldpXMedRemSoftwareRev']) ? NULL : $lldp['lldpXMedRemSoftwareRev'];
// Remote sysname is MAC in some cases
// lldpRemChassisIdSubtype.0.16.1 = macAddress
// lldpRemChassisId.0.16.1 = "40 E3 D6 CE 8A 9A "
// lldpRemPortIdSubtype.0.16.1 = macAddress
// lldpRemPortId.0.16.1 = "40 E3 D6 CE 8A 9A "
// lldpRemSysName.0.16.1 = 40:e3:d6:ce:8a:9a
// lldpRemManAddrIfId.0.16.1.1.4.10.10.14.132 = 8
if (preg_match('/^[a-f\d]{2}([: ][a-f\d]{2}){5}$/', $lldp['lldpRemSysName']) && get_ip_version($lldp['lldpRemManAddr'])) {
// Replace by IP address for better discovery
print_debug("LLDP hostname replaced: ".$lldp['lldpRemSysName']." -> ".$lldp['lldpRemManAddr']);
$lldp['lldpRemSysName'] = $lldp['lldpRemManAddr'];
} elseif (safe_empty($lldp['lldpRemSysName']) && !safe_empty($lldp['lldpRemSysDesc'])) {
if ($lldp['lldpRemChassisIdSubtype'] === 'macAddress') {
// use mac address instead empty hostname:
// lldpRemChassisIdSubtype.89.3.1 = macAddress
// lldpRemChassisId.89.3.1 = "6C B0 CE 12 A9 A8 "
// lldpRemPortIdSubtype.89.3.1 = local
// lldpRemPortId.89.3.1 = "g25"
// lldpRemPortDesc.89.3.1 = g25
// lldpRemSysName.89.3.1 =
// lldpRemSysDesc.89.3.1 = GS724Tv4 ProSafe 24-port Gigabit Ethernet Smart Switch, 6.3.1.4, B1.0.0.4
// lldpRemManAddrIfId.89.3.1.1.4.192.168.0.239 = 51
$lldp['lldpRemSysName'] = str_replace(array( ' ', '-' ), '', strtolower($lldp['lldpRemChassisId']));
} elseif ($lldp['lldpRemChassisIdSubtype'] === 'networkAddress' &&
preg_match('/^01 (?<ip>([A-F\d]{2}\s?){4})$/', $lldp['lldpRemChassisId'], $matches)) {
$lldp['lldpRemSysName'] = hex2ip($matches['ip']);
}
}
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $lldp['lldpRemSysName'], $lldp['lldpRemManAddr'], $remote_mac);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($lldp['lldpRemSysName'], $lldp['lldpRemManAddr'])) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($lldp['lldpRemSysName'], $lldp['lldpRemManAddr'], 'LLDP', $lldp['lldpRemSysDesc'], $device, $port);
}
if ($remote_device_id) {
$if = $lldp['lldpRemPortDesc'];
$id = trim($lldp['lldpRemPortId']);
// lldpPortIdSubtype -> lldpPortId
// interfaceAlias(1), -> ifAlias
// portComponent(2), -> entPhysicalAlias
// macAddress(3), -> ifPhysAddress
// networkAddress(4), -> IP address
// interfaceName(5), -> ifName
// agentCircuitId(6), -> agent-local identifier of the circuit (defined in RFC 3046) (FIXME, not know)
// local(7) -> ifIndex
switch ($lldp['lldpRemPortIdSubtype'])
{
case 'interfaceAlias':
$remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifAlias` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?", [ $id, $if, $if, $remote_device_id, 0 ]);
break;
case 'interfaceName':
// Try lldpRemPortId
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($id, $id, $id, $remote_device_id, 0));
if (!$remote_port_id && strlen($if))
{
// Try same by lldpRemPortDesc
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
}
break;
case 'macAddress':
$remote_port_id = get_port_id_by_mac($remote_device_id, $id);
break;
case 'networkAddress':
$ip_version = get_ip_version($id);
if ($ip_version)
{
// Try by IP
$peer_where = generate_query_values($remote_device_id, 'device_id'); // Additional filter for include self IPs
// Fetch all devices with peer IP and filter by UP
if ($ids = get_entity_ids_ip_by_network('port', $id, $peer_where))
{
$remote_port_id = $ids[0];
//$port = get_port_by_id_cache($ids[0]);
}
}
break;
case 'local':
// local not always ifIndex or FIXME (see: http://jira.observium.org/browse/OBSERVIUM-1716)
if (!ctype_digit($id))
{
// Not sure what should be if $id ifName and it just numeric
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($id, $id, $id, $remote_device_id, 0));
if (!$remote_port_id)
{
// Try same by lldpRemPortDesc
$remote_port_id = dbFetchCell($query, array($if, $if, $if, $remote_device_id, 0));
}
}
case 'ifIndex':
// These cases are handled by the ifDescr/ifIndex combination fallback below
break;
default:
break;
}
if (!$remote_port_id && is_numeric($id)) // Not found despite our attempts above - fall back to try matching with ifDescr/ifIndex
{
$remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifIndex`= ? OR `ifDescr` = ?) AND `device_id` = ? AND `deleted` = ?", array($id, $if, $remote_device_id, 0));
}
if (!$remote_port_id) // Still not found?
{
if ($lldp['lldpRemChassisIdSubtype'] === 'macAddress')
{
// Find the port by chassis MAC address, only use this if exactly 1 match is returned, otherwise we'd link wrongly - think switches with 1 global MAC on all ports.
$remote_port_id = get_port_id_by_mac($remote_device_id, $lldp['lldpRemChassisId']);
} else {
// Last chance
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` IN (?, ?) OR `ifDescr` IN (?, ?) OR `port_label_short` IN (?, ?)) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, array($id, $if, $id, $if, $id, $if, $remote_device_id, 0));
}
}
// Still not found? Seems as incorrect remote device :/
if (!$remote_port_id)
{
print_debug("WARNING. Remote device found in db, but remote port not found. Seems as incorrect remote device association.");
}
}
// FIXME. We can use lldpRemSysCapEnabled as platform, but they use BITS textual conversion:
// LLDP-MIB::lldpRemSysCapEnabled.0.5.3 = BITS: 20 00 bridge(2)
// LLDP-MIB::lldpRemSysCapEnabled.0.5.3 = "20 00 "
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $lldp['lldpRemSysName'],
'remote_port' => $lldp['lldpRemPortId'],
'remote_platform' => $lldp['lldpRemSysDesc'],
'remote_version' => $lldp['lldpRemSysVersion'], //NULL,
'remote_address' => $lldp['lldpRemManAddr']
];
discover_neighbour($port, 'lldp', $neighbour);
}
}
// EOF

View File

@ -0,0 +1,159 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// mtxrNeighborIpAddress.1 = IpAddress: 192.168.4.27
// mtxrNeighborMacAddress.1 = STRING: 0:23:ac:53:3:28
// mtxrNeighborVersion.1 = STRING: Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(1)SE2, RELEASE SOFTWARE (fc3)
// Technical Support: http://www.cisco.com/techsupport
// Copyright (c) 1986-2011 by Cisco Systems, Inc.
// Compiled Thu 22-Dec-11 00:46 by prod_rel_team
// mtxrNeighborPlatform.1 = STRING: cisco WS-C2960G-48TC-L
// mtxrNeighborIdentity.1 = STRING: switch.example.com
// mtxrNeighborSoftwareID.1 = STRING:
// mtxrNeighborInterfaceID.1 = INTEGER: 2
/*
MIKROTIK-MIB:
[1502] => array(
[mtxrNeighborIpAddress] => string(11) "10.24.99.65"
[mtxrNeighborMacAddress] => string(15) "0:4:56:ef:f1:c9"
[mtxrNeighborVersion] => string(5) "3.5.2"
[mtxrNeighborPlatform] => string(18) "5G Force 200 (ROW)"
[mtxrNeighborIdentity] => string(20) "Fortuna_Skladskaya28"
[mtxrNeighborSoftwareID] => string(10) "MAC-Telnet"
[mtxrNeighborInterfaceID] => string(1) "9"
)
LLDP-MIB:
[1502] => array(
[lldpRemChassisIdSubtype] => string(10) "macAddress"
[lldpRemChassisId] => string(17) "00:04:56:EF:F1:C9"
[lldpRemPortIdSubtype] => string(13) "interfaceName"
[lldpRemPortId] => string(9) "br-lan.98"
[lldpRemSysName] => string(20) "Fortuna_Skladskaya28"
[lldpRemManAddr] => string(11) "10.24.99.65"
[lldpRemSysDesc] => string(0) ""
)
*/
$mtxr_array = snmpwalk_cache_oid($device, "mtxrNeighbor", array(), "MIKROTIK-MIB", NULL, OBS_SNMP_ALL | OBS_SNMP_CONCAT);
if ($mtxr_array)
{
print_debug_vars($mtxr_array);
// Extend remote port names by discovery in LLDP-MIB (but do not use this MIB self, mikrotik not reports local port there)
$lldp_array = snmpwalk_cache_oid($device, 'lldpRemChassisId', [], "LLDP-MIB");
if (snmp_status())
{
$lldp_array = snmpwalk_cache_oid($device, 'lldpRemPortIdSubtype', $lldp_array, "LLDP-MIB");
$lldp_array = snmpwalk_cache_oid($device, 'lldpRemPortId', $lldp_array, "LLDP-MIB");
$lldp_array = snmpwalk_cache_oid($device, 'lldpRemSysDesc', $lldp_array, "LLDP-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($lldp_array);
}
foreach ($mtxr_array as $key => $entry)
{
if (isset($lldp_array[$key]))
{
// older fw versions
$entry = array_merge($entry, $lldp_array[$key]);
}
elseif (isset($lldp_array['0.0.'.$key]))
{
// latest fw versions
$entry = array_merge($entry, $lldp_array['0.0.'.$key]);
}
// Need to straighten out the MAC first for use later. Mikrotik does not pad the numbers! (i.e. 0:12:23:3:5c:6b)
//$remote_mac = mac_zeropad($entry['mtxrNeighborMacAddress']);
$entry['mtxrNeighborMacAddress'] = format_mac($entry['mtxrNeighborMacAddress']);
// Note, mtxrNeighborInterfaceID really hex number, ie:
// mtxrNeighborInterfaceID.1 = a
$ifIndex = hexdec($entry['mtxrNeighborInterfaceID']);
$remote_platform = strlen($entry['mtxrNeighborPlatform']) ? $entry['mtxrNeighborPlatform'] : $entry['lldpRemSysDesc'];
$remote_port = strlen($entry['lldpRemPortId']) ? $entry['lldpRemPortId'] : format_mac($entry['mtxrNeighborMacAddress'], ' ');
// Get the port using BRIDGE-MIB (Why without Vlan?)
//$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ? AND `ifDescr` NOT LIKE 'Vlan%'", array($device['device_id'], $ifIndex));
$port = get_port_by_index_cache($device, $ifIndex);
$remote_device_id = NULL;
$remote_port_id = NULL;
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $entry['mtxrNeighborIdentity'], $entry['mtxrNeighborIpAddress'], $entry['mtxrNeighborMacAddress']);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($entry['mtxrNeighborIdentity'], $entry['mtxrNeighborIpAddress'])) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($entry['mtxrNeighborIdentity'], $entry['mtxrNeighborIpAddress'], 'MNDP', $remote_platform, $device, $port);
}
if ($remote_device_id)
{
// Detect remote port by LLDP
if (strlen($entry['lldpRemPortId']))
{
$id = $entry['lldpRemPortId'];
switch ($entry['lldpRemPortIdSubtype'])
{
case 'interfaceAlias':
$remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `ifAlias` = ? AND `device_id` = ?", [ $id, $remote_device_id ]);
break;
case 'interfaceName':
// Try lldpRemPortId
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ?';
$remote_port_id = dbFetchCell($query, [ $id, $id, $id, $remote_device_id ]);
break;
case 'macAddress':
$remote_port_id = get_port_id_by_mac($remote_device_id, $id);
break;
case 'networkAddress':
$ip_version = get_ip_version($id);
if ($ip_version)
{
$ip = ip_uncompress($id);
$remote_port_id = dbFetchCell("SELECT `port_id` FROM `ipv" . $ip_version . "_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv" . $ip_version . "_address` = ? AND `device_id` = ?",
[ $ip, $remote_device_id ]);
}
break;
case 'local':
// local not always ifIndex or FIXME (see: http://jira.observium.org/browse/OBSERVIUM-1716)
if (!ctype_digit($id))
{
// Not sure what should be if $id ifName and it just numeric
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ?';
$remote_port_id = dbFetchCell($query, [ $id, $id, $id, $remote_device_id ]);
}
break;
}
} else {
// No way to find a remote port other than by MAC address, with the data we're getting from Mikrotik. Only proceed when only one remote port matches...
$remote_port_id = get_port_id_by_mac($remote_device_id, $entry['mtxrNeighborMacAddress']);
}
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $entry['mtxrNeighborIdentity'],
'remote_port' => $remote_port,
'remote_platform' => $remote_platform,
'remote_version' => $entry['mtxrNeighborVersion'],
'remote_address' => $entry['mtxrNeighborIpAddress']
];
discover_neighbour($port, 'mndp', $neighbour);
}
}
// EOF

View File

@ -0,0 +1,35 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
// NETGEAR-ISDP-MIB::agentIsdpCacheDeviceId.7.1 = STRING: "vminnovation-c3945"
// NETGEAR-ISDP-MIB::agentIsdpCacheDevicePort.7.1 = STRING: "GigabitEthernet0/1"
// NETGEAR-ISDP-MIB::agentIsdpCachePlatform.7.1 = STRING: "Cisco CISCO3945-CHASSIS"
// NETGEAR-ISDP-MIB::agentIsdpCacheCapabilities.7.1 = STRING: "Router Switch IGMP "
// NETGEAR-ISDP-MIB::agentIsdpCacheLastChange.7.1 = Timeticks: (7900) 0:01:19.00
// NETGEAR-ISDP-MIB::agentIsdpCacheProtocolVersion.7.1 = STRING: "2"
// NETGEAR-ISDP-MIB::agentIsdpCacheHoldtime.7.1 = INTEGER: 130 seconds
// NETGEAR-ISDP-MIB::agentIsdpCacheAddress.19.1 = STRING: "172.19.1.5"
// NETGEAR-ISDP-MIB::agentIsdpCacheLocalIntf.19.1 = STRING: "1/0/19"
// NETGEAR-ISDP-MIB::agentIsdpCacheVersion.19.1 = STRING: "11.0.0.31"
// NETGEAR-ISDP-MIB::agentIsdpCacheDeviceId.19.1 = STRING: "Lefkosa-Telekom"
// NETGEAR-ISDP-MIB::agentIsdpCacheDevicePort.19.1 = STRING: "1/0/6"
// NETGEAR-ISDP-MIB::agentIsdpCachePlatform.19.1 = STRING: "M5300-28GF3"
// NETGEAR-ISDP-MIB::agentIsdpCacheCapabilities.19.1 = STRING: "Router "
// NETGEAR-ISDP-MIB::agentIsdpCacheLastChange.19.1 = Timeticks: (9000) 0:01:30.00
// NETGEAR-ISDP-MIB::agentIsdpCacheProtocolVersion.19.1 = STRING: "2"
// NETGEAR-ISDP-MIB::agentIsdpCacheHoldtime.19.1 = INTEGER: 167 seconds
include(__DIR__ . "/isdp-mib.inc.php");
// EOF

View File

@ -0,0 +1,73 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
*
*/
if (!$config['autodiscovery']['ospf'])
{
print_debug("Autodiscovery for OSPF disabled.");
return;
}
// OSPF-MIB::ospfNbrIpAddr.103.52.56.3.0 = IpAddress: 103.52.56.3
// OSPF-MIB::ospfNbrIpAddr.103.52.56.4.0 = IpAddress: 103.52.56.4
// OSPF-MIB::ospfNbrAddressLessIndex.103.52.56.3.0 = INTEGER: 0
// OSPF-MIB::ospfNbrAddressLessIndex.103.52.56.4.0 = INTEGER: 0
// OSPF-MIB::ospfNbrRtrId.103.52.56.3.0 = IpAddress: 103.52.56.3
// OSPF-MIB::ospfNbrRtrId.103.52.56.4.0 = IpAddress: 10.20.3.1
// OSPF-MIB::ospfNbrOptions.103.52.56.3.0 = INTEGER: 66
// OSPF-MIB::ospfNbrOptions.103.52.56.4.0 = INTEGER: 2
// OSPF-MIB::ospfNbrPriority.103.52.56.3.0 = INTEGER: 1
// OSPF-MIB::ospfNbrPriority.103.52.56.4.0 = INTEGER: 1
// OSPF-MIB::ospfNbrState.103.52.56.3.0 = INTEGER: full(8)
// OSPF-MIB::ospfNbrState.103.52.56.4.0 = INTEGER: full(8)
// OSPF-MIB::ospfNbrEvents.103.52.56.3.0 = Counter32: 6
// OSPF-MIB::ospfNbrEvents.103.52.56.4.0 = Counter32: 5
// OSPF-MIB::ospfNbrLsRetransQLen.103.52.56.3.0 = Gauge32: 0
// OSPF-MIB::ospfNbrLsRetransQLen.103.52.56.4.0 = Gauge32: 0
// OSPF-MIB::ospfNbmaNbrStatus.103.52.56.3.0 = INTEGER: active(1)
// OSPF-MIB::ospfNbmaNbrStatus.103.52.56.4.0 = INTEGER: active(1)
// OSPF-MIB::ospfNbmaNbrPermanence.103.52.56.3.0 = INTEGER: permanent(2)
// OSPF-MIB::ospfNbmaNbrPermanence.103.52.56.4.0 = INTEGER: permanent(2)
// OSPF-MIB::ospfNbrHelloSuppressed.103.52.56.3.0 = INTEGER: false(2)
// OSPF-MIB::ospfNbrHelloSuppressed.103.52.56.4.0 = INTEGER: false(2)
// OSPF-MIB::ospfNbrRtrId[103.52.56.3][0] = IpAddress: 103.52.56.3
// OSPF-MIB::ospfNbrRtrId[103.52.56.4][0] = IpAddress: 10.20.3.1
// OSPF-MIB::ospfNbmaNbrStatus[103.52.56.3][0] = INTEGER: active(1)
// OSPF-MIB::ospfNbmaNbrStatus[103.52.56.4][0] = INTEGER: active(1)
$ospf_array = snmpwalk_cache_twopart_oid($device, 'ospfNbmaNbrStatus', [], 'OSPF-MIB', NULL, OBS_SNMP_ALL_TABLE);
if (snmp_status())
{
$ospf_array = snmpwalk_cache_twopart_oid($device, 'ospfNbrRtrId', $ospf_array, 'OSPF-MIB', NULL, OBS_SNMP_ALL_TABLE);
print_debug_vars($ospf_array);
foreach ($ospf_array as $ip => $entry)
{
if ($ip === '0.0.0.0') { continue; }
foreach ($entry as $if => $ospf)
{
if ($ospf['ospfNbmaNbrStatus'] !== 'active' || $ospf['ospfNbrRtrId'] === '0.0.0.0') { continue; }
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $ospf['ospfNbrRtrId']);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($ospf['ospfNbrRtrId'])) // Check all previous autodiscovery rounds
{
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($ospf['ospfNbrRtrId'], NULL, 'OSPF', NULL, $device);
}
}
}
}
// EOF

View File

@ -0,0 +1,94 @@
<?php
/*
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
// TPLINK-LLDPINFO-MIB::lldpNeighborPortId.49175.1 = STRING: "1/0/23"
// TPLINK-LLDPINFO-MIB::lldpNeighborPortIndexId.49175.1 = INTEGER: 1
// TPLINK-LLDPINFO-MIB::lldpNeighborChassisIdType.49175.1 = STRING: "MAC address"
// TPLINK-LLDPINFO-MIB::lldpNeighborChassisId.49175.1 = STRING: "A4:B9:84:7E:9Z:4B"
// TPLINK-LLDPINFO-MIB::lldpNeighborPortIdType.49175.1 = STRING: "Interface name"
// TPLINK-LLDPINFO-MIB::lldpNeighborPortIdDescr.49175.1 = STRING: "eth1"
// TPLINK-LLDPINFO-MIB::lldpNeighborTtl.49175.1 = INTEGER: 120
// TPLINK-LLDPINFO-MIB::lldpNeighborPortDescr.49175.1 = STRING: "eth1"
// TPLINK-LLDPINFO-MIB::lldpNeighborDeviceName.49175.1 = STRING: "Honda-WR200"
// TPLINK-LLDPINFO-MIB::lldpNeighborDeviceDescr.49175.1 = STRING: "OpenWrt 19.07.7"
// TPLINK-LLDPINFO-MIB::lldpNeighborCapAvailable.49175.1 = STRING: "Bridge WLAN Access Point Router Station Only"
// TPLINK-LLDPINFO-MIB::lldpNeighborCapEnabled.49175.1 = STRING: "Bridge WLAN Access Point Router"
// TPLINK-LLDPINFO-MIB::lldpNeighborManageIpAddr.49175.1 = Wrong Type (should be IpAddress): STRING: "19.254.254.149"
// TPLINK-LLDPINFO-MIB::lldpNeighborManageAddrType.49175.1 = STRING: "ipv4"
// TPLINK-LLDPINFO-MIB::lldpNeighborManageAddrInterfaceType.49175.1 = STRING: "IfIndex"
// TPLINK-LLDPINFO-MIB::lldpNeighborManageAddrInterfaceId.49175.1 = INTEGER: 5
// TPLINK-LLDPINFO-MIB::lldpNeighborManageAddrOID.49175.1 = STRING: "0"
// TPLINK-LLDPINFO-MIB::lldpNeighborPortAndProtocolVlanID.49175.1 = ""
// TPLINK-LLDPINFO-MIB::lldpNeighborVlanName.49175.1 = STRING: "vid: 100, VLAN name: eth1.100; vid: 2, VLAN name: eth1.2; vid: 200, VLAN name: eth1.200; vid: 254, VLAN name: eth1.254;"
// TPLINK-LLDPINFO-MIB::lldpNeighborProtocolIdentity.49175.1 = ""
// TPLINK-LLDPINFO-MIB::lldpNeighborAutoNegotiationSupported.49175.1 = INTEGER: enable(1)
// TPLINK-LLDPINFO-MIB::lldpNeighborAutoNegotiationEnabled.49175.1 = INTEGER: enable(1)
// TPLINK-LLDPINFO-MIB::lldpNeighborOperMau.49175.1 = STRING: "speed(100)/duplex(Full)"
// TPLINK-LLDPINFO-MIB::lldpNeighborLinkAggregationSupported.49175.1 = INTEGER: enable(1)
// TPLINK-LLDPINFO-MIB::lldpNeighborLinkAggregationEnabled.49175.1 = INTEGER: disable(0)
// TPLINK-LLDPINFO-MIB::lldpNeighborAggregationPortId.49175.1 = INTEGER: 0
// TPLINK-LLDPINFO-MIB::lldpNeighborPowerPortClass.49175.1 = ""
// TPLINK-LLDPINFO-MIB::lldpNeighborPsePowerSupported.49175.1 = INTEGER: disable(0)
// TPLINK-LLDPINFO-MIB::lldpNeighborPsePowerEnabled.49175.1 = INTEGER: disable(0)
// TPLINK-LLDPINFO-MIB::lldpNeighborPsePairsControlAbility.49175.1 = INTEGER: disable(0)
// TPLINK-LLDPINFO-MIB::lldpNeighborMaximumFrameSize.49175.1 = INTEGER: 0
$lldp_array = snmpwalk_cache_oid($device, 'lldpNeighborInfoTable', [], "TPLINK-LLDPINFO-MIB", NULL, OBS_SNMP_ALL_MULTILINE);
print_debug_vars($lldp_array);
foreach ($lldp_array as $index => $lldp) {
// Local port
list($ifIndex, $lldpNeighborPortIndexId) = explode('.', $index, 2);
$ifName = $lldp['lldpNeighborPortId'];
$port = get_port_by_index_cache($device, $ifIndex);
if (!$port) {
$port = dbFetchRow("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = ? AND (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?)", [ $device['device_id'], 0, $ifName, $ifName, $ifName ]);
}
// Remote device & port
$remote_device_id = FALSE;
$remote_port_id = NULL;
// Try find remote device and check if already cached
$remote_device_id = get_autodiscovery_device_id($device, $lldp['lldpNeighborDeviceName'], $lldp['lldpNeighborManageIpAddr'], $lldp['lldpNeighborChassisId']);
if (is_null($remote_device_id) && // NULL - never cached in other rounds
check_autodiscovery($lldp['lldpNeighborDeviceName'], $lldp['lldpNeighborManageIpAddr'])) { // Check all previous autodiscovery rounds
// Neighbour never checked, try autodiscovery
$remote_device_id = autodiscovery_device($lldp['lldpNeighborDeviceName'], $lldp['lldpNeighborManageIpAddr'], 'LLDP', $lldp['lldpNeighborDeviceDescr'], $device, $port);
}
if ($remote_device_id) {
// Try lldpNeighborPortIdDescr
$if = $lldp['lldpNeighborPortIdDescr'];
$query = 'SELECT `port_id` FROM `ports` WHERE (`ifName` = ? OR `ifDescr` = ? OR `port_label_short` = ?) AND `device_id` = ? AND `deleted` = ?';
$remote_port_id = dbFetchCell($query, [ $if, $if, $if, $remote_device_id, 0 ]);
if (!$remote_port_id && $lldp['lldpNeighborPortDescr'] !== $if) {
$if = $lldp['lldpNeighborPortDescr'];
// Try same by lldpNeighborPortDescr
$remote_port_id = dbFetchCell($query, [ $if, $if, $if, $remote_device_id, 0 ]);
}
//$id = $lldp['lldpNeighborManageAddrInterfaceId'];
}
$neighbour = [
'remote_port_id' => $remote_port_id,
'remote_hostname' => $lldp['lldpNeighborDeviceName'],
'remote_port' => $lldp['lldpNeighborPortIdDescr'],
'remote_platform' => $lldp['lldpNeighborDeviceDescr'],
'remote_version' => NULL,
'remote_address' => $lldp['lldpNeighborManageIpAddr']
];
discover_neighbour($port, 'lldp', $neighbour);
}
// EOF

View File

@ -0,0 +1,57 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
$table_rows = array();
$sql = "SELECT *";
$sql .= " FROM `oids_entries`";
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
$sql .= " WHERE `device_id` = ?";
//print_vars($sql);
$entries_db = dbFetchRows($sql, array($device['device_id']));
foreach($entries_db as $entry_db)
{
$entries[$entry_db['oid_id']] = $entry_db['oid_entry_id'];
}
$oids_db = dbFetchRows("SELECT * FROM `oids` WHERE `oid_autodiscover` = '1'");
// FIXME - removal and blacklisting
foreach($oids_db as $oid)
{
$value = snmp_get($device, $oid['oid'], "-OUQnv");
if (is_numeric($value) && $value != '4294967295' && $value != '2147483647' && $value != '-2147483647') // Don't discover stuff which is returning min/max 32 bit values
{
if(!isset($entries[$oid['oid_id']]))
{
// Auto-add this OID.
if ($oid_entry_id = dbInsert(array('oid_id' => $oid['oid_id'], 'device_id' => $device['device_id']), 'oids_entries'))
{
print_debug("SUCCESS: Added OID entry (id: $oid_entry_id)");
} else {
print_warning("ERROR: Unable to add OID entry for ".$oid['oid_name']);
}
}
} else {
if(isset($entries[$oid['oid_id']]))
{
// Mark this OID as deleted from the host.
dbUpdate(array('deleted' => '1'), 'oids_entries', '`oid_entry_id` = ?', array($oid['oid_entry_id']));
}
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Redetect OS if necessary (controlled by discover_device function)
if ($detect_os)
{
$os = get_device_os($device);
if ($os != $device['os'])
{
$type = (isset($config['os'][$os]['type']) ? $config['os'][$os]['type'] : 'unknown'); // Also change $type
print_cli_data('Device OS changed', $device['os']." -> $os", 1);
log_event('OS changed: '.$device['os'].' -> '.$os, $device, 'device', $device['device_id'], 'warning');
// Additionally reset icon and type for device if os changed
dbUpdate(array('os' => $os, 'icon' => array('NULL'), 'type' => $type), 'devices', '`device_id` = ?', array($device['device_id']));
if (isset($attribs['override_icon']))
{
del_entity_attrib('device', $device, 'override_icon');
}
if (isset($attribs['override_type']))
{
del_entity_attrib('device', $device, 'override_type');
}
$device['os'] = $os;
$device['type'] = $type;
// Set device sysObjectID when device os changed
$sysObjectID = snmp_cache_sysObjectID($device);
if ($device['sysObjectID'] != $sysObjectID)
{
dbUpdate(array('sysObjectID' => $sysObjectID), 'devices', '`device_id` = ?', array($device['device_id']));
$device['sysObjectID'] = $sysObjectID;
}
}
}
// EOF

View File

@ -0,0 +1,28 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
*
*/
/// YAH, leave this here, still many device use same sysObjectId as here :(
if ($os) { return; }
if (match_oid_num($sysObjectID, '.1.3.6.1.4.1.4413') || $sysObjectID === '.1.3.6.1.4.1.7244') {
$os = 'broadcom_fastpath'; // Generic Broadcom
/* Seems unused
if ($sysObjectID === '.1.3.6.1.4.1.4413' && str_icontains_array($sysDescr, 'bcm963')) {
//Broadcom Bcm963xx Software Version 3.00L.01V.
//Broadcom Bcm963xx Software Version A131-306CTU-C08_R04
//$os = 'comtrend-';
}
*/
}
// EOF

View File

@ -0,0 +1,26 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage discovery
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
// Keep this os detect here!
// for detect as last turn (when other definitions not detected)
if ($os) { return; }
if (str_contains_array($sysDescr, 'FreeBSD') ||
str_starts($sysObjectID, array('.1.3.6.1.4.1.8072.3.2.8', // NET-SNMP
'.1.3.6.1.4.1.12325.1.1.2.1'))) // BSNMP daemon
{
$os = 'freebsd';
}
// EOF

Some files were not shown because too many files have changed in this diff Show More