mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
vrp - Collect sticky mac addresses in fdb-table (#12774)
* collect sticky mac addresses as well * style
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
$fdbPort_table = snmpwalk_group($device, 'hwDynFdbPort', 'HUAWEI-L2MAM-MIB');
|
||||
$hwCfgMacAddrQueryIfIndex = snmpwalk_group($device, 'hwCfgMacAddrQueryIfIndex', 'HUAWEI-L2MAM-MIB', 10);
|
||||
|
||||
if (! empty($fdbPort_table)) {
|
||||
echo 'HUAWEI-L2MAM-MIB:' . PHP_EOL;
|
||||
@@ -39,3 +40,34 @@ if (! empty($fdbPort_table)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Static (sticky) mac addresses are not stored in the same table.
|
||||
if (! empty($hwCfgMacAddrQueryIfIndex)) {
|
||||
echo 'HUAWEI-L2MAM-MIB (static):' . PHP_EOL;
|
||||
foreach ($hwCfgMacAddrQueryIfIndex as $vlan => $data) {
|
||||
if (! empty($data[0][0][0])) {
|
||||
foreach ($data[0][0][0] as $mac => $data_next) {
|
||||
if (! empty($data_next['showall'][0][0][0][0]['hwCfgMacAddrQueryIfIndex'])) {
|
||||
$basePort = $data_next['showall'][0][0][0][0]['hwCfgMacAddrQueryIfIndex'];
|
||||
$ifIndex = reset($basePort);
|
||||
if (! $ifIndex) {
|
||||
continue;
|
||||
}
|
||||
$port = get_port_by_index_cache($device['device_id'], $ifIndex);
|
||||
$port_id = $port['port_id'];
|
||||
$mac_address = implode(array_map('zeropad', explode(':', $mac)));
|
||||
if (strlen($mac_address) != 12) {
|
||||
d_echo("MAC address padding failed for $mac\n");
|
||||
continue;
|
||||
}
|
||||
$vlan_id = isset($vlans_dict[$vlan]) ? $vlans_dict[$vlan] : 0;
|
||||
$insert[$vlan_id][$mac_address]['port_id'] = $port_id;
|
||||
d_echo("vlan $vlan mac $mac_address port ($ifIndex) $port_id\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($fdbPort_table);
|
||||
unset($hwCfgMacAddrQueryIfIndex);
|
||||
|
Reference in New Issue
Block a user