Module: check_mk
Branch: master
Commit: 84c5a6b6f85907ee091d37b35f5ed55d6bf340b4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=84c5a6b6f85907…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Feb 27 09:57:43 2019 +0100
added WK6707: SNMP with IPv6only hosts: Fixed bug which caused connection errors
Change-Id: I1f7d0ae58a45429b9f74e5e1ecace445dad8ab14
---
.werks/6707 | 12 ++++++++++++
cmk_base/classic_snmp.py | 18 +++++++++++-------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/.werks/6707 b/.werks/6707
new file mode 100644
index 0000000..1194119
--- /dev/null
+++ b/.werks/6707
@@ -0,0 +1,12 @@
+Title: SNMP with IPv6only hosts: Fixed bug which caused connection errors
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1551188496
+
+IPv6 addresses were not correctly quoted with brackets, hereby causing
+connection errors with classic and inline-snmp connections.
diff --git a/cmk_base/classic_snmp.py b/cmk_base/classic_snmp.py
index eed8d95..ae63dd3 100644
--- a/cmk_base/classic_snmp.py
+++ b/cmk_base/classic_snmp.py
@@ -50,12 +50,13 @@ from cmk_base.exceptions import MKSNMPError
def walk(host_config, oid, hex_plain=False, context_name=None):
protospec = _snmp_proto_spec(host_config)
+
+ ipaddress = host_config.ipaddress
+ if protospec == "udp6:":
+ ipaddress = "[" + ipaddress + "]"
portspec = _snmp_port_spec(host_config)
command = _snmp_walk_command(host_config, context_name)
- command += [
- "-OQ", "-OU", "-On", "-Ot",
- "%s%s%s" % (protospec, host_config.ipaddress, portspec), oid
- ]
+ command += ["-OQ", "-OU", "-On", "-Ot",
"%s%s%s" % (protospec, ipaddress, portspec), oid]
console.vverbose("Running '%s'\n" %
subprocess.list2cmdline(command))
@@ -92,8 +93,8 @@ def walk(host_config, oid, hex_plain=False, context_name=None):
if exitstatus:
console.verbose(tty.red + tty.bold + "ERROR: " + tty.normal +
"SNMP error: %s\n" % error.strip())
- raise MKSNMPError("SNMP Error on %s: %s (Exit-Code: %d)" %
(host_config.ipaddress,
- error.strip(),
exitstatus))
+ raise MKSNMPError(
+ "SNMP Error on %s: %s (Exit-Code: %d)" % (ipaddress, error.strip(),
exitstatus))
return rowinfo
@@ -143,10 +144,13 @@ def get(host_config, oid, context_name=None):
commandtype = "get"
protospec = _snmp_proto_spec(host_config)
+ ipaddress = host_config.ipaddress
+ if protospec == "udp6:":
+ ipaddress = "[" + ipaddress + "]"
portspec = _snmp_port_spec(host_config)
command = _snmp_base_command(commandtype, host_config, context_name) + \
[ "-On", "-OQ", "-Oe", "-Ot",
- "%s%s%s" % (protospec, host_config.ipaddress, portspec),
+ "%s%s%s" % (protospec, ipaddress, portspec),
oid_prefix ]
console.vverbose("Running '%s'\n" %
subprocess.list2cmdline(command))