Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce discovery snmp load of Cisco VTP vlans module #10510

Merged
merged 2 commits into from
Aug 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions includes/discovery/vlans/cisco-vtp.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
if ($device['os_group'] == 'cisco') {
echo "Cisco VLANs:\n";

$native_vlans = snmpwalk_cache_oid($device, 'vlanTrunkPortNativeVlan', array(), 'CISCO-VTP-MIB');
$native_vlans = snmpwalk_cache_oid($device, 'vlanTrunkPortNativeVlan', [], 'CISCO-VTP-MIB');
$native_vlans = snmpwalk_cache_oid($device, 'vmVlan', $native_vlans, 'CISCO-VLAN-MEMBERSHIP-MIB');

// Not sure why we check for VTP, but this data comes from that MIB, so...
$vtpversion = snmp_get($device, 'vtpVersion.0', '-OnvQ', 'CISCO-VTP-MIB');
if ($vtpversion == '1' || $vtpversion == '2' || $vtpversion == '3' || $vtpversion == 'one' || $vtpversion == 'two' || $vtpversion == 'three' || $vtpversion == 'none') {
if (in_array($vtpversion, ['1', '2', '3', 'one', 'two', 'three', 'none'])) {
// FIXME - can have multiple VTP domains.
$vtpdomains = snmpwalk_cache_oid($device, 'vlanManagementDomains', array(), 'CISCO-VTP-MIB');
$vlans = snmpwalk_cache_twopart_oid($device, 'vtpVlanEntry', array(), 'CISCO-VTP-MIB');
$vtpdomains = snmpwalk_cache_oid($device, 'vlanManagementDomains', [], 'CISCO-VTP-MIB');
$vlans = snmpwalk_cache_twopart_oid($device, 'vtpVlanName', [], 'CISCO-VTP-MIB');
$vlans = snmpwalk_cache_twopart_oid($device, 'vtpVlanType', $vlans, 'CISCO-VTP-MIB');

foreach ($vtpdomains as $vtpdomain_id => $vtpdomain) {
echo 'VTP Domain '.$vtpdomain_id.' '.$vtpdomain['managementDomainName'].' ';
Expand All @@ -37,11 +38,13 @@
// Ignore reserved VLAN IDs
// get dot1dStpPortEntry within the vlan context
$vlan_device = array_merge($device, array('community' => $device['community'] . '@' . $vlan_id, 'context_name' => "vlan-$vlan_id"));
$tmp_vlan_data = snmpwalk_cache_oid($vlan_device, 'dot1dStpPortEntry', array(), 'BRIDGE-MIB');
$tmp_vlan_data = snmpwalk_cache_oid($vlan_device, 'dot1dStpPortPriority', [], 'BRIDGE-MIB');
$tmp_vlan_data = snmpwalk_cache_oid($vlan_device, 'dot1dStpPortState', $tmp_vlan_data, 'BRIDGE-MIB');
$tmp_vlan_data = snmpwalk_cache_oid($vlan_device, 'dot1dStpPortPathCost', $tmp_vlan_data, 'BRIDGE-MIB');

// may need to fetch additional dot1dBasePortIfIndex mappings
$tmp_vlan_data = snmpwalk_cache_oid($vlan_device, 'dot1dBasePortIfIndex', $tmp_vlan_data, 'BRIDGE-MIB');
$vlan_data = array();
$vlan_data = [];
// flatten the array, use ifIndex instead of dot1dBasePortId
foreach ($tmp_vlan_data as $index => $array) {
if (isset($array['dot1dBasePortIfIndex'])) {
Expand Down