newdevice: Added FDB and ARP support for edgeswitch devices (#7199)

This commit is contained in:
Neil Lathwood
2017-08-22 20:55:39 +01:00
committed by GitHub
parent 65c6240c2a
commit 6bab347335
4 changed files with 75 additions and 3 deletions
+6 -2
View File
@@ -33,8 +33,12 @@ foreach ($vrfs_lite_cisco as $vrf) {
$context = $vrf['context_name'];
$device['context_name']=$context;
$arp_data = snmpwalk_group($device, 'ipNetToPhysicalPhysAddress', 'IP-MIB');
$arp_data = snmpwalk_group($device, 'ipNetToMediaPhysAddress', 'IP-MIB', 1, $arp_data);
if (file_exists($config['install_dir'] . "/includes/discovery/arp-table/{$device['os']}.inc.php")) {
include $config['install_dir'] . "/includes/discovery/arp-table/{$device['os']}.inc.php";
} else {
$arp_data = snmpwalk_group($device, 'ipNetToPhysicalPhysAddress', 'IP-MIB');
$arp_data = snmpwalk_group($device, 'ipNetToMediaPhysAddress', 'IP-MIB', 1, $arp_data);
}
$existing_data = dbFetchRows(
"SELECT * from `ipv4_mac` WHERE `device_id`=? AND `context_name`=?",
@@ -0,0 +1,31 @@
<?php
/**
* edgeswitch.inc.php
*
* Arp Table discovery file for EdgeSwitch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <[email protected]>
*/
$binding = snmpwalk_group($device, 'agentDynamicDsBindingTable', 'EdgeSwitch-SWITCHING-MIB', 1);
foreach ($binding as $mac => $data) {
$arp_data[$data['agentDynamicDsBindingIfIndex']]['ipNetToMediaPhysAddress'][$data['agentDynamicDsBindingIpAddr']] = $data['agentDynamicDsBindingMacAddr'];
$arp_data[$data['agentDynamicDsBindingIfIndex']]['ipNetToPhysicalPhysAddress']['ipv4'][$data['agentDynamicDsBindingIpAddr']] = $data['agentDynamicDsBindingMacAddr'];
}
+3 -1
View File
@@ -15,7 +15,9 @@ foreach ($sql_result as $entry) {
}
$insert = array(); // populate $insert with database entries
if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
if (file_exists($config['install_dir'] . "/includes/discovery/fdb-table/{$device['os']}.inc.php")) {
require $config['install_dir'] . "/includes/discovery/fdb-table/{$device['os']}.inc.php";
} elseif ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
include $config['install_dir'] . '/includes/discovery/fdb-table/ios.inc.php';
} else {
// Check generic Q-BRIDGE-MIB and BRIDGE-MIB
@@ -0,0 +1,35 @@
<?php
/**
* edgeswitch.inc.php
*
* FDP Table discovery file for EdgeSwitch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <[email protected]>
*/
$binding = snmpwalk_group($device, 'agentDynamicDsBindingTable', 'EdgeSwitch-SWITCHING-MIB', 1);
foreach ($binding as $mac => $data) {
$port = get_port_by_index_cache($device['device_id'], $data['agentDynamicDsBindingIfIndex']);
$port_id = $port['port_id'];
$mac_address = implode(array_map('zeropad', explode(':', $mac)));
$vlan_id = $data['agentDynamicDsBindingVlanId'] ?: 0;
$insert[$vlan_id][$mac_address]['port_id'] = $port_id;
d_echo("vlan $vlan_id mac $mac_address port $port_id\n");
}