Module: check_mk
Branch: master
Commit: 0d33acc9bbdcf86357a748074b9569e0a2121083
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0d33acc9bbdcf8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 11 15:34:08 2016 +0200
3471 FIX Repair ignoring discovery errors when bogus %s is contained in service
description
This problem often appeard after an upgrade from 1.2.6 to 1.2.8 on monitored ESX servers.
---
.werks/3471 | 10 ++++++++++
ChangeLog | 1 +
modules/discovery.py | 39 +++++++++++++++++++++++++++++++++------
3 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/.werks/3471 b/.werks/3471
new file mode 100644
index 0000000..31bddb1
--- /dev/null
+++ b/.werks/3471
@@ -0,0 +1,10 @@
+Title: Repair ignoring discovery errors when bogus %s is contained in service
description
+Level: 2
+Component: core
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1462973569
+
+This problem often appeard after an upgrade from 1.2.6 to 1.2.8 on monitored ESX
servers.
diff --git a/ChangeLog b/ChangeLog
index 2d6af3e..a9ed054 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
* 3385 FIX: Fixed not updated discovery service after grouped auto discovery...
* 3416 FIX: Avoid warning in cmc.log when rescheduling non-existing discovery
check...
* 3437 FIX: Improved performance of "activate changes", especially in
distributed environments
+ * 3471 FIX: Repair ignoring discovery errors when bogus %s is contained in service
description...
Checks & Agents:
* 3183 aruba_wlc_aps: new check which monitors the provisioned accesspoints of an
Aruba Network WLAN Controller
diff --git a/modules/discovery.py b/modules/discovery.py
index bbfd17c..ee84837 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -940,19 +940,28 @@ def get_node_services(hostname, ipaddress, use_caches, do_snmp_scan,
on_error):
# Identify clustered services
for (check_type, item), (check_source, paramstring) in services.items():
- descr = service_description(hostname, check_type, item)
+ try:
+ descr = service_description(hostname, check_type, item)
+ except Exception, e:
+ if on_error == "raise":
+ raise
+ elif on_error == "warn":
+ sys.stderr.write("Invalid service description: %s\n" % e)
+ else:
+ continue # ignore
+
if hostname != host_of_clustered_service(hostname, descr):
if check_source == "vanished":
del services[(check_type, item)] # do not show vanished clustered
services here
else:
services[(check_type, item)] = ("clustered_" + check_source,
paramstring)
- merge_manual_services(services, hostname)
+ merge_manual_services(services, hostname, on_error)
return services
# To a list of discovered services add/replace manual and active
# checks and handle ignoration
-def merge_manual_services(services, hostname):
+def merge_manual_services(services, hostname, on_error):
# Find manual checks. These can override discovered checks -> "manual"
manual_items = get_check_table(hostname, skip_autochecks=True)
for (check_type, item), (params, descr, deps) in manual_items.items():
@@ -978,7 +987,16 @@ def merge_manual_services(services, hostname):
# Handle disabled services -> "obsolete" and "ignored"
for (check_type, item), (check_source, paramstring) in services.items():
- descr = service_description(hostname, check_type, item)
+ try:
+ descr = service_description(hostname, check_type, item)
+ except Exception, e:
+ if on_error == "raise":
+ raise
+ elif on_error == "warn":
+ sys.stderr.write("Invalid service description: %s\n" % e)
+ else:
+ continue # ignore
+
if service_ignored(hostname, check_type, descr):
if check_source == "vanished":
new_source = "obsolete"
@@ -1015,7 +1033,7 @@ def get_cluster_services(hostname, use_caches, with_snmp_scan,
on_error):
# In all other cases either both must be "new" or
"vanished" -> let it be
# Now add manual and active serivce and handle ignored services
- merge_manual_services(cluster_items, hostname)
+ merge_manual_services(cluster_items, hostname, on_error)
return cluster_items
@@ -1041,7 +1059,16 @@ def get_check_preview(hostname, use_caches, do_snmp_scan,
on_error):
except:
raise MKGeneralException("Invalid check parameter string
'%s'" % paramstring)
- descr = service_description(hostname, check_type, item)
+ try:
+ descr = service_description(hostname, check_type, item)
+ except Exception, e:
+ if on_error == "raise":
+ raise
+ elif on_error == "warn":
+ sys.stderr.write("Invalid service description: %s\n" % e)
+ else:
+ continue # ignore
+
global g_service_description
g_service_description = descr
infotype = check_type.split('.')[0]