Module: check_mk
Branch: master
Commit: bbb853703df5eed60134ea9c7d69e6b92d5418b3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bbb853703df5ee…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 29 16:34:59 2017 +0200
Improved recent implicit connect/disconnect fix
Change-Id: I3b2c0b963d261f310761f0a65c55f00d873482f9
---
web/plugins/userdb/ldap.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 8973be6..4fb8dee 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -567,7 +567,7 @@ class LDAPUserConnector(UserConnector):
# In some environments, the connection to the LDAP server does not seem to
# be as stable as it is needed. So we try to repeat the query for three times.
# -> Don't retry when implicit connect is disabled
- tries_left = 2 if implicit_connect else 0
+ tries_left = 2
success = False
last_exc = None
while not success:
@@ -601,7 +601,7 @@ class LDAPUserConnector(UserConnector):
'within the ldap or adapt the limit settings of the LDAP server.'))
except (ldap.SERVER_DOWN, ldap.TIMEOUT, MKLDAPException), e:
last_exc = e
- if tries_left:
+ if implicit_connect and tries_left:
self.log(' Received %r. Retrying with clean connection...' % e)
self.disconnect()
time.sleep(0.5)
Module: check_mk
Branch: master
Commit: 3fdf8d8bbeb8630aefbb007a1dc905b1f6a4fbe0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3fdf8d8bbeb863…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 29 16:56:04 2017 +0200
LDAP discovery: Continue with origin connection (the one made with the origin server address) when discovery fails
Change-Id: Id306f772e5aacc683ba8e8dad7d9a749220ebf59
---
web/plugins/userdb/ldap.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 4fb8dee..046412f 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -298,9 +298,10 @@ class LDAPUserConnector(UserConnector):
continue
except Exception, e:
- self.log(' DISCOVERY: Failed to detect server from %r' % server)
+ self.log(' DISCOVERY: Failed to discover a better server than %r' % server)
log_exception()
- raise
+ self.log(' DISCOVERY: Try to continue with origin connection')
+ break # got a connection!
# Got no connection to any server
if self._ldap_obj is None:
Module: check_mk
Branch: master
Commit: cd36a82bb5f79865da7448e79ca10735e23143c7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cd36a82bb5f798…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Aug 29 16:59:21 2017 +0200
df.include: Make comments slightly less misleading
Change-Id: I46a93efe7b8595dc71b1313dd4f52b87f2f8610f
---
checks/df.include | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/checks/df.include b/checks/df.include
index 1fb5de2..d9e0a96 100644
--- a/checks/df.include
+++ b/checks/df.include
@@ -100,9 +100,6 @@ def df_inventory(mplist):
# compute warning and critical levels. Takes into account the size of
# the filesystem and the magic number. Since the size is only known at
# check time this function's result cannot be precompiled.
-# Note: this function is in our days only needed in order to support
-# old style params a'la (80, 90). As soon as we drop support for that
-# (can happen any decade now), we can get rid of this function.
def get_filesystem_levels(host, mountpoint, size_gb, params):
mega = 1024 * 1024
giga = mega * 1024
@@ -158,9 +155,12 @@ def get_filesystem_levels(host, mountpoint, size_gb, params):
if not found:
warn, crit = 100.0, 100.0 # entry not found in list
+ # Take into account magic scaling factor (third optional argument
+ # in check params). A factor of 1.0 changes nothing. Factor should
+ # be > 0 and <= 1. A smaller factor raises levels for big file systems
+ # bigger than 100 GB and lowers it for file systems smaller than 100 GB.
+ # Please run df_magic_factor.py to understand how it works.
- # If the magic factor is used, take disk size and magic factor
- # into account in order to move levels
magic = levels.get("magic")
# We need a way to disable the magic factor so check
# if magic not 1.0
@@ -298,12 +298,6 @@ def df_check_filesystem_single(hostname, mountpoint, size_mb, avail_mb, reserved
warn_mb, crit_mb = levels["levels_mb"]
warn_inode, crit_inode = levels["inodes_levels"]
- # Take into account magic scaling factor (third optional argument
- # in check params). A factor of 1.0 changes nothing. Factor should
- # be > 0 and <= 1. A smaller factor raises levels for big file systems
- # bigger than 100 GB and lowers it for file systems smaller than 100 GB.
- # Please run df_magic_factor.py to understand how it works.
-
used_hr = get_bytes_human_readable(used_mb * 1024 * 1024)
size_hr = get_bytes_human_readable(size_mb * 1024 * 1024)
# If both numbers end with both MB or GB or TB, then drop the first one
Module: check_mk
Branch: master
Commit: a80cd4be30e7d887050ac6a7c65089bccd12fdb4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a80cd4be30e7d8…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Aug 29 15:21:50 2017 +0200
Fixed manpage of netstat
A simple copy&paste mistake referenced to the windows plugin instead of linux/aix
Change-Id: Idc4336ae434eeefcd44ddc89ba868e6936ca393d
---
checkman/netstat | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/checkman/netstat b/checkman/netstat
index 32501fa..68dfd6d 100644
--- a/checkman/netstat
+++ b/checkman/netstat
@@ -4,15 +4,15 @@ catalog: os/networking
license: GPL
distribution: check_mk
description:
- This check evaluates the output of the {netstat} command on Linux and
- AIX and checks if there are established connections or listeners
- matching a given criteria.
+ This check evaluates the output of the {netstat} command on Linux and AIX
+ and checks if there are established connections or listeners matching a
+ given criteria.
The check returns {OK} state if the specified connection/listener is present,
and {CRIT} if not.
- This check needs the agent plugin {netstat_an.bat} to be installed.
+ This check needs the agent plugin {netstat.linux} or {netstat.aix} to
+ be installed.
item:
A user defined identifier of the connection.
-
Module: check_mk
Branch: master
Commit: 5966bf6c178d19792f54d50539c44da20f387081
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5966bf6c178d19…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 29 10:45:36 2017 +0200
5054 FIX SNMPv3 contextes were not always used during discovery
The SNMPv3 contextes configured for a host were not used correctly for the SNMP-GET
request made during service discovery. This has been fixed now. When a single OID
is requested by Check_MK all configured contextes for a check will be queried until
an answer is recevied using a context. e.g. in case you have configured two contextes
for a check, the first configured context will be queried first. In case it answers
with the OID, this value will be used. In case the requested OID does not exist in
this context, the next contex will be queried.
The check independent OIDs .1.3.6.1.2.1.1.1.0 and .1.3.6.1.2.1.1.2.0 will always
be queried without context.
Change-Id: I1c0a046c7c839c2109c536db3e40a6f83488c88d
---
.werks/5054 | 19 +++++++++++++++++++
cmk_base/classic_snmp.py | 19 ++++++++++---------
cmk_base/discovery.py | 2 +-
cmk_base/snmp.py | 32 ++++++++++++++++++++++----------
4 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/.werks/5054 b/.werks/5054
new file mode 100644
index 0000000..306cb1b
--- /dev/null
+++ b/.werks/5054
@@ -0,0 +1,19 @@
+Title: SNMPv3 contextes were not always used during discovery
+Level: 1
+Component: core
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1503996131
+Class: fix
+
+The SNMPv3 contextes configured for a host were not used correctly for the SNMP-GET
+request made during service discovery. This has been fixed now. When a single OID
+is requested by Check_MK all configured contextes for a check will be queried until
+an answer is recevied using a context. e.g. in case you have configured two contextes
+for a check, the first configured context will be queried first. In case it answers
+with the OID, this value will be used. In case the requested OID does not exist in
+this context, the next contex will be queried.
+
+The check independent OIDs .1.3.6.1.2.1.1.1.0 and .1.3.6.1.2.1.1.2.0 will always
+be queried without context.
diff --git a/cmk_base/classic_snmp.py b/cmk_base/classic_snmp.py
index 82cff9f..fa4a5d9 100644
--- a/cmk_base/classic_snmp.py
+++ b/cmk_base/classic_snmp.py
@@ -48,12 +48,10 @@ from cmk_base.exceptions import MKSNMPError
# | Implements the neccessary function for Check_MK |
# '----------------------------------------------------------------------'
-def walk(hostname, ip, oid, hex_plain = False, context_name = None):
+def walk(hostname, ip, oid, hex_plain=False, context_name=None):
protospec = _snmp_proto_spec(hostname)
portspec = _snmp_port_spec(hostname)
- command = _snmp_walk_command(hostname)
- if context_name != None:
- command += [ "-n", context_name ]
+ command = _snmp_walk_command(hostname, context_name)
command += [ "-OQ", "-OU", "-On", "-Ot", "%s%s%s" % (protospec, ip, portspec), oid ]
debug_cmd = [ "''" if a == "" else a for a in command ]
@@ -102,7 +100,7 @@ def walk(hostname, ip, oid, hex_plain = False, context_name = None):
return rowinfo
-def get(hostname, ipaddress, oid):
+def get(hostname, ipaddress, oid, context_name=None):
if oid.endswith(".*"):
oid_prefix = oid[:-2]
commandtype = "getnext"
@@ -112,7 +110,7 @@ def get(hostname, ipaddress, oid):
protospec = _snmp_proto_spec(hostname)
portspec = _snmp_port_spec(hostname)
- command = _snmp_base_command(commandtype, hostname) + \
+ command = _snmp_base_command(commandtype, hostname, context_name) + \
[ "-On", "-OQ", "-Oe", "-Ot",
"%s%s%s" % (protospec, ipaddress, portspec),
oid_prefix ]
@@ -168,8 +166,8 @@ def _snmp_proto_spec(hostname):
# Returns command lines for snmpwalk and snmpget including
# options for authentication. This handles communities and
# authentication for SNMP V3. Also bulkwalk hosts
-def _snmp_walk_command(hostname):
- return _snmp_base_command('walk', hostname) + [ "-Cc" ]
+def _snmp_walk_command(hostname, context_name):
+ return _snmp_base_command('walk', hostname, context_name) + [ "-Cc" ]
# if the credentials are a string, we use that as community,
@@ -181,7 +179,7 @@ def _snmp_walk_command(hostname):
# And if it is a six-tuple, it has the following additional arguments:
# (5) privacy protocol (DES|AES) (-x)
# (6) privacy protocol pass phrase (-X)
-def _snmp_base_command(what, hostname):
+def _snmp_base_command(what, hostname, context_name):
options = []
if what == 'get':
@@ -242,6 +240,9 @@ def _snmp_base_command(what, hostname):
if "retries" in settings:
options += [ "-r", "%d" % settings["retries"] ]
+ if context_name != None:
+ options += [ "-n", context_name ]
+
return command + options
#.
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 8e0e142..550f914 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -838,7 +838,7 @@ def snmp_scan(hostname, ipaddress, on_error = "ignore", for_inv=False):
if scan_function:
try:
def oid_function(oid, default_value=None):
- value = snmp.get_single_oid(hostname, ipaddress, oid)
+ value = snmp.get_single_oid(hostname, ipaddress, oid, check_type)
if value == None:
return default_value
else:
diff --git a/cmk_base/snmp.py b/cmk_base/snmp.py
index 3c57bd5..36d424a 100644
--- a/cmk_base/snmp.py
+++ b/cmk_base/snmp.py
@@ -206,7 +206,8 @@ def get_snmp_table(hostname, ip, check_type, oid_info, use_snmpwalk_cache):
return info
-def get_single_oid(hostname, ipaddress, oid):
+# Contextes can only be used when check_type is given.
+def get_single_oid(hostname, ipaddress, oid, check_type=None):
# New in Check_MK 1.1.11: oid can end with ".*". In that case
# we do a snmpgetnext and try to find an OID with the prefix
# in question. The *cache* is working including the X, however.
@@ -236,15 +237,26 @@ def get_single_oid(hostname, ipaddress, oid):
value = None
else:
- try:
- if config.is_inline_snmp_host(hostname):
- value = inline_snmp.get(hostname, oid, ipaddress=ipaddress)
- else:
- value = classic_snmp.get(hostname, ipaddress, oid)
- except:
- if cmk.debug.enabled():
- raise
- value = None
+ # get_single_oid() can only return a single value. When SNMPv3 is used with multiple
+ # SNMP contexts, all contextes will be queried until the first answer is received.
+ if check_type is not None and config.is_snmpv3_host(hostname):
+ snmp_contexts = _snmpv3_contexts_of(hostname, check_type)
+ else:
+ snmp_contexts = [None]
+
+ for context_name in snmp_contexts:
+ try:
+ if config.is_inline_snmp_host(hostname):
+ value = inline_snmp.get(hostname, oid, ipaddress=ipaddress, context_name=context_name)
+ else:
+ value = classic_snmp.get(hostname, ipaddress, oid, context_name=context_name)
+
+ if value is not None:
+ break # Use first received answer in case of multiple contextes
+ except:
+ if cmk.debug.enabled():
+ raise
+ value = None
if value != None:
console.vverbose("%s%s%s%s\n" % (tty.bold, tty.green, value, tty.normal))
Module: check_mk
Branch: master
Commit: 31137e1e66b051eb7a03e4e28e26468df72630b2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=31137e1e66b051…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 29 08:43:55 2017 +0200
LDAP: Fixed broken sync of nested groups
Change-Id: I22b92347506e141338c33c4beffb5e55fecf0c8e
---
web/plugins/userdb/ldap.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 200371f..35ff1ad 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -883,12 +883,12 @@ class LDAPUserConnector(UserConnector):
if not result:
continue # Skip groups which can not be found
- for dn, cn in result:
- matched_groups[dn] = cn
+ for dn, attrs in result:
+ matched_groups[dn] = attrs["cn"][0]
else:
# in case of asking with DNs in nested mode, the resulting objects have the
# cn set to None for all objects. We do not need it in that case.
- matched_groups[dn] = None
+ matched_groups[filter_val] = None
for dn, cn in matched_groups.items():
filt = '(&%s(memberOf:1.2.840.113556.1.4.1941:=%s))' % \