mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
better bgp / ipv6 display, remove some pear stuff
git-svn-id: http://www.observium.org/svn/observer/trunk@236 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -39,7 +39,13 @@
|
||||
while($ip = mysql_fetch_Array($ipdata)) {
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip[addr]')\">$ip[addr]/$ip[cidr]</a>");
|
||||
$break = "<br />";
|
||||
}
|
||||
}
|
||||
$ip6data = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
while($ip6 = mysql_fetch_Array($ip6data)) {
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip6[addr]')\">".Net_IPv6::compress($ip6[addr])."/$ip6[cidr]</a>");
|
||||
$break = "<br />";
|
||||
}
|
||||
|
||||
echo("</span>");
|
||||
echo("</td><td width=100>");
|
||||
if($interface['ifOperStatus'] == "up") {
|
||||
@@ -80,9 +86,12 @@ echo("</td>");
|
||||
if ( strpos($ifDescr, "oopback") === false && !$dographs) {
|
||||
$link_query = mysql_query("select * from links AS L, interfaces AS I, devices AS D WHERE L.src_if = '$if_id' AND L.dst_if = I.interface_id AND I.device_id = D.device_id");
|
||||
while($link = mysql_fetch_array($link_query)) {
|
||||
echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generateiflink($link, makeshortif($link['ifDescr'])) . " on " . generatedevicelink($link) . "</a><br />");
|
||||
$br = "<br />";
|
||||
# echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generateiflink($link, makeshortif($link['ifDescr'])) . " on " . generatedevicelink($link) . "</a><br />");
|
||||
# $br = "<br />";
|
||||
$int_links[$link['interface_id']] = $link['interface_id'];
|
||||
$int_links_phys[$link['interface_id']] = 1;
|
||||
}
|
||||
|
||||
unset($br);
|
||||
$adj_sql = "SELECT * FROM networks AS N, interfaces AS I, adjacencies AS A ";
|
||||
$adj_sql = $adj_sql . "WHERE I.interface_id = A.interface_id AND A.network_id = N.id ";
|
||||
@@ -92,29 +101,79 @@ echo("</td>");
|
||||
$network_id = $adjs['network_id'];
|
||||
$newsql = "SELECT * FROM adjacencies AS A, networks as N, interfaces as I, devices as D ";
|
||||
$newsql = $newsql . "WHERE N.id = '$network_id' AND A.network_id = N.id AND I.interface_id = A.interface_id AND D.device_id = I.device_id ";
|
||||
$newsql = $newsql . "AND D.device_id != '$device[id]' AND I.ifDescr NOT LIKE '%loopback%' GROUP BY D.device_id ORDER BY D.hostname";
|
||||
$newsql = $newsql . "AND D.device_id != '".$device['device_id']."' AND I.ifDescr NOT LIKE '%loopback%' GROUP BY D.device_id ORDER BY D.hostname";
|
||||
$new_query = mysql_query($newsql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
if ($new['status'] == '0') { $class = "red"; } else { $class = "blue"; }
|
||||
if ($new['ignore'] == '1') {
|
||||
$class = "grey";
|
||||
if ($new['status'] == '1') { $class = "green"; }
|
||||
}
|
||||
|
||||
$this_ifid = $new['interface_id'];
|
||||
$this_hostid = $new['device_id'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['ifDescr']);
|
||||
$wq = mysql_query("select count(*) FROM links WHERE dst_if = '$this_ifid' AND src_if = $if_id;");
|
||||
if (@mysql_result($wq, 0) == '0' && $this_hostname != $hostname) {
|
||||
$graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits'";
|
||||
echo("$br <img src='images/16/bullet_go.png' alt='Same Subnet' align=absmiddle />" . generateiflink($new, makeshortif($new['ifDescr'])) . " on " . generatedevicelink($new));
|
||||
$br = "<br />";
|
||||
}
|
||||
|
||||
$int_links[$this_ifid] = $this_ifid;
|
||||
$int_links_v4[$this_ifid] = 1;
|
||||
|
||||
|
||||
# if (@mysql_result($wq, 0) == '0' && $this_hostname != $hostname) {
|
||||
# $graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits'";
|
||||
# echo("$br <img src='images/16/bullet_go.png' alt='Same Subnet' align=absmiddle />" . generateiflink($new, makeshortif($new['ifDescr'])) . " on " . generatedevicelink($new));
|
||||
# $br = "<br />";
|
||||
# }
|
||||
}
|
||||
}
|
||||
unset($br);
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT network_id FROM ip6addr AS A, ip6networks AS N, interfaces AS I
|
||||
WHERE A.interface_id = I.interface_id
|
||||
AND A.network = N.cidr
|
||||
AND I.interface_id = '".$interface['interface_id']."'";
|
||||
|
||||
$nets_query = mysql_query($sql);
|
||||
|
||||
while($net = mysql_fetch_array($nets_query)) {
|
||||
$network_id = $net['network_id'];
|
||||
|
||||
$sql = "SELECT I.interface_id FROM ip6addr AS A, ip6networks AS N, interfaces AS I, devices AS D
|
||||
WHERE A.interface_id = I.interface_id
|
||||
AND A.network = N.cidr
|
||||
AND N.network_id = '".$net['network_id']."' AND D.device_id = I.device_id and D.device_id != '".$device['device_id']."'";
|
||||
|
||||
$new_query = mysql_query($sql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
|
||||
echo($new['network_id']);
|
||||
|
||||
$this_ifid = $new['interface_id'];
|
||||
$this_hostid = $new['device_id'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['ifDescr']);
|
||||
|
||||
$int_links[$this_ifid] = $this_ifid;
|
||||
$int_links_v6[$this_ifid] = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($int_links as $int_link) {
|
||||
|
||||
$interface = mysql_fetch_array(mysql_query("SELECT * from interfaces AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = '".$int_link."'"));
|
||||
|
||||
echo("$br");
|
||||
|
||||
if($int_links_phys[$int_link]) { echo("<img align=absmiddle src='images/16/connect.png'> "); } else {
|
||||
echo("<img align=absmiddle src='images/16/bullet_go.png'> "); }
|
||||
|
||||
echo("<b>" . generateiflink($interface, makeshortif($interface['ifDescr'])) . " on " . generatedevicelink($interface) );
|
||||
|
||||
if($int_links_v6[$int_link]) { echo(" <b style='color: #a10000;'>v6</b>"); }
|
||||
if($int_links_v4[$int_link]) { echo(" <b style='color: #00a100'>v4</b>"); }
|
||||
$br = "<br />";
|
||||
}
|
||||
|
||||
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
// If we're showing graphs, generate the graph and print the img tags
|
||||
|
||||
+13
-11
@@ -4,11 +4,11 @@
|
||||
|
||||
$i = "1";
|
||||
|
||||
if($view == "alerted") {
|
||||
if($_GET['view'] == "alerted") {
|
||||
$where = "";
|
||||
} elseif ($view == "external") {
|
||||
} elseif ($_GET['view'] == "external") {
|
||||
$where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs";
|
||||
} elseif ($view == "internal") {
|
||||
} elseif ($_GET['view'] == "internal") {
|
||||
$where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs";
|
||||
}
|
||||
|
||||
@@ -18,20 +18,22 @@
|
||||
|
||||
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
|
||||
if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $bg_colour = "#ffcccc"; }
|
||||
if($peer['bgpPeerAdminStatus'] == "start") { $admin_col = "green"; } else { $admin_col = "red"; $bg_colour = "#cccccc"; }
|
||||
if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $nobg_colour = "#ffcccc"; }
|
||||
if($peer['bgpPeerAdminStatus'] == "start") { $admin_col = "green"; } else { $admin_col = "gray"; }
|
||||
|
||||
if($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "<span style='color: #00f;'>iBGP</span>"; } else { $peer_type = "<span style='color: #0a0;'>eBGP</span>"; }
|
||||
if($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "<span style='color: #00f;'>iBGP</span>"; } else { $peer_type = "<span style='color: #0a0;'>eBGP</span>";
|
||||
if($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] =< '65535') { $peer_type = "<span style='color: #f00;'>Priv eBGP</span>"; }
|
||||
}
|
||||
|
||||
$peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
|
||||
|
||||
if($peerhost) { $peername = generatedevicelink($peerhost); } else { unset($peername); }
|
||||
if($peerhost) { $peername = generatedevicelink($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); }
|
||||
|
||||
echo("<tr bgcolor=$bg_colour>
|
||||
<td width=20><span class=list-large><center>$i</center></span></td>
|
||||
<td width=175>".generatedevicelink($peer)."</td>
|
||||
<td width=220><span class=list-large>" . $peer['bgpPeerIdentifier'] . "</span><br />".$peername."</td>
|
||||
<td width=50>$peer_type</td>
|
||||
<td width=30><span class=list-large><center>$i</center></span></td>
|
||||
<td width=150>".generatedevicelink($peer, shorthost($peer['hostname']))."</td>
|
||||
<td width=150><span class=list-large>" . $peer['bgpPeerIdentifier'] . "</span><br />".$peername."</td>
|
||||
<td width=50><b>$peer_type</b></td>
|
||||
<td><strong>AS" . $peer['bgpPeerRemoteAs'] . "</strong><br />" . $peer['astext'] . "</td>
|
||||
<td><strong><span style='color: $admin_col;'>" . $peer['bgpPeerAdminStatus'] . "<span><br /><span style='color: $col;'>" . $peer['bgpPeerState'] . "</span></strong></td>
|
||||
<td>" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "<br />
|
||||
|
||||
Reference in New Issue
Block a user