Module: check_mk
Branch: master
Commit: c1d9ff1e22096e1c52d90beeb7f8275f78d1acde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1d9ff1e22096e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 8 17:14:07 2010 +0100
Better handling for removed checks
Removed exceptions in check_mk calls when some configured checks have been
removed/renamed
---
ChangeLog | 2 ++
modules/check_mk.py | 20 +++++++++++++++++---
modules/check_mk_base.py | 4 +++-
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 448a345..cc26f37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,8 @@
per-host configuration
* allow check implementations to use common include files. See if/if64
for an example
+ * Better handling for removed checks: Removed exceptions in check_mk calls
+ when some configured checks have been removed/renamed
Checks & Agents:
* fc_brocade_port_detailed: allow to specify port state combinations not
diff --git a/modules/check_mk.py b/modules/check_mk.py
index b5eec95..294e5ed 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -396,7 +396,10 @@ if __name__ == "__main__":
# +----------------------------------------------------------------------+
def have_perfdata(checkname):
- return check_info[checkname][2]
+ try:
+ return check_info[checkname][2]
+ except:
+ return False
def output_check_info():
print "Available check types:"
@@ -866,8 +869,13 @@ def get_datasource_program(hostname, ipaddress):
def service_description(checkname, item):
if checkname not in check_info:
- raise MKGeneralException("Unknown check type '%s'.\n"
- "Please use check_mk -L for a list of all check
types.\n" % checkname)
+ if item:
+ return "Unimplmented check %s / %s" % (checkname, item)
+ else:
+ return "Unimplemented check %s" % checkname
+
+ # raise MKGeneralException("Unknown check type '%s'.\n"
+ # "Please use check_mk -L for a list of all check
types.\n" % checkname)
# use user-supplied service description, of available
descr_format = service_descriptions.get(checkname)
@@ -1880,6 +1888,9 @@ def remove_autochecks_of(hostname, checktypes):
count += 1
splitted = line.split('"')
if splitted[1] != hostname or splitted[3] not in checktypes:
+ if splitted[3] not in check_info:
+ sys.stderr.write('Removing unimplemented check %s\n' %
splitted[3])
+ continue
lines.append(line)
if len(lines) == 0:
if opt_verbose:
@@ -2006,6 +2017,9 @@ filesystem_default_levels = None
need_snmp_module = False
needed_types = set([])
for checktype, item, param, descr, aggr in check_table:
+ if checktype not in check_info:
+ sys.stderr.write('Warning: Ignoring missing check %s.\n' %
checktype)
+ continue
needed_types.add(checktype.split(".")[0])
if check_uses_snmp(checktype):
need_snmp_module = True
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index d0f16bc..7b7c5ed 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -725,6 +725,8 @@ def do_check(hostname, ipaddress):
sys.stdout.write(output)
sys.exit(status)
+def check_unimplemented(checkname, params, info):
+ return (3, 'UNKNOWN - Check not implemented')
# Loops over all checks for a host, gets the data, calls the check
# function that examines that data and sends the result to Nagios
@@ -767,7 +769,7 @@ def do_all_checks_on_host(hostname, ipaddress):
try:
check_funktion = check_info[checkname][0]
except:
- raise MKGeneralException("Unknown check type %s" % checkname)
+ check_funktion = check_unimplemented
try:
dont_submit = False