Skip to content

Commit 350642f

Browse files
committed
Various fixes to make this work with librenms
1 parent efec77c commit 350642f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bird_bgp.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ def OnUpdate(ax, axd, state):
4343
## register variables
4444
axd.RegisterVar('bgp', 0)
4545
axd.RegisterVar('bgpVersion', "10")
46-
axd.RegisterVar('bgpLocalAs', state.get("bgpLocalAs"))
46+
axd.RegisterVar('bgpLocalAs', 0)
47+
axd.RegisterVar('bgpLocalAs.0', state.get("bgpLocalAs"))
4748

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

5354
for snmpkey in BirdAgent.bgp_keys:
54-
#axd.RegisterVar(snmpkey, 0)
55+
axd.RegisterVar(snmpkey, 0)
5556
for peer in sorted(peers.keys(), BirdAgent.ipCompare):
5657
oid = "%s.%s"%(snmpkey, peer)
5758
if peers[peer].has_key(snmpkey):

birdagent.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, cfgfile, birdcli, netstatcmd="netstat -na"):
4040
}
4141

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

100100
bgp_defaults = {
101101
'bgpPeerIdentifier': SnmpIpAddress("0.0.0.0"),
102+
'bgpPeerLocalAddr': SnmpIpAddress("0.0.0.0"),
102103
'bgpPeerHoldTime': 0,
104+
'bgpPeerHoldTimeConfigured': 0,
103105
'bgpPeerKeepAlive': 0,
106+
'bgpPeerKeepAliveConfigured': 0,
104107
'bgpPeerState': 1,
105108
'bgpPeerInUpdates': SnmpCounter32(0),
106109
'bgpPeerOutUpdates': SnmpCounter32(0),
@@ -234,6 +237,7 @@ def getBGPState(self):
234237
match = self._re_birdcli_bgp_begin.search(line)
235238
if match:
236239
bgp_proto = match.group(1)
240+
state["bgp-peers"][bgp_proto] = {}
237241
timestamp = int(match.group(2))
238242
if not state["bgp-peers"].has_key(bgp_proto):
239243
print("WARNING: proto \"%s\" not in config, skipping"%bgp_proto)

0 commit comments

Comments
 (0)