Skip to content

Commit

Permalink
Merge pull request mikenowak#1 from mikenowak/librenms
Browse files Browse the repository at this point in the history
Various fixes to make this work with librenms
  • Loading branch information
mikenowak authored Mar 23, 2018
2 parents efec77c + 350642f commit 528ba15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bird_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ def OnUpdate(ax, axd, state):
## register variables
axd.RegisterVar('bgp', 0)
axd.RegisterVar('bgpVersion', "10")
axd.RegisterVar('bgpLocalAs', state.get("bgpLocalAs"))
axd.RegisterVar('bgpLocalAs', 0)
axd.RegisterVar('bgpLocalAs.0', state.get("bgpLocalAs"))

# reindex by bgpPeerRemoteAddr
peers = {}
for peer in state["bgp-peers"].values():
peers[peer.get("bgpPeerRemoteAddr")] = peer

for snmpkey in BirdAgent.bgp_keys:
#axd.RegisterVar(snmpkey, 0)
axd.RegisterVar(snmpkey, 0)
for peer in sorted(peers.keys(), BirdAgent.ipCompare):
oid = "%s.%s"%(snmpkey, peer)
if peers[peer].has_key(snmpkey):
Expand Down
6 changes: 5 additions & 1 deletion birdagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, cfgfile, birdcli, netstatcmd="netstat -na"):
}

_re_config_include = re.compile("^include\s*\"(/[^\"]*)\".*$")
_re_config_bgp_proto_begin = re.compile("^protocol bgp ([a-zA-Z0-9_]+) \{$")
_re_config_bgp_proto_begin = re.compile("^protocol bgp ([a-zA-Z0-9_]+) .* \{$")
_re_config_local_as = re.compile("local ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) as ([0-9]+);")
_re_config_bgp_holdtime = re.compile("hold time ([0-9]+);")
_re_config_bgp_keepalive = re.compile("keepalive time ([0-9]+);")
Expand Down Expand Up @@ -99,8 +99,11 @@ def __init__(self, cfgfile, birdcli, netstatcmd="netstat -na"):

bgp_defaults = {
'bgpPeerIdentifier': SnmpIpAddress("0.0.0.0"),
'bgpPeerLocalAddr': SnmpIpAddress("0.0.0.0"),
'bgpPeerHoldTime': 0,
'bgpPeerHoldTimeConfigured': 0,
'bgpPeerKeepAlive': 0,
'bgpPeerKeepAliveConfigured': 0,
'bgpPeerState': 1,
'bgpPeerInUpdates': SnmpCounter32(0),
'bgpPeerOutUpdates': SnmpCounter32(0),
Expand Down Expand Up @@ -234,6 +237,7 @@ def getBGPState(self):
match = self._re_birdcli_bgp_begin.search(line)
if match:
bgp_proto = match.group(1)
state["bgp-peers"][bgp_proto] = {}
timestamp = int(match.group(2))
if not state["bgp-peers"].has_key(bgp_proto):
print("WARNING: proto \"%s\" not in config, skipping"%bgp_proto)
Expand Down

0 comments on commit 528ba15

Please sign in to comment.