commit version 22.12.12447

This commit is contained in:
2023-01-01 22:36:12 -05:00
parent af1b03d79f
commit b948283a96
744 changed files with 620715 additions and 27381 deletions

View File

@ -1,53 +1,94 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_title("OSPF");
$navbar = array();
$navbar = [];
$navbar['brand'] = "OSPF";
$navbar['class'] = "navbar-narrow";
$ospf_instances = dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id']));
echo generate_box_open();
echo '<table class="table table-hover table-striped table-condensed">';
// Loop Instances (There can only ever really be once instance at the moment, thanks to douchebags who decided we should use undiscoverable context names instead of just making tables.)
// There only 2 possible instances (V2/V3)
foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", [ $device['device_id'] ]) as $instance) {
foreach ($ospf_instances as $instance)
{
echo generate_box_open();
echo '<table class="table table-hover table-striped table-condensed">';
$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']));
$ospf_version = $instance['ospfVersionNumber'];
$query = "SELECT * FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `device_id` = ?";
//$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']));
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]);
if ($ospf_version !== 'version3') {
$instance_id = $instance['ospfRouterId'];
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-success">V2</span>'; }
// V2 always have 5 part index, ie: 95.130.232.140.0
$port_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
// V2 always have 5 part index, ie: .95.130.232.130.0
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
} else {
$instance_id = long2ip($instance['ospfRouterId']);
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-primary">V3</span>'; }
// V3 always have 2 part index, ie: 6.0
$port_params = [ $device['device_id'], '^[[:digit:]]+\.[[:digit:]]+$' ];
// V3 always have 3 part index, ie: .4.0.1602414725
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){2}$' ];
}
$port_count = 0;
$port_count_enabled = 0;
$sql = 'SELECT `ospfIfAdminStat`, COUNT(*) AS `count` FROM `ospf_ports`' .
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? GROUP BY `ospfIfAdminStat`';
foreach (dbFetchRows($sql, $port_params) as $entry) {
if ($entry['ospfIfAdminStat'] === 'enabled') {
$port_count_enabled = (int)$entry['count'];
}
$port_count += (int)$entry['count'];
}
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params);
if ($instance['ospfAdminStat'] == "enabled") { $enabled = '<span class="green">enabled</span>';
$row_class = 'up'; } else { $enabled = '<span class="grey">disabled</span>';
$row_class = "disabled"; }
if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span class="green">yes</span>'; } else { $abr = '<span class="grey">no</span>'; }
if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span class="green">yes</span>'; } else { $asbr = '<span class="grey">no</span>'; }
if ($instance['ospfAdminStat'] === "enabled") {
$enabled = '<span class="label label-success">enabled</span>';
$row_class = 'up';
} else {
$enabled = '<span class="label">disabled</span>';
$row_class = "disabled";
}
if ($instance['ospfAreaBdrRtrStatus'] === "true") {
$abr = '<span class="green">yes</span>';
} else {
$abr = '<span class="grey">no</span>';
}
if ($instance['ospfASBdrRtrStatus'] === "true") {
$asbr = '<span class="green">yes</span>';
} else {
$asbr = '<span class="grey">no</span>';
}
echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Router Id', 'style="width: 160px;"' ],
'Status',
'ABR',
'ASBR',
'Areas',
'Ports',
'Neighbours'
//'descr' => array('Description', 'style="width: 400px;"'),
//'rule' => 'Rule',
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
echo('<tr class="'.$row_class.'">');
echo(' <td class="state-marker"></td>');
echo(' <td class="entity-title">'.$instance['ospfRouterId'] . '</td>');
echo(' <td class="entity-title">' . $instance_id . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $abr . '</td>');
echo(' <td>' . $asbr . '</td>');
@ -64,22 +105,36 @@ foreach ($ospf_instances as $instance)
/// Global Areas Table
/// FIXME -- humanize_ospf_area()
echo generate_box_open(array('title' => 'Areas'));
echo generate_box_open([ 'title' => 'Areas' ]);
echo('<table class="table table-hover table-striped">');
echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Area Id', 'style="width: 160px;"' ],
'Status',
'Auth Type',
'AS External',
'Area LSAs',
'Area Summary',
'Ports'
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
/// Loop Areas
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $area)
{
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]) 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']));
$port_params[] = $area['ospfAreaId'];
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
$area_id = $ospf_version === 'version3' ? long2ip($area['ospfAreaId']) : $area['ospfAreaId'];
$area_row_class = $area['ospfAreaStatus'] === 'active' ? 'up' : 'disabled';
$enabled = $area['ospfAreaStatus'] === 'active' ? '<span class="label label-success">'.$area['ospfAreaStatus'].'</span>' : '<span class="label">'.$area['ospfAreaStatus'].'</span>';
echo('<tr class="'.$area_row_class.'">');
echo(' <td class="state-marker"></td>');
echo(' <td class="entity-title">'.$area['ospfAreaId'] . '</td>');
echo(' <td class="entity-title">' . $area_id . '</td>');
echo(' <td>' . $enabled . '</td>');
echo ' <td>' . $area['ospfAuthType'] . '</td>';
echo ' <td>' . $area['ospfImportAsExtern'] . '</td>';
@ -96,20 +151,28 @@ foreach ($ospf_instances as $instance)
echo generate_box_open();
echo('<table class="table table-hover table-striped table-condensed ">');
echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
echo('<table class="table table-hover table-striped table-condensed">');
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Port', 'style="width: 160px;"' ],
[ 'Status', 'style="width: 160px;"' ],
'Port Type',
'Port State'
];
echo get_table_header($cols, $vars);
//echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
///# Loop Ports
$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)
{
// Loop Ports
$p_sql = 'SELECT * FROM `ospf_ports` LEFT JOIN `ports` USING (`device_id`, `port_id`)' .
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ? AND `ospfIfAdminStat` = \'enabled\'';
//$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, $port_params) as $ospfport) {
if ($ospfport['ospfIfAdminStat'] == "enabled")
{
$port_enabled = '<span class="green">enabled</span>';
if ($ospfport['ospfIfAdminStat'] === "enabled") {
$port_enabled = '<span class="label label-success">enabled</span>';
$port_row_class = 'up';
} else {
$port_enabled = '<span class="green">disabled</span>';
$port_enabled = '<span class="label">'.$ospfport['ospfIfAdminStat'].'</span>';
$port_row_class = 'disabled';
}
@ -120,8 +183,6 @@ foreach ($ospf_instances as $instance)
echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
echo('</tr>');
$i_p++;
} // End loop Ports
echo('</table>');
@ -137,26 +198,41 @@ foreach ($ospf_instances as $instance)
/// Global Neighbour Table
/// FIXME -- humanize_ospf_neighbour()
echo generate_box_open(array('title' => 'Neighbours'));
echo generate_box_open([ 'title' => 'Neighbours' ]);
echo '<table class="table table-condensed table-hover table-striped">';
echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
echo '<table class="table table-condensed table-hover table-striped">';
$cols = [
[ NULL, 'class="state-marker"' ],
[ 'Router Id', 'style="width: 160px;"' ],
[ 'Device', 'style="width: 160px;"' ],
'IP Address',
'Status'
];
echo get_table_header($cols, $vars);
//echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
// Loop Neigbours
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']));
// Loop Neighbours
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params) as $nbr) {
if ($ospf_version !== 'version3') {
$nbr_router_id = $nbr['ospfNbrRtrId'];
} else {
$nbr_router_id = long2ip($nbr['ospfNbrRtrId']);
}
$host = dbFetchRow("SELECT `device_id`, `port_id` FROM `ipv4_addresses` WHERE `ipv4_address` = ?", [ $nbr_router_id ]);
if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; }
if (is_array($host)) {
$rtr_id = generate_device_link($host);
} else {
$rtr_id = '<span class="label">unknown</span>';
}
echo('<tr class="' . $port_row_class . '">');
echo(' <td class="state-marker"></td>');
echo(' <td><span class="entity-title">' . $nbr['ospfNbrRtrId'] . '</span></td>');
echo(' <td><span class="entity-title">' . $nbr_router_id . '</span></td>');
echo(' <td>' . $rtr_id . '</td>');
echo(' <td>' . $nbr['ospfNbrIpAddr'] . '</td>');
echo(' <td>' . ip_compress($nbr['ospfNbrIpAddr']) . '</td>');
echo(' <td>');
switch ($nbr['ospfNbrState'])
{
switch ($nbr['ospfNbrState']) {
case 'full':
echo('<span class="green">'.$nbr['ospfNbrState'].'</span>');
break;