From f1103399f056ff7c843b32f218a7c2a6de4052d4 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 3 Jan 2010 22:13:50 +0000 Subject: [PATCH] add Q-BRIDGE-MIB support git-svn-id: http://www.observium.org/svn/observer/trunk@589 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 5 ++- includes/discovery/q-bridge-mib.php | 57 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 includes/discovery/q-bridge-mib.php diff --git a/discovery.php b/discovery.php index 38957682c..28391594d 100755 --- a/discovery.php +++ b/discovery.php @@ -86,7 +86,7 @@ while ($device = mysql_fetch_array($device_query)) { if ($device['type'] == "unknown") { $device['type'] = 'network'; } # FIXME: could also be a Netscreen... } - if($device['os'] == "powerconnect" || $device['os'] == "ios" || $device['os'] == "iosxe" || $device['os'] == "catos" || $device['os'] == "asa" || $device['os'] == "pix") { + if($device['os'] == "ios" || $device['os'] == "iosxe" || $device['os'] == "catos" || $device['os'] == "asa" || $device['os'] == "pix") { include("includes/discovery/cisco-vlans.php"); include("includes/discovery/bgp-peers.php"); include("includes/discovery/cisco-mac-accounting.php"); @@ -100,8 +100,9 @@ while ($device = mysql_fetch_array($device_query)) { if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } - if ($device['os'] == "procurve") + if ($device['os'] == "procurve" || $device['os'] == "powerconnect") { + include("includes/discovery/q-bridge-mib.php"); if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } diff --git a/includes/discovery/q-bridge-mib.php b/includes/discovery/q-bridge-mib.php new file mode 100644 index 000000000..71b500c56 --- /dev/null +++ b/includes/discovery/q-bridge-mib.php @@ -0,0 +1,57 @@ +/dev/null`); + +echo $vlanversion; + + if($vlanversion == 'version1') { + + echo("VLAN $vlanversion "); + + $vlans_cmd = $config['snmpwalk'] . " -m Q-BRIDGE-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $vlans_cmd .= "dot1qVlanFdbId"; + + $vlans = trim(`$vlans_cmd | grep -v o`); + + foreach(explode("\n", $vlans) as $vlan_oid) { + + list($oid,$vlan) = split(' ',$vlan_oid); + $oid_ex = explode('.',$oid); + $oid = $oid_ex[count($oid_ex)-1]; + + $vlan_descr_cmd = $config['snmpget'] . " -m Q-BRIDGE-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $vlan_descr_cmd .= "dot1qVlanStaticName.$oid"; + $vlan_descr = shell_exec($vlan_descr_cmd); + + $vlan_descr = trim(str_replace("\"", "", $vlan_descr)); + + if(mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0') { + mysql_query("INSERT INTO `vlans` (`device_id`,`vlan_domain`,`vlan_vlan`, `vlan_descr`) VALUES (" . $device['device_id'] . ",'','$vlan', '$vlan_descr')"); + echo("+"); + } else { echo("."); } + + $this_vlans[] = $vlan; + + } + + $device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "'"); + while($dev_vlan = mysql_fetch_array($device_vlans)) { + unset($vlan_exists); + foreach($this_vlans as $test_vlan) { + if($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; } + } + if(!$vlan_exists) { + mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'"); + echo("-"); + #echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); + } + } + } + + unset($this_vlans); + + echo("\n");