mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 16:08:55 +02:00
Build a better vlan discoverer!
git-svn-id: http://www.observium.org/svn/observer/trunk@93 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+18
-9
@@ -9,20 +9,29 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
echo("Discovering VLANs on " . $device['hostname'] . "\n");
|
||||
|
||||
$vlans_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$vlans_cmd .= "1.3.6.1.4.1.9.9.46.1.3.1.1.2.1 | sed s/.1.3.6.1.4.1.9.9.46.1.3.1.1.2.1.//g | cut -f 1 -d\" \"";
|
||||
$vtpversion_cmd = "snmpget -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.9.9.46.1.1.1.0";
|
||||
$vtpversion = trim(`$vtpversion_cmd 2>/dev/null`);
|
||||
|
||||
$vlans = trim(`$vlans_cmd | grep -v o`);
|
||||
if($vtpversion == '1' || $vtpversion == '2') {
|
||||
|
||||
foreach(explode("\n", $vlans) as $vlan) {
|
||||
echo("VLAN Trunking Protocol Version $vtpversion\n");
|
||||
|
||||
$vlan_descr_cmd = "snmpget -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$vlan_descr_cmd .= ".1.3.6.1.4.1.9.9.46.1.3.1.1.4.1." . $vlan;
|
||||
$vlan_descr = `$vlan_descr_cmd`;
|
||||
$vlans_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$vlans_cmd .= "1.3.6.1.4.1.9.9.46.1.3.1.1.2.1 | sed s/.1.3.6.1.4.1.9.9.46.1.3.1.1.2.1.//g | cut -f 1 -d\" \"";
|
||||
|
||||
$vlan_descr = trim(str_replace("\"", "", $vlan_descr));
|
||||
$vlans = trim(`$vlans_cmd | grep -v o`);
|
||||
|
||||
echo("VLAN $vlan ($vlan_descr)\n");
|
||||
foreach(explode("\n", $vlans) as $vlan) {
|
||||
|
||||
$vlan_descr_cmd = "snmpget -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ";
|
||||
$vlan_descr_cmd .= ".1.3.6.1.4.1.9.9.46.1.3.1.1.4.1." . $vlan;
|
||||
$vlan_descr = `$vlan_descr_cmd`;
|
||||
|
||||
$vlan_descr = trim(str_replace("\"", "", $vlan_descr));
|
||||
|
||||
echo("VLAN $vlan ($vlan_descr)\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user