2007-04-10 23:43:42 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?
|
|
|
|
|
|
|
|
include("config.php");
|
|
|
|
include("includes/functions.php");
|
|
|
|
|
|
|
|
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND os = 'IOS'");
|
|
|
|
while ($device = mysql_fetch_array($device_query)) {
|
|
|
|
|
|
|
|
echo("Discovering VLANs on " . $device['hostname'] . "\n");
|
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
$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`);
|
2007-04-10 23:43:42 +00:00
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
if($vtpversion == '1' || $vtpversion == '2') {
|
2007-04-10 23:43:42 +00:00
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
echo("VLAN Trunking Protocol Version $vtpversion\n");
|
2007-04-10 23:43:42 +00:00
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
$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\" \"";
|
2007-04-10 23:43:42 +00:00
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
$vlans = trim(`$vlans_cmd | grep -v o`);
|
2007-04-10 23:43:42 +00:00
|
|
|
|
2007-04-12 00:07:25 +00:00
|
|
|
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");
|
|
|
|
|
|
|
|
}
|
2007-04-10 23:43:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|