Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peering import from SNMP #245

Open
paravoid opened this issue May 2, 2020 · 1 comment
Open

Peering import from SNMP #245

paravoid opened this issue May 2, 2020 · 1 comment
Assignees
Labels

Comments

@paravoid
Copy link

paravoid commented May 2, 2020

Environment

  • Peering Manager version: master

Proposed Functionality & Use Case

As an alternative to the NAPALM & Netbox/NAPALM peering import, it could perhaps be interesting to also support importing from SNMP as a more lightweight approach. An example code using the excellent snimpy library would be:

from snimpy.manager import Manager as M
from snimpy.manager import load
from snimpy.snmp import SNMPException

load("BGP4-MIB")

for router, community in …:
    m = M(host=router, community=community, version=2)

    try:
        peers = m.bgpPeerRemoteAs
        for ip, asn in peers.iteritems():
            …
    except SNMPException as e:
        …

Important caveat: this is IPv4-only. The IPv6 BGP MIB never got out of draft status and there are vendor-specific implementations for it. I tried to make this work with BGP4-V2-MIB-JUNIPER + our Juniper gear ~3 years ago and ran into a wall: I asked the snimpy author at the time, who didn't see anything wrong with his code, asked j-nsp, and got confirmation from Juniper that this was a bug on their implementation(!) and filed a PR internally. This was fixed in recent JunOS (18.1+), but requires extra config on the Juniper router (set protocols bgp snmp-options emit-inet-address-length-in-oid command). I never got to implement that codepath, though, or other vendors (like Cisco and Arista's). That needs some playing around from folks that own such equipment.

External Dependencies

  • snimpy
@gmazoyer gmazoyer self-assigned this May 2, 2020
@gmazoyer gmazoyer added the type: feature request Issue is an accepted feature request label May 2, 2020
@stale stale bot added the status: wontfix Not an issue, no fix to be done, no code to be changed label Jul 12, 2021
@peering-manager peering-manager deleted a comment from stale bot Jul 12, 2021
@stale stale bot removed the status: wontfix Not an issue, no fix to be done, no code to be changed label Jul 12, 2021
@borisski
Copy link

[snmp_poll_peering_sessions.py.txt](https://github.com/peering-manager/peering-manager/files/7234291/snmp_poll_peering_sessions.py.txt
router_config
)
Hello, I wrote a small snippet that grab info from snmp for CISCO router, you just need to put it in peering/management/commands/ and configure the snmp (only v2 supported at this time) in the router config context (as in the print screen). Script is based on easysnmp python library (much more faster as it is a binding of the net-snmp in C) and also require a further install on debian:
sudo apt-get install libsnmp-dev
sudo apt-get install snmp-mibs-downloader # optional
sudo apt-get install gcc python-dev
pip install easysnmp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants