mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
new things! vrfs!
git-svn-id: http://www.observium.org/svn/observer/trunk@256 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -58,6 +58,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
include("includes/discovery/cisco-physical.php");
|
||||
include("includes/discovery/bgp-peers.php");
|
||||
include("includes/discovery/cisco-pw.php");
|
||||
include("includes/discovery/cisco-vrf.php");
|
||||
}
|
||||
|
||||
echo("\n"); $devices_polled++;
|
||||
|
||||
@@ -69,7 +69,12 @@
|
||||
if($device['os'] == "IOS") {
|
||||
|
||||
if($interface['ifTrunk']) { echo("<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>");
|
||||
} elseif ($interface['ifVlan']) { echo("<span class=box-desc><span class=blue>VLAN " . $interface['ifVlan'] . "</span></span>"); }
|
||||
} elseif ($interface['ifVlan']) { echo("<span class=box-desc><span class=blue>VLAN " . $interface['ifVlan'] . "</span></span>");
|
||||
} elseif ($interface['ifVrf']) {
|
||||
$vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'"));
|
||||
echo("<span style='color: green;'>" . $vrf['vrf_name'] . "</span>");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
if(is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
|
||||
echo("<tr bgcolor='$bg_colour'>");
|
||||
|
||||
echo("<td class=list-large> " . $vrf['vrf_name'] . "</td>");
|
||||
echo("<td class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>");
|
||||
|
||||
echo("<td class=list-bold>");
|
||||
$ports_query = mysql_query("SELECT * FROM interfaces WHERE `device_id` = '" . $device['device_id'] . "' AND `ifVrf` = '" . $vrf['vrf_id'] . "' ");
|
||||
while($port = mysql_fetch_array($ports_query)) {
|
||||
|
||||
echo($vrf['port_sep'] . generateiflink($port, makeshortif($port['ifDescr'])));
|
||||
$vrf['port_sep'] = ", ";
|
||||
}
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
|
||||
?>
|
||||
@@ -39,6 +39,16 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
|
||||
</li>");
|
||||
}
|
||||
|
||||
if(@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||
echo("
|
||||
<li class=" . $select['dev-vrfs'] . ">
|
||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vrfs' >
|
||||
<img src='images/16/layers.png' align=absmiddle border=0> VRFs
|
||||
</a>
|
||||
</li>");
|
||||
}
|
||||
|
||||
|
||||
if($config['enable_bgp'] && $device['bgpLocalAs']) {
|
||||
echo("
|
||||
<li class=" . $select['dev-bgp'] . ">
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
|
||||
$i = "1";
|
||||
$vrf_query = mysql_query("select * from vrfs WHERE device_id = '".$_GET['id']."' ORDER BY 'vrf_name'");
|
||||
while($vrf = mysql_fetch_array($vrf_query)) {
|
||||
include("includes/print-vrf.inc");
|
||||
$i++;
|
||||
}
|
||||
echo("</table></div>");
|
||||
|
||||
?>
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
<?
|
||||
|
||||
unset( $vrf_count );
|
||||
|
||||
echo("VRF : ");
|
||||
|
||||
$oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " mplsVpnVrfRouteDistinguisher");
|
||||
|
||||
$oids = str_replace(".1.3.6.1.3.118.1.2.2.1.3.", "", $oids);
|
||||
$oids = str_replace(" \"", "||", $oids);
|
||||
$oids = str_replace("\"", "", $oids);
|
||||
|
||||
$oids = trim($oids);
|
||||
foreach ( explode("\n", $oids) as $oid ) {
|
||||
if($oid) {
|
||||
list($vrf['oid'], $vrf['RouteDistinguisher']) = explode("||", $oid);
|
||||
$vrf['name'] = shell_exec($config['snmpget'] . " -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']);
|
||||
list(,$vrf['name'], $vrf['MplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']);
|
||||
echo($vrf['name']);
|
||||
|
||||
if(@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."'
|
||||
AND `vrf_oid`='".$vrf['oid']."'"),0)) {
|
||||
echo("already have! \n");
|
||||
} else {
|
||||
$insert_query = "INSERT INTO `vrfs` (`vrf_oid`,`vrf_name`,`mplsVpnVrfRouteDistinguisher`,`device_id`) ";
|
||||
$insert_query .= "VALUES ('".$vrf['oid']."','".$vrf['name']."','".$vrf['MplsVpnVrfRouteDistinguisher']."','".$device['device_id']."')";
|
||||
mysql_query($insert_query);
|
||||
}
|
||||
$vrf_id = mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0);
|
||||
echo(" Id: ($vrf_id) ");
|
||||
|
||||
$interfaces_oid = ".1.3.6.1.3.118.1.2.1.1.2." . $vrf['oid'];
|
||||
$interfaces = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " $interfaces_oid");
|
||||
$interfaces = trim(str_replace($interfaces_oid . ".", "", $interfaces));
|
||||
# list($interfaces) = explode(" ", $interfaces);
|
||||
echo(" ( ");
|
||||
foreach (explode("\n", $interfaces) as $if_id) {
|
||||
$interface = mysql_fetch_array(mysql_query("SELECT * FROM interfaces WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'"));
|
||||
echo($interface['ifDescr'] . " ");
|
||||
mysql_query("UPDATE interfaces SET ifVrf = '".$vrf_id."' WHERE interface_id = '".$interface['interface_id']."'");
|
||||
|
||||
}
|
||||
echo(") ");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user