From 19ae34c4d8d0b5f642329c3094747c47b5a29857 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 15 Dec 2011 15:00:45 +0000 Subject: [PATCH] unfinished q-bridge-mib vlan/trunk code git-svn-id: http://www.observium.org/svn/observer/trunk@2784 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/polling/ports.inc.php | 38 +++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 40ab3757b..87f52f2a4 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -88,9 +88,34 @@ if ($device['os_group'] == "ios") $port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB"); $port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB"); -} +} else +{ + $port_stats = snmpwalk_cache_oid($device, "dot1qPortVlanTable", $port_stats, "Q-BRIDGE-MIB"); -$port_stats = snmpwalk_cache_oid($device, "dot1qPortVlanTable", $port_stats, "Q-BRIDGE-MIB"); + $vlan_ports = snmpwalk_cache_twopart_oid($device, "dot1qVlanCurrentEgressPorts", $vlan_stats, "Q-BRIDGE-MIB"); + $vlan_ifindex_map = snmpwalk_cache_oid($device, "dot1dBasePortIfIndex", $vlan_stats, "Q-BRIDGE-MIB"); + + foreach ($vlan_ports as $instance) + { + foreach (array_keys($instance) as $vlan_id) + { + $parts = explode(' ',$instance[$vlan_id]['dot1qVlanCurrentEgressPorts']); + $binary = ''; + foreach ($parts as $part) + { + $binary .= zeropad(decbin($part),8); + } + for ($i = 0; $i < strlen($binary); $i++) + { + if ($binary[$i]) + { + $ifindex = $i; // FIXME $vlan_ifindex_map[$i] + $q_bridge_mib[$ifindex][] = $vlan_id; + } + } + } + } +} $polled = time(); @@ -131,15 +156,11 @@ echo("\n"); /// Loop ports in the DB and update where necessary foreach ($ports as $port) { - echo ("Port " . $port['ifDescr'] . "(".$port['ifIndex'].") "); if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1") { /// Check to make sure Port data is cached. $this_port = &$port_stats[$port['ifIndex']]; - #print_r($port); - #print_r($this_port); - if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; } $polled_period = $polled - $port['poll_time']; @@ -157,7 +178,6 @@ foreach ($ports as $port) } /// rewrite the ifPhysAddress - if (strpos($this_port['ifPhysAddress'], ":")) { list($a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(":", $this_port['ifPhysAddress']); @@ -194,7 +214,7 @@ foreach ($ports as $port) $this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus']; } - /// Set VLAN and Trunk + /// Set VLAN and Trunk from Cisco if (isset($this_port['vlanTrunkPortEncapsulationOperType']) && $this_port['vlanTrunkPortEncapsulationOperType'] != "notApplicable") { $this_port['ifTrunk'] = $this_port['vlanTrunkPortEncapsulationOperType']; @@ -202,10 +222,12 @@ foreach ($ports as $port) } $this_port['ifVlan'] = $this_port['vmVlan']; + /// Set VLAN and Trunk from Q-BRIDGE-MIB if (!isset($this_port['ifVlan']) && isset($this_port['dot1qPvid'])) { $this_port['ifVlan'] = $this_port['dot1qPvid']; } + # FIXME use $q_bridge_mib[$this_port['ifIndex'] to see if it is a trunk (>1 array count) echo("VLAN == ".$this_port['ifVlan']);