Cleanup enable bgp setting (#14931)

* remove logic in module

* remove enable_bgp logic

* remove enable_bgp logic

* remove enable_bgp logic

* remove enable_bgp logic

* remove enable_bgp definition

* remove enable_bgp logic

* Remove enable_bgp documentation

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI

* StyleCI
This commit is contained in:
Justin Lentz
2023-04-06 21:01:21 -05:00
committed by GitHub
parent bbe752b24a
commit df31be30c1
8 changed files with 1170 additions and 1190 deletions

View File

@@ -63,13 +63,11 @@ class OverviewController extends Controller
->get();
// TODO: is inAlarm() equal to: bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' ?
if (Config::get('enable_bgp')) {
$bgp_down = BgpPeer::hasAccess(Auth::user())
->inAlarm()
->limit(Config::get('front_page_down_box_limit'))
->with('device')
->get();
}
if (filter_var(Config::get('uptime_warning'), FILTER_VALIDATE_FLOAT) !== false
&& Config::get('uptime_warning') > 0

View File

@@ -657,7 +657,6 @@ Please refer to [Billing](../Extensions/Billing-Module.md)
## Global module support
```bash
lnms config:set enable_bgp true # Enable BGP session collection and display
lnms config:set enable_syslog false # Enable Syslog
lnms config:set enable_inventory true # Enable Inventory
lnms config:set enable_pseudowires true # Enable Pseudowires

View File

@@ -4,19 +4,18 @@ use LibreNMS\Config;
use LibreNMS\Exceptions\InvalidIpException;
use LibreNMS\Util\IP;
if (Config::get('enable_bgp')) {
//
// Load OS specific file
//
if (file_exists(Config::get('install_dir') . "/includes/discovery/bgp-peers/{$device['os']}.inc.php")) {
//
// Load OS specific file
//
if (file_exists(Config::get('install_dir') . "/includes/discovery/bgp-peers/{$device['os']}.inc.php")) {
include Config::get('install_dir') . "/includes/discovery/bgp-peers/{$device['os']}.inc.php";
}
}
if (empty($bgpLocalAs)) {
if (empty($bgpLocalAs)) {
$bgpLocalAs = snmp_getnext($device, 'bgpLocalAs', '-OQUsv', 'BGP4-MIB');
}
}
foreach (DeviceCache::getPrimary()->getVrfContexts() as $context_name) {
foreach (DeviceCache::getPrimary()->getVrfContexts() as $context_name) {
$device['context_name'] = $context_name;
$peer2 = false;
$peers_data = '';
@@ -174,27 +173,26 @@ if (Config::get('enable_bgp')) {
$peerlist,
$af_data
);
}
}
// delete unknown contexts
$contexts = dbFetchColumn(
// delete unknown contexts
$contexts = dbFetchColumn(
'SELECT DISTINCT context_name FROM bgpPeers WHERE device_id=?',
[$device['device_id']]
);
);
$existing_contexts = DeviceCache::getPrimary()->getVrfContexts();
foreach ($contexts as $context) {
$existing_contexts = DeviceCache::getPrimary()->getVrfContexts();
foreach ($contexts as $context) {
if (! in_array($context, $existing_contexts)) {
dbDelete('bgpPeers', 'device_id=? and context_name=?', [$device['device_id'], $context]);
dbDelete('bgpPeers_cbgp', 'device_id=? and context_name=?', [$device['device_id'], $context]);
echo '-';
}
}
}
unset(
unset(
$device['context_name'],
$peers_data,
$af_data,
$contexts
);
}
);

View File

@@ -29,8 +29,7 @@ use App\Models\Vrf;
use LibreNMS\Config;
use LibreNMS\Util\IP;
if (Config::get('enable_bgp')) {
if ($device['os'] == 'dell-os10') {
if ($device['os'] == 'dell-os10') {
$bgpPeersCache = snmpwalk_cache_multi_oid($device, 'os10bgp4V2PeerTable', [], 'DELLEMC-OS10-BGP4V2-MIB', 'dell');
foreach ($bgpPeersCache as $key => $value) {
$oid = explode('.', $key);
@@ -116,5 +115,4 @@ if (Config::get('enable_bgp')) {
}
unset($bgpPeers);
// No return statement here, so standard BGP mib will still be polled after this file is executed.
}
}

View File

@@ -27,8 +27,7 @@
use LibreNMS\Config;
use LibreNMS\Util\IP;
if (Config::get('enable_bgp')) {
if ($device['os'] == 'timos') {
if ($device['os'] == 'timos') {
$bgpPeersCache = snmpwalk_cache_multi_oid($device, 'tBgpPeerNgTable', [], 'TIMETRA-BGP-MIB', 'nokia');
foreach ($bgpPeersCache as $key => $value) {
$oid = explode('.', $key);
@@ -97,5 +96,4 @@ if (Config::get('enable_bgp')) {
}
unset($bgpPeers);
// No return statement here, so standard BGP mib will still be polled after this file is executed.
}
}

View File

@@ -27,17 +27,16 @@
use LibreNMS\Config;
use LibreNMS\Util\IP;
if (Config::get('enable_bgp')) {
$bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerRemoteAs', [], 'HUAWEI-BGP-VPN-MIB');
$bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerRemoteAs', [], 'HUAWEI-BGP-VPN-MIB');
if (count($bgpPeersCache) == 0) {
if (count($bgpPeersCache) == 0) {
//Either we have no BGP peer, or this VRP device does not support Huawei's own BGP MIB
//Let's compare with standard BGP4-MIB.
$bgpPeersCache_ietf = snmpwalk_cache_oid($device, 'bgpPeerRemoteAs', [], 'BGP4-MIB');
}
}
// So if we have HUAWEI BGP entries or if we don't have anything from HUAWEI nor BGP4-MIB
if (count($bgpPeersCache) > 0 || count($bgpPeersCache_ietf) == 0) {
// So if we have HUAWEI BGP entries or if we don't have anything from HUAWEI nor BGP4-MIB
if (count($bgpPeersCache) > 0 || count($bgpPeersCache_ietf) == 0) {
$vrfs = DeviceCache::getPrimary()->vrfs()->select('vrf_id', 'vrf_name')->get();
foreach ($vrfs as $vrf) {
$map_vrf['byId'][$vrf['vrf_id']]['vrf_name'] = $vrf['vrf_name'];
@@ -167,6 +166,5 @@ if (Config::get('enable_bgp')) {
if ($vrp_bgp_peer_count > 0) {
return; //Finish BGP discovery here, cause we already collected data with Huawei MIBs
}
}
// If not, we continue with standard BGP4 MIB
}
// If not, we continue with standard BGP4 MIB

View File

@@ -5,10 +5,9 @@ use LibreNMS\Exceptions\InvalidIpException;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\IP;
if (\LibreNMS\Config::get('enable_bgp')) {
$peers = dbFetchRows('SELECT * FROM `bgpPeers` AS B LEFT JOIN `vrfs` AS V ON `B`.`vrf_id` = `V`.`vrf_id` WHERE `B`.`device_id` = ?', [$device['device_id']]);
$peers = dbFetchRows('SELECT * FROM `bgpPeers` AS B LEFT JOIN `vrfs` AS V ON `B`.`vrf_id` = `V`.`vrf_id` WHERE `B`.`device_id` = ?', [$device['device_id']]);
if (! empty($peers)) {
if (! empty($peers)) {
$generic = false;
if ($device['os'] == 'junos') {
$peer_data_check = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerIndex', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14', [], 'BGP4-V2-MIB-JUNIPER', 'junos');
@@ -448,7 +447,6 @@ if (\LibreNMS\Config::get('enable_bgp')) {
$peer_data['bgpPeerIface'] = null;
}
}
d_echo($peer_data);
} catch (InvalidIpException $e) {
// ignore
@@ -626,7 +624,6 @@ if (\LibreNMS\Config::get('enable_bgp')) {
}//end if
if ($device['os_group'] === 'arista') {
$safis['unicast'] = 1;
$safis['multicast'] = 2;
$afis['ipv4'] = 1;
$afis['ipv6'] = 2;
@@ -766,7 +763,6 @@ if (\LibreNMS\Config::get('enable_bgp')) {
->addDataset('AdvertisedPrefixes', 'GAUGE', null, 100000000000)
->addDataset('SuppressedPrefixes', 'GAUGE', null, 100000000000)
->addDataset('WithdrawnPrefixes', 'GAUGE', null, 100000000000);
$fields = [
'AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes,
'DeniedPrefixes' => $cbgpPeerDeniedPrefixes,
@@ -787,7 +783,6 @@ if (\LibreNMS\Config::get('enable_bgp')) {
} //end if
echo "\n";
} //end foreach
} //end if
} //end if
unset($peers, $peer_data_tmp, $j_prefixes);

View File

@@ -1584,10 +1584,6 @@
"order": 1,
"type": "text"
},
"enable_bgp": {
"default": true,
"type": "boolean"
},
"enable_billing": {
"default": false,
"type": "boolean"