mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
initial work on vlan discovery.
git-svn-id: http://www.observium.org/svn/observer/trunk@89 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#!/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");
|
||||
|
||||
$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\" \"";
|
||||
|
||||
$vlans = trim(`$vlans_cmd | grep -v o`);
|
||||
|
||||
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