2011-04-27 01:46:01 +00:00
<? php
2011-04-29 22:29:42 +00:00
2016-07-31 01:05:02 +02:00
$i = 0 ;
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>' ;
2015-07-10 13:36:21 +02:00
foreach ( dbFetchRows ( 'SELECT * FROM `ospf_instances` WHERE `device_id` = ?' , array ( $device [ 'device_id' ])) as $instance ) {
2016-07-31 01:05:02 +02:00
$i ++ ;
2015-07-10 13:36:21 +02:00
$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' ]));
2011-05-04 18:35:01 +00:00
2016-07-31 01:05:02 +02:00
$status_color = $abr_status_color = $asbr_status_color = 'default' ;
2019-05-11 23:33:55 +02:00
2015-07-10 13:36:21 +02:00
if ( $instance [ 'ospfAdminStat' ] == 'enabled' ) {
2016-07-31 01:05:02 +02:00
$status_color = 'success' ;
2015-07-10 13:36:21 +02:00
}
2011-04-29 22:29:42 +00:00
2015-07-10 13:36:21 +02:00
if ( $instance [ 'ospfAreaBdrRtrStatus' ] == 'true' ) {
2016-07-31 01:05:02 +02:00
$abr_status_color = 'success' ;
2015-07-10 13:36:21 +02:00
}
2011-04-29 22:29:42 +00:00
2015-07-10 13:36:21 +02:00
if ( $instance [ 'ospfASBdrRtrStatus' ] == 'true' ) {
2016-07-31 01:05:02 +02:00
$asbr_status_color = 'success' ;
2015-07-10 13:36:21 +02:00
}
2019-05-11 23:33:55 +02:00
2016-07-31 01:05:02 +02:00
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>' ;
2015-07-10 13:36:21 +02:00
foreach ( dbFetchRows ( 'SELECT * FROM `ospf_areas` WHERE `device_id` = ?' , array ( $device [ 'device_id' ])) as $area ) {
$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' ]));
2019-05-11 23:33:55 +02:00
2016-07-31 01:05:02 +02:00
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>
2019-05-11 23:33:55 +02:00
<th>Area ID</th>
2016-07-31 01:05:02 +02:00
</tr>
</thead>
</div>' ;
2019-05-11 23:33:55 +02:00
foreach ( dbFetchRows ( "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND P.port_id = O.port_id ORDER BY O.`ospfIfAreaId`" , array ( $device [ 'device_id' ])) as $ospfport ) {
2017-04-04 08:08:23 +01:00
$ospfport = cleanPort ( $ospfport );
2016-07-31 01:05:02 +02:00
$port_status_color = 'default' ;
if ( $ospfport [ 'ospfIfAdminStat' ] == 'enabled' ) {
$port_status_color = 'success' ;
2015-07-10 13:36:21 +02:00
}
2019-05-11 23:33:55 +02:00
2016-07-31 01:05:02 +02:00
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>
2019-05-11 23:33:55 +02:00
<td>' . $ospfport [ 'ospfIfAreaId' ] . '</td>
2016-07-31 01:05:02 +02:00
</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 ) {
$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' ]));
2019-05-11 23:33:55 +02:00
2016-07-31 01:05:02 +02:00
$rtr_id = 'unknown' ;
$ospfnbr_status_color = 'default' ;
2019-05-11 23:33:55 +02:00
2015-07-10 13:36:21 +02:00
if ( is_array ( $host )) {
$rtr_id = generate_device_link ( $host );
}
2016-07-31 01:05:02 +02:00
if ( $nbr [ 'ospfNbrState' ] == 'full' ) {
$ospfnbr_status_color = 'success' ;
2016-08-18 20:28:22 -05:00
} elseif ( $nbr [ 'ospfNbrState' ] == 'down' ) {
2016-07-31 01:05:02 +02:00
$ospfnbr_status_color = 'danger' ;
2015-07-10 13:36:21 +02:00
}
2016-07-31 01:05:02 +02:00
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>' ;