mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
better vlan discovery
git-svn-id: http://www.observium.org/svn/observer/trunk@2786 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
b118ea7062
commit
53327231b7
@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
include("../includes/defaults.inc.php");
|
||||
include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
|
||||
$link = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']);
|
||||
$db = mysql_select_db($config['db_name'], $link);
|
||||
|
||||
|
||||
$query = "SELECT * FROM ipaddr AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.os = 'ios'";
|
||||
$query = "SELECT * FROM ipv4_addresses AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.os = 'ios'";
|
||||
$data = mysql_query($query, $link);
|
||||
while($ip = mysql_fetch_array($data)) {
|
||||
unset($sub);
|
||||
@ -17,21 +17,19 @@ while($ip = mysql_fetch_array($data)) {
|
||||
|
||||
$real_hostname = $hostname;
|
||||
|
||||
$hostname = str_replace(".jtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".wtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".jerseytelecom.net", "", $hostname);
|
||||
|
||||
list($cc, $loc, $host) = explode(".", $hostname);
|
||||
if($host) {
|
||||
$hostname = "$host.$loc.$cc.v4.jerseytelecom.net";
|
||||
$hostname = "$host.$loc.$cc.v4.data.net.uk";
|
||||
} else {
|
||||
$host = $cc; unset ($cc);
|
||||
$hostname = "$host.v4.jerseytelecom.net";
|
||||
$hostname = "$host.v4.data.net.uk";
|
||||
}
|
||||
|
||||
$interface = $ip['ifDescr'];
|
||||
$address = $ip['addr'];
|
||||
$cidr = $ip['cidr'];
|
||||
$address = $ip['ipv4_address'];
|
||||
$cidr = $ip['ipv4_prefixlen'];
|
||||
$interface = strtolower(makeshortif(fixifname($interface)));
|
||||
$interface = str_replace("/", "-", $interface);
|
||||
$interface = str_replace(":", "_", $interface);
|
||||
|
@ -67,6 +67,10 @@ if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$po
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") )
|
||||
{ $menu_options['pagp'] = 'PAgP'; }
|
||||
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `interface_id` = '".$port['interface_id']."' and `device_id` = '".$device['device_id']."'") )
|
||||
{ $menu_options['vlans'] = 'VLANs'; }
|
||||
|
||||
|
||||
$sep = "";
|
||||
foreach ($menu_options as $option => $text)
|
||||
{
|
||||
|
51
html/pages/device/port/vlans.inc.php
Normal file
51
html/pages/device/port/vlans.inc.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
$vlans = dbFetchRows("SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`interface_id` = '".$port['interface_id']."' and PV.`device_id` = '".$device['device_id']."' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id");
|
||||
|
||||
echo('<table border="0" cellspacing="0" cellpadding="5" width="100%">');
|
||||
|
||||
echo("<tr><td>VLAN</td><td>Description</td><td>Cost</td><td>Priority</td><td>State</td><td>Other Ports</td></tr>");
|
||||
|
||||
$row=0;
|
||||
foreach($vlans as $vlan)
|
||||
{
|
||||
$row++;
|
||||
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
echo('<tr bgcolor="'.$row_colour.'">');
|
||||
|
||||
echo("<td width=100 class=list-large> Vlan " . $vlan['vlan'] . "</td>");
|
||||
echo("<td width=200 class=box-desc>" . $vlan['vlan_descr'] . "</td>");
|
||||
|
||||
echo("<td>".$vlan['cost']."</td><td>".$vlan['priority']."</td><td>".$vlan['state']."</td>");
|
||||
|
||||
$vlan_ports = array();
|
||||
|
||||
$otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.interface_id = V.interface_id", array($device['device_id'], $vlan['vlan']));
|
||||
foreach($otherports as $otherport)
|
||||
{
|
||||
$vlan_ports[$otherport[ifIndex]] = $otherport;
|
||||
}
|
||||
|
||||
$otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan']));
|
||||
foreach($otherports as $otherport)
|
||||
{
|
||||
$vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('access' => '1'));
|
||||
}
|
||||
|
||||
ksort($vlan_ports);
|
||||
|
||||
echo("<td>");
|
||||
$vsep='';
|
||||
foreach($vlan_ports as $otherport)
|
||||
{
|
||||
echo($vsep.generate_port_link($otherport, makeshortif($otherport['ifDescr'])));
|
||||
if($otherport['access']) { echo("(A)"); }
|
||||
$vsep=", ";
|
||||
}
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
?>
|
@ -382,8 +382,7 @@ $config['discovery_modules']['discovery-protocols'] = 1;
|
||||
$config['discovery_modules']['arp-table'] = 1;
|
||||
$config['discovery_modules']['junose-atm-vp'] = 1;
|
||||
$config['discovery_modules']['bgp-peers'] = 1;
|
||||
$config['discovery_modules']['q-bridge-mib'] = 1;
|
||||
$config['discovery_modules']['cisco-vlans'] = 1;
|
||||
$config['discovery_modules']['vlans'] = 1;
|
||||
$config['discovery_modules']['cisco-mac-accounting'] = 1;
|
||||
$config['discovery_modules']['cisco-pw'] = 1;
|
||||
$config['discovery_modules']['cisco-vrf'] = 1;
|
||||
|
@ -41,27 +41,9 @@ if ($device['os_group'] == "ios")
|
||||
$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_assoc($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");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -34,25 +34,8 @@ if ($vlanversion == 'version1')
|
||||
$this_vlans[] = $vlan;
|
||||
}
|
||||
|
||||
$device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "'");
|
||||
while ($dev_vlan = mysql_fetch_assoc($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("-");
|
||||
if ($debug) { echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($this_vlans);
|
||||
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user