net/frr - BFD diagnostics in new style (#3487)

* BFD diagnostics in new style.

* Add tree support for BFD diagnostics.

* net/frr - cleanups for BFD diagnostics (https://github.com/opnsense/plugins/pull/3485).

* net/frr - cleanups for BFD diagnostics (https://github.com/opnsense/plugins/pull/3485).

parse summary data and wrap into bootgrid.

* net/frr - cleanups for BFD diagnostics (https://github.com/opnsense/plugins/pull/3485).

trim frr summary info.

---------

Co-authored-by: Mark O. Stitson <mark@stitson.com>
This commit is contained in:
Ad Schellevis
2023-06-27 17:48:24 +02:00
committed by GitHub
co-authored by Mark O. Stitson
parent c76693e952
commit ca9bd30a95
5 changed files with 102 additions and 1 deletions
@@ -237,7 +237,7 @@ class DiagnosticsController extends ApiControllerBase
public function searchOspfneighborAction(): array
{
$records = [];
$payload = $this->getInformation("ospf", "neighbor", "json")['response'];
$payload = $this->getInformation("ospf", "neighbor", "json");
if (!empty($payload['neighbors'])) {
foreach ($payload['neighbors'] as $neighborid => $neighbor) {
foreach ($neighbor as $item) {
@@ -312,4 +312,44 @@ class DiagnosticsController extends ApiControllerBase
{
return $this->getInformation("ospfv3", "interface", $format);
}
private function bfdTreeFetch($topic)
{
$records = [];
$payload = $this->getInformation("bfd", $topic, "json")['response'];
if (!empty($payload)) {
foreach ($payload as $peer) {
$peerid = $peer['peer'];
$records[$peerid] = $peer;
}
}
return ["response" => $records];
}
public function bfdsummaryAction(): array
{
$records = [];
foreach (explode("\n", $this->getInformation("bfd", "summary", "plain")['response']) as $line) {
$parts = preg_split('/\s+/', trim($line));
if (count($parts) == 4 && filter_var($parts[0], FILTER_VALIDATE_INT) !== false) {
$records[] = [
'id' => $parts[0],
'local' => $parts[1],
'peer' => $parts[2],
'status' => $parts[3]
];
}
}
return $this->searchRecordsetBase($records);
}
public function bfdneighborsAction(): array
{
return $this->bfdTreeFetch('neighbors');
}
public function bfdcountersAction(): array
{
return $this->bfdTreeFetch('counters');
}
}
@@ -95,6 +95,31 @@ class DiagnosticsController extends \OPNsense\Base\IndexController
$this->view->default_tab = 'routing';
$this->view->pick('OPNsense/Quagga/diagnostics');
}
public function bfdAction()
{
$this->view->tabs = [
[
'name' => 'summary',
'endpoint' => '/api/quagga/diagnostics/bfdsummary',
'tabhead' => gettext('Summary'),
'type' => 'bfdsummary'
],
[
'name' => 'neighbors',
'endpoint' => '/api/quagga/diagnostics/bfdneighbors',
'tabhead' => gettext('Neighbors'),
'type' => 'tree'
],
[
'name' => 'counters',
'endpoint' => '/api/quagga/diagnostics/bfdcounters',
'tabhead' => gettext('Counters'),
'type' => 'tree'
]
];
$this->view->default_tab = 'summary';
$this->view->pick('OPNsense/Quagga/diagnostics');
}
public function ospfv3Action()
{
$this->view->pick('OPNsense/Quagga/diagnosticsospfv3');
@@ -12,6 +12,7 @@
<OSPF VisibleName="OSPF" url="/ui/quagga/diagnostics/ospf" order="20" />
<OSPFv3 VisibleName="OSPFv3" url="/ui/quagga/diagnostics/ospfv3" order="25" />
<BGP VisibleName="BGP" url="/ui/quagga/diagnostics/bgp" order="40" />
<BFD VisibleName="BFD" url="/ui/quagga/diagnostics/bfd" order="50" />
<LOG VisibleName="Log" url="/ui/diagnostics/log/routing/frr" order="100" />
</Diagnostics>
</Routing>
@@ -86,6 +86,7 @@ POSSIBILITY OF SUCH DAMAGE.
{% case 'bgproutetable' %}
{% case 'ospfroutetable' %}
{% case 'ospfneighbors' %}
{% case 'bfdsummary' %}
if (all_grids["{{ tab['name'] }}"] === undefined) {
/**
* initialize bootgrid table for {{ tab['tabhead'] }}
@@ -320,6 +321,22 @@ POSSIBILITY OF SUCH DAMAGE.
</table>
</div>
{% break %}
{% case 'bfdsummary' %}
<div class="col-sm-12">
<table id="grid-{{ tab['name'] }}" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="id">{{ lang._('SessionId') }}</th>
<th data-column-id="local" data-searchable="false">{{ lang._('LocalAddress') }}</th>
<th data-column-id="peer">{{ lang._('PeerAddress') }}</th>
<th data-column-id="status" data-searchable="false">{{ lang._('Status') }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
{% break %}
{% case 'tree' %}
<div class="searchbox">
<input
@@ -221,6 +221,24 @@ parameters:
type:script_output
message:FRR diagnostics "show ip ospf interface json"
[diagnostics.bfd_neighbors_json]
command:/usr/local/bin/vtysh -c "show bfd peers json"
parameters:
type:script_output
message:FRR diagnostics "show bfd peers json"
[diagnostics.bfd_summary]
command:/usr/local/bin/vtysh -c "show bfd peers brief"
parameters:
type:script_output
message:FRR diagnostics "show bfd peers brief"
[diagnostics.bfd_counters_json]
command:/usr/local/bin/vtysh -c "show bfd peers counters json"
parameters:
type:script_output
message:FRR diagnostics "show bfd peers counters json"
[diagnostics.ospfv3_overview]
command:/usr/local/bin/vtysh -c "show ipv6 ospf6"
parameters: