Module: check_mk
Branch: master
Commit: da8cf4709a76240d355504e760adec95572dd29d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da8cf4709a7624…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 17 13:25:23 2015 +0200
#2469 FIX Fixed service discovery on SNMP host having no system description OID
---
.werks/2469 | 10 ++++++++++
ChangeLog | 1 +
checks/snmp_info | 2 +-
checks/snmp_uptime | 2 +-
modules/check_mk.py | 22 +++++++++++++++-------
modules/discovery.py | 5 +++++
6 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/.werks/2469 b/.werks/2469
new file mode 100644
index 0000000..e2815cb
--- /dev/null
+++ b/.werks/2469
@@ -0,0 +1,10 @@
+Title: Fixed service discovery on SNMP host having no system description OID
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1437132300
+
+
diff --git a/ChangeLog b/ChangeLog
index b256165..77615e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,6 +59,7 @@
* 2404 FIX: apache_status: now able to handle BusyServers and IdleServers...
* 2406 FIX: fileinfo: fixed missing size performance data for very large (e.g 2TB)
files and fileinfo groups...
* 2450 FIX: citrix_serverload: Changed representation of load to percent in rule and
graphs, added perfometer
+ * 2469 FIX: Fixed service discovery on SNMP host having no system description OID
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/checks/snmp_info b/checks/snmp_info
index f038a4e..bd16052 100644
--- a/checks/snmp_info
+++ b/checks/snmp_info
@@ -42,5 +42,5 @@ check_info["snmp_info"] = {
'inventory_function': inventory_snmp_info,
'service_description': 'SNMP Info',
'snmp_info': ('.1.3.6.1.2.1.1', ['1.0',
'4.0', '5.0', '6.0']),
- 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.1.0") !=
None,
+ 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.1.0")
not in [ None, "" ],
}
diff --git a/checks/snmp_uptime b/checks/snmp_uptime
index f2dde6b..a1ba8ee 100644
--- a/checks/snmp_uptime
+++ b/checks/snmp_uptime
@@ -40,7 +40,7 @@ check_info["snmp_uptime"] = {
'service_description' : 'Uptime',
'has_perfdata' : True,
'snmp_info' : ('.1.3.6.1.2.1.1', ['3.0']), #
DISMAN-EVENT-MIB::sysUpTime
- 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.1.0") !=
None,
+ 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.1.0")
not in [ None, "" ],
'group' : 'uptime',
'includes' : [ 'uptime.include' ],
}
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 86ce3c3..38ffbc1 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -811,6 +811,19 @@ def snmp_get_oid(hostname, ipaddress, oid):
value = value[1:-1]
return value
+
+def clear_other_hosts_oid_cache(hostname):
+ global g_single_oid_hostname
+ if g_single_oid_hostname != hostname:
+ g_single_oid_cache.clear()
+ g_single_oid_hostname = hostname
+
+
+def set_oid_cache(hostname, oid, value):
+ clear_other_hosts_oid_cache(hostname)
+ g_single_oid_cache[oid] = value
+
+
def get_single_oid(hostname, ipaddress, oid):
# 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
@@ -822,12 +835,7 @@ def get_single_oid(hostname, ipaddress, oid):
else:
oid = '.' + oid
- global g_single_oid_hostname
- global g_single_oid_cache
-
- if g_single_oid_hostname != hostname:
- g_single_oid_hostname = hostname
- g_single_oid_cache = {}
+ clear_other_hosts_oid_cache(hostname)
if oid in g_single_oid_cache:
return g_single_oid_cache[oid]
@@ -856,7 +864,7 @@ def get_single_oid(hostname, ipaddress, oid):
else:
vverbose("failed.\n")
- g_single_oid_cache[oid] = value
+ set_oid_cache(hostname, oid, value)
return value
#.
diff --git a/modules/discovery.py b/modules/discovery.py
index 24c9869..3ceb7fa 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -353,6 +353,11 @@ def snmp_scan(hostname, ipaddress, on_error = "ignore",
for_inv=False):
sys_descr = get_single_oid(hostname, ipaddress, sys_descr_oid)
if sys_descr == None:
raise MKSNMPError("Cannot fetch system description OID %s" %
sys_descr_oid)
+ else:
+ # Fake OID values to prevent issues with a lot of scan functions
+ set_oid_cache(hostname, ".1.3.6.1.2.1.1.1.0", "")
+ set_oid_cache(hostname, ".1.3.6.1.2.1.1.2.0", "")
+
found = []
if for_inv: