Old BGP Session Removal

Is there anyway to remove old BGP Peers/Sessions from Librenms? I changed BGP Peers and still have the old BGP Peers & Sessions in Librenms.

Either they are still reported by your device via SNMP or they are stuck. You can delete all entries in the bgpPeers table and it should recreate them just fine.

Can I get the correct mysql command to do this?

lnms tinker --execute '\App\Models\BgpPeer::delete()' will delete all entries in the bgppeers table. Run discovery/polling to re-populate the table.

Do I have to run discovery/polling or can I just wait for the next poll?

Any way to delete specific BGP Peer from the table use the lnms tinker command?

Yes, or you could use mysql workbench or something to look at them and delete them in a gui.

Is there any additional documentation on the lmns tinker command for BgpPeer? If so, can you point me in the right direction?

Do I run this command with root or librenms user?

When I run it with librenms I get the following -

bash-4.2$ ./lnms tinker --execute ‘\App\Models\BgpPeer::delete()’

In Configuration.php line 580:

Unable to create PsySH runtime directory. Make sure PHP is able to write to /run/user/0 in order to continue.

So the answer is almost never root as far as LibreNMS is concerned.

Also, it seems to be trying to access a directory for user id 0, which is root. Usually this is because how you became the librenms user. You have to use su - librenms or similar to get a fresh user session and not inherit things from the root user.

Okay, I used su - librenms then tried the command again and here is the error I received -
-bash-4.2$ ./lnms tinker --execute ‘\App\Models\BgpPeer::delete()’
PHP Deprecated: Non-static method Illuminate/Database/Eloquent/Model::delete() should not be called statically in Psy Shell code on line 1
PHP Error: Using $this when not in object context in /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 949

Need to do some updating most likely.

That was the wrong one, it was supposed to be

./lnms tinker --execute ‘\App\Models\BgpPeer::truncate()

Okay, that removed all BGP Sessions. I just did a rediscovery on the device and waiting to see what happens.

Okay, that worked! You are the man!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.