Module: check_mk
Branch: master
Commit: 799a8d86e6c879311907fbadfb4a791549e676f7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=799a8d86e6c879…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Tue Nov 27 11:26:05 2018 +0100
6897 juniper_gbp_state: Add IPv6 support
Previously the juniper_bgp_state check supported IPv4 addresses only.
This werk adds support for IPv6 addresses.
CMK-1334
Change-Id: I3937036f96b078044871255d671ee83784485e8c
---
.werks/6897 | 13 +++++++++++++
checks/juniper_bgp_state | 11 ++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/.werks/6897 b/.werks/6897
new file mode 100644
index 0000000..7a40ee5
--- /dev/null
+++ b/.werks/6897
@@ -0,0 +1,13 @@
+Title: juniper_gbp_state: Add IPv6 support
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1543314263
+Class: feature
+
+Previously the juniper_bgp_state check supported IPv4 addresses only.
+This werk adds support for IPv6 addresses.
+
+CMK-1334
diff --git a/checks/juniper_bgp_state b/checks/juniper_bgp_state
index ba1d3cb..3c55e68 100644
--- a/checks/juniper_bgp_state
+++ b/checks/juniper_bgp_state
@@ -26,7 +26,16 @@
def juniper_bgp_state_create_item(oid_end):
- return re.sub(r"[0-9]+\.1\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.1\.",
"", oid_end)
+ # supports IPv4 (e.g. 255.255.255.255) and
+ # IPv6 (e.g. 1762:0:0:0:0:B03:1:AF18)
+ ipv4_regex = r"[0-9]+\.1\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.1\."
+ ipv6_regex = r"^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$"
+ ipv4_match = re.match(ipv4_regex, oid_end)
+ if ipv4_match:
+ return ipv4_match.group()
+ ipv6_match = re.match(ipv6_regex, oid_end)
+ if ipv6_match:
+ return ipv6_match.group()
def inventory_juniper_bgp_state(info):