mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge remote-tracking branch 'upstream/master' into rrd-create-remote
This commit is contained in:
@@ -1,192 +1,178 @@
|
||||
<?php
|
||||
|
||||
$i_i = '0';
|
||||
$i = 0;
|
||||
|
||||
echo '<table width=100% border=0 cellpadding=5>';
|
||||
|
||||
// Loop Instances
|
||||
echo '
|
||||
<div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed" style="border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Router ID</th>
|
||||
<th>Status</th>
|
||||
<th>ABR</th>
|
||||
<th>ASBR</th>
|
||||
<th>Areas</th>
|
||||
<th>Ports(Enabled)</th>
|
||||
<th>Neighbours</th>
|
||||
</tr>
|
||||
</thead>';
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', array($device['device_id'])) as $instance) {
|
||||
if (!is_integer($i_i / 2)) {
|
||||
$instance_bg = $list_colour_a;
|
||||
}
|
||||
else {
|
||||
$instance_bg = $list_colour_b;
|
||||
}
|
||||
|
||||
$i++;
|
||||
$area_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
|
||||
$nbr_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id']));
|
||||
|
||||
$query = 'SELECT * FROM ipv4_addresses AS A, ports AS I WHERE ';
|
||||
$query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)';
|
||||
$query .= ' AND I.device_id = ?';
|
||||
$ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id']));
|
||||
|
||||
$status_color = $abr_status_color = $asbr_status_color = 'default';
|
||||
|
||||
if ($instance['ospfAdminStat'] == 'enabled') {
|
||||
$enabled = '<span style="color: #00aa00">enabled</span>';
|
||||
}
|
||||
else {
|
||||
$enabled = '<span style="color: #aaaaaa">disabled</span>';
|
||||
$status_color = 'success';
|
||||
}
|
||||
|
||||
if ($instance['ospfAreaBdrRtrStatus'] == 'true') {
|
||||
$abr = '<span style="color: #00aa00">yes</span>';
|
||||
}
|
||||
else {
|
||||
$abr = '<span style="color: #aaaaaa">no</span>';
|
||||
$abr_status_color = 'success';
|
||||
}
|
||||
|
||||
if ($instance['ospfASBdrRtrStatus'] == 'true') {
|
||||
$asbr = '<span style="color: #00aa00">yes</span>';
|
||||
$asbr_status_color = 'success';
|
||||
}
|
||||
else {
|
||||
$asbr = '<span style="color: #aaaaaa">no</span>';
|
||||
}
|
||||
|
||||
echo '<tr><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr>';
|
||||
echo '<tr bgcolor="'.$instance_bg.'">';
|
||||
echo ' <td class="list-large">'.$instance['ospfRouterId'].'</td>';
|
||||
echo ' <td>'.$enabled.'</td>';
|
||||
echo ' <td>'.$abr.'</td>';
|
||||
echo ' <td>'.$asbr.'</td>';
|
||||
echo ' <td>'.$area_count.'</td>';
|
||||
echo ' <td>'.$port_count.'('.$port_count_enabled.')</td>';
|
||||
echo ' <td>'.$nbr_count.'</td>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr bgcolor="'.$instance_bg.'">';
|
||||
echo '<td colspan=7>';
|
||||
echo '<table width=100% border=0 cellpadding=5>';
|
||||
echo '<tr><th></th><th>Area Id</th><th>Status</th><th>Ports</th></tr>';
|
||||
|
||||
// # Loop Areas
|
||||
$i_a = 0;
|
||||
|
||||
echo '
|
||||
<tbody>
|
||||
<tr data-toggle="collapse" data-target="#ospf-panel' . $i . '" class="accordion-toggle">
|
||||
<td><button class="btn btn-default btn-xs"><span class="fa fa-plus"></span></button></td>
|
||||
<td>' . $instance['ospfRouterId'] . '</td>
|
||||
<td><span class="label label-' . $status_color . '">' . $instance['ospfAdminStat'] . '</span></td>
|
||||
<td><span class="label label-' . $abr_status_color . '">' . $instance['ospfAreaBdrRtrStatus'] . '</span></td>
|
||||
<td><span class="label label-' . $asbr_status_color . '">' . $instance['ospfASBdrRtrStatus'] . '</span></td>
|
||||
<td>' . $area_count . '</td>
|
||||
<td>' . $port_count . '(' . $port_count_enabled . ')</td>
|
||||
<td>' . $nbr_count . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="12" class="hiddenRow">
|
||||
<div class="accordian-body collapse" id="ospf-panel' . $i . '">
|
||||
<br>
|
||||
<div class="col-xs-4">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<h4><span class="label label-primary">Areas</span></h4>
|
||||
<tr>
|
||||
<th>Area ID</th>
|
||||
<th>Ports(Enabled)</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>';
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])) as $area) {
|
||||
if (!is_integer($i_a / 2)) {
|
||||
$area_bg = $list_colour_b_a;
|
||||
}
|
||||
else {
|
||||
$area_bg = $list_colour_b_b;
|
||||
}
|
||||
|
||||
|
||||
$area_port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?', array($device['device_id'], $area['ospfAreaId']));
|
||||
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
|
||||
|
||||
echo '
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>' . $area['ospfAreaId'] . '</td>
|
||||
<td>' . $area_port_count . '(' . $area_port_count_enabled . ')</td>
|
||||
<td><span class="label label-' . $status_color . '">' . $instance['ospfAdminStat'] . '</span></td>
|
||||
</tr>
|
||||
</tbody>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<h4><span class="label label-primary">Ports</span></h4>
|
||||
<tr>
|
||||
<th>Port</th>
|
||||
<th>Port Type</th>
|
||||
<th>Port State</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</div>';
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id", array($device['device_id'], $area['ospfAreaId'])) as $ospfport) {
|
||||
|
||||
echo '<tr bgcolor="'.$area_bg.'">';
|
||||
echo ' <td width=5></td>';
|
||||
echo ' <td class="list-large">'.$area['ospfAreaId'].'</td>';
|
||||
echo ' <td>'.$enabled.'</td>';
|
||||
echo ' <td>'.$area_port_count.'('.$area_port_count_enabled.')</td>';
|
||||
echo '</tr>';
|
||||
$port_status_color = 'default';
|
||||
|
||||
echo '<tr bgcolor="'.$area_bg.'">';
|
||||
echo '<td colspan=7>';
|
||||
echo '<table width=100% border=0 cellpadding=5>';
|
||||
echo '<tr><th></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr>';
|
||||
|
||||
// # Loop Ports
|
||||
$i_p = ($i_a + 1);
|
||||
$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
|
||||
foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) {
|
||||
if (!is_integer($i_a / 2)) {
|
||||
if (!is_integer($i_p / 2)) {
|
||||
$port_bg = $list_colour_b_b;
|
||||
}
|
||||
else {
|
||||
$port_bg = $list_colour_b_a;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!is_integer($i_p / 2)) {
|
||||
$port_bg = $list_colour_a_b;
|
||||
}
|
||||
else {
|
||||
$port_bg = $list_colour_a_a;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ospfport['ospfIfAdminStat'] == 'enabled') {
|
||||
$port_enabled = '<span style="color: #00aa00">enabled</span>';
|
||||
}
|
||||
else {
|
||||
$port_enabled = '<span style="color: #aaaaaa">disabled</span>';
|
||||
}
|
||||
|
||||
echo '<tr bgcolor="'.$port_bg.'">';
|
||||
echo ' <td width=15></td>';
|
||||
echo ' <td><strong>'.generate_port_link($ospfport).'</strong></td>';
|
||||
echo ' <td>'.$port_enabled.'</td>';
|
||||
echo ' <td>'.$ospfport['ospfIfType'].'</td>';
|
||||
echo ' <td>'.$ospfport['ospfIfState'].'</td>';
|
||||
echo '</tr>';
|
||||
|
||||
$i_p++;
|
||||
}//end foreach
|
||||
|
||||
echo '</table>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
$i_a++;
|
||||
} //end foreach
|
||||
|
||||
echo '<tr bgcolor="#ffffff"><th></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr>';
|
||||
|
||||
// Loop Neigbours
|
||||
$i_n = 1;
|
||||
if ($ospfport['ospfIfAdminStat'] == 'enabled') {
|
||||
$port_status_color = 'success';
|
||||
}
|
||||
|
||||
echo '
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>' . generate_port_link($ospfport) . '</td>
|
||||
<td>' . $ospfport['ospfIfType'] . '</td>
|
||||
<td>' . $ospfport['ospfIfState'] . '</td>
|
||||
<td><span class="label label-' . $port_status_color . '">' . $ospfport['ospfIfAdminStat'] . '</span></td>
|
||||
</tr>
|
||||
</tbody>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<h4><span class="label label-primary">Neighbours</span></h4>
|
||||
<tr>
|
||||
<th>Router ID</th>
|
||||
<th>Device</th>
|
||||
<th>IP Address</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>';
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])) as $nbr) {
|
||||
if (!is_integer($i_n / 2)) {
|
||||
$nbr_bg = $list_colour_b_a;
|
||||
}
|
||||
else {
|
||||
$nbr_bg = $list_colour_b_b;
|
||||
}
|
||||
|
||||
$host = @dbFetchRow(
|
||||
'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ?
|
||||
AND I.port_id = A.port_id AND D.device_id = I.device_id',
|
||||
array($nbr['ospfNbrRtrId'])
|
||||
);
|
||||
|
||||
$host = @dbFetchRow('SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($nbr['ospfNbrRtrId']));
|
||||
|
||||
$rtr_id = 'unknown';
|
||||
$ospfnbr_status_color = 'default';
|
||||
|
||||
if (is_array($host)) {
|
||||
$rtr_id = generate_device_link($host);
|
||||
}
|
||||
else {
|
||||
$rtr_id = 'unknown';
|
||||
|
||||
if ($nbr['ospfNbrState'] == 'full') {
|
||||
$ospfnbr_status_color = 'success';
|
||||
}
|
||||
elseif ($nbr['ospfNbrState'] == 'down') {
|
||||
$ospfnbr_status_color = 'danger';
|
||||
}
|
||||
|
||||
echo '<tr bgcolor="'.$nbr_bg.'">';
|
||||
echo ' <td width=5></td>';
|
||||
echo ' <td><span class="list-large">'.$nbr['ospfNbrRtrId'].'</span></td>';
|
||||
echo ' <td>'.$rtr_id.'</td>';
|
||||
echo ' <td>'.$nbr['ospfNbrIpAddr'].'</td>';
|
||||
echo ' <td>';
|
||||
switch ($nbr['ospfNbrState']) {
|
||||
case 'full':
|
||||
echo '<span class=green>'.$nbr['ospfNbrState'].'</span>';
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
echo '<span class=red>'.$nbr['ospfNbrState'].'</span>';
|
||||
break;
|
||||
|
||||
default:
|
||||
echo '<span class=blue>'.$nbr['ospfNbrState'].'</span>';
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
$i_n++;
|
||||
}//end foreach
|
||||
|
||||
echo '</table>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
$i_i++;
|
||||
} //end foreach
|
||||
|
||||
echo '</table>';
|
||||
echo '
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>' . $nbr['ospfNbrRtrId'] . '</td>
|
||||
<td>' . $rtr_id . '</td>
|
||||
<td>' . $nbr['ospfNbrIpAddr'] . '</td>
|
||||
<td><span class="label label-' . $ospfnbr_status_color . '">' . $nbr['ospfNbrState'] . '</span></td>
|
||||
</tr>
|
||||
</tbody>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
Reference in New Issue
Block a user