mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS (#15535)
* Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS * Added extra space * Reverted back to overlibLink (due to BGP update graphs on hover) * Added extra space * Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer) * Removed unnecessary/unused code * Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer), replaced with just a DeviceLinks * Change Url::deviceLink to return $text if the device doesn't exist. Default to '' Import some of the things to improve readability. * update phpdoc --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
parent
05a5fbc5b5
commit
d5c6d0aaf4
@ -39,8 +39,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
class Url
|
||||
{
|
||||
/**
|
||||
* @param Device $device
|
||||
* @param string $text
|
||||
* @param Device|null $device
|
||||
* @param string|null $text
|
||||
* @param array $vars
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
@ -48,10 +48,10 @@ class Url
|
||||
* @param int $overlib
|
||||
* @return string
|
||||
*/
|
||||
public static function deviceLink($device, $text = null, $vars = [], $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
|
||||
public static function deviceLink($device, $text = '', $vars = [], $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
|
||||
{
|
||||
if (! $device instanceof Device || ! $device->hostname) {
|
||||
return '';
|
||||
return (string) $text;
|
||||
}
|
||||
|
||||
if (! $device->canAccess(Auth::user())) {
|
||||
|
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\IPv6;
|
||||
use LibreNMS\Util\Number;
|
||||
use LibreNMS\Util\Time;
|
||||
use LibreNMS\Util\Url;
|
||||
|
||||
if (! Auth::user()->hasGlobalRead()) {
|
||||
include 'includes/html/error-no-perm.inc.php';
|
||||
@ -272,26 +276,26 @@ if (! Auth::user()->hasGlobalRead()) {
|
||||
// display overlib graphs
|
||||
$graph_array = [];
|
||||
$graph_array['type'] = 'bgp_updates';
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$graph_array['to'] = \LibreNMS\Config::get('time.now');
|
||||
$graph_array['from'] = \LibreNMS\Config::get('time.day');
|
||||
$graph_array['height'] = '110';
|
||||
$graph_array['width'] = $width;
|
||||
|
||||
// Peer Address
|
||||
$peer_device = Device::whereHas('bgppeers', fn ($q) => $q->where('bgpLocalAddr', $peer['bgpPeerIdentifier']))->first();
|
||||
$peeraddresslink = '<span class=list-large>' . Url::deviceLink($peer_device, $peer_addr, ['tab' => 'routing', 'proto' => 'bgp']) . '</span>';
|
||||
|
||||
// Local Address
|
||||
$graph_array['id'] = $peer['bgpPeer_id'];
|
||||
$graph_array['afi'] = 'ipv4';
|
||||
$graph_array['safi'] = 'unicast';
|
||||
$graph_array_zoom = $graph_array;
|
||||
$graph_array_zoom['height'] = '150';
|
||||
$graph_array_zoom['width'] = '500';
|
||||
$overlib_link = 'device/device=' . $peer['device_id'] . '/tab=routing/proto=bgp/';
|
||||
$peeraddresslink = '<span class=list-large>' . \LibreNMS\Util\Url::overlibLink($overlib_link, $peer_addr, \LibreNMS\Util\Url::graphTag($graph_array_zoom)) . '</span>';
|
||||
|
||||
// Local Address
|
||||
$graph_array['afi'] = 'ipv4';
|
||||
$graph_array['safi'] = 'unicast';
|
||||
$graph_array_zoom['afi'] = 'ipv4';
|
||||
$graph_array_zoom['safi'] = 'unicast';
|
||||
$overlib_link = 'device/device=' . $peer['device_id'] . '/tab=routing/proto=bgp/';
|
||||
$localaddresslink = '<span class=list-large>' . \LibreNMS\Util\Url::overlibLink($overlib_link, $local_addr, \LibreNMS\Util\Url::graphTag($graph_array_zoom)) . '</span>';
|
||||
$localaddresslink = '<span class=list-large>' . Url::overlibLink($overlib_link, $local_addr, Url::graphTag($graph_array_zoom)) . '</span>';
|
||||
|
||||
if ($peer['bgpPeerLastErrorCode'] == 0 && $peer['bgpPeerLastErrorSubCode'] == 0) {
|
||||
$last_error = $peer['bgpPeerLastErrorText'];
|
||||
@ -313,21 +317,20 @@ if (! Auth::user()->hasGlobalRead()) {
|
||||
}
|
||||
|
||||
unset($sep);
|
||||
$peer_device = \App\Models\Device::whereHas('bgppeers', fn ($q) => $q->where('bgpLocalAddr', $peer['bgpPeerIdentifier']))->first();
|
||||
|
||||
echo ' <td></td>
|
||||
<td width=150>' . $localaddresslink . '<br />' . generate_device_link($peer, null, ['tab' => 'routing', 'proto' => 'bgp']) . '</td>
|
||||
<td width=30><b>»</b></td>
|
||||
<td width=150>' . $peeraddresslink . '<br />' . \LibreNMS\Util\Url::deviceLink($peer_device, vars: ['tab' => 'routing', 'proto' => 'bgp']) . "</td>
|
||||
<td width=150>' . $peeraddresslink . '<br />' . Url::deviceLink($peer_device, vars: ['tab' => 'routing', 'proto' => 'bgp']) . "</td>
|
||||
<td width=50><b>$peer_type</b></td>
|
||||
<td width=50>" . $peer['afi'] . '</td>
|
||||
<td><strong>AS' . $peer['bgpPeerRemoteAs'] . '</strong><br />' . $peer['astext'] . '</td>
|
||||
<td>' . $peer['bgpPeerDescr'] . "</td>
|
||||
<td><strong><span style='color: $admin_col;'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: $col;'>" . $peer['bgpPeerState'] . '</span></strong></td>
|
||||
<td>' . $last_error . '</td>
|
||||
<td>' . \LibreNMS\Util\Time::formatInterval($peer['bgpPeerFsmEstablishedTime']) . "<br />
|
||||
Updates <i class='fa fa-arrow-down icon-theme' aria-hidden='true'></i> " . \LibreNMS\Util\Number::formatSi($peer['bgpPeerInUpdates'], 2, 3, '') . "
|
||||
<i class='fa fa-arrow-up icon-theme' aria-hidden='true'></i> " . \LibreNMS\Util\Number::formatSi($peer['bgpPeerOutUpdates'], 2, 3, '') . '</td></tr>';
|
||||
<td>' . Time::formatInterval($peer['bgpPeerFsmEstablishedTime']) . "<br />
|
||||
Updates <i class='fa fa-arrow-down icon-theme' aria-hidden='true'></i> " . Number::formatSi($peer['bgpPeerInUpdates'], 2, 3, '') . "
|
||||
<i class='fa fa-arrow-up icon-theme' aria-hidden='true'></i> " . Number::formatSi($peer['bgpPeerOutUpdates'], 2, 3, '') . '</td></tr>';
|
||||
|
||||
unset($invalid);
|
||||
switch ($vars['graph']) {
|
||||
|
Loading…
Reference in New Issue
Block a user