mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 10:58:42 +00:00
Update bgp-peers.inc.php
This commit is contained in:
parent
886fcaf04c
commit
5e540ff6cd
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
if ($config['enable_bgp']) {
|
||||
// Discover BGP peers
|
||||
echo 'BGP Sessions : ';
|
||||
@ -14,13 +13,11 @@ if ($config['enable_bgp']) {
|
||||
$bgpLocalAs = trim(snmp_walk($device, '.1.3.6.1.2.1.15.2', '-Oqvn', 'BGP4-MIB', $config['mibdir']));
|
||||
|
||||
foreach ($vrfs_lite_cisco as $vrf) {
|
||||
$device['context_name'] = $vrf['context_name'];
|
||||
|
||||
$device['context_name'] = $vrf['context_name'];
|
||||
if (is_numeric($bgpLocalAs)) {
|
||||
echo "AS$bgpLocalAs ";
|
||||
|
||||
if ($bgpLocalAs != $device['bgpLocalAs']) {
|
||||
dbUpdate(array('bgpLocalAs' => $bgpLocalAs,'context_name' => $device['context_name']), 'devices', 'device_id=?', array($device['device_id']));
|
||||
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo 'Updated AS ';
|
||||
}
|
||||
|
||||
@ -92,7 +89,7 @@ if ($config['enable_bgp']) {
|
||||
}
|
||||
}
|
||||
|
||||
// Process disovered peers
|
||||
// Process disovered peers
|
||||
if (isset($peerlist)) {
|
||||
foreach ($peerlist as $peer) {
|
||||
$astext = get_astext($peer['as']);
|
||||
@ -217,12 +214,11 @@ if ($config['enable_bgp']) {
|
||||
}
|
||||
|
||||
// Delete removed peers
|
||||
$sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
|
||||
$sql = "SELECT * FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND context_name = '".$device['context_name']."'";
|
||||
|
||||
foreach (dbFetchRows($sql) as $entry) {
|
||||
unset($exists);
|
||||
$i = 0;
|
||||
|
||||
while ($i < count($peerlist) && !isset($exists)) {
|
||||
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
|
||||
$exists = 1;
|
||||
@ -241,8 +237,9 @@ if ($config['enable_bgp']) {
|
||||
unset($peerlist);
|
||||
|
||||
echo "\n";
|
||||
unset($device['context_name']);
|
||||
unset($device['context_name']);
|
||||
}
|
||||
unset($device['context_name']);
|
||||
unset($vrfs_c);
|
||||
}
|
||||
echo "FIN BGP \n\n\n";
|
||||
|
Loading…
Reference in New Issue
Block a user