Module: check_mk
Branch: master
Commit: d3df5b7acaa82ee701920783ec7d132a3006ec9b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d3df5b7acaa82e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Oct 14 00:34:45 2013 +0200
FIX: inventory check now honors settings for exit code
---
.bugs/895 | 7 +++++--
ChangeLog | 3 +++
modules/check_mk.py | 9 +++++++--
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/.bugs/895 b/.bugs/895
index 413cd30..5e78514 100644
--- a/.bugs/895
+++ b/.bugs/895
@@ -1,10 +1,13 @@
Title: Inventory check should honor exit code settings
Component: core
-State: open
+Class: bug
+State: done
Date: 2013-06-21 11:58:34
Targetversion: future
-Class: bug
If you use the feature that the Check_MK exit code is also OK
when the host is down, that should also apply for the inventory
check.
+
+2013-10-14 00:34:40: changed state open -> done
+Fixed.
diff --git a/ChangeLog b/ChangeLog
index caa919c..595cf04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.3i5:
+ Core:
+ * FIX: inventory check now honors settings for exit code
+
Multisite:
* Speed-O-Meter: now measure only service checks. Host checks
are omitted, since they do not really matter and make the
diff --git a/modules/check_mk.py b/modules/check_mk.py
index f3c4c98..397face 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2742,8 +2742,13 @@ def check_inventory(hostname):
except Exception, e:
if opt_debug:
raise
- sys.stdout.write("UNKNOWN - %s\n" % (e,))
- sys.exit(3)
+ # Honor rule settings for "Status of the Check_MK service". In case of
+ # a problem we assume a connection error here.
+ spec = exit_code_spec(hostname)
+ what = isinstance(e, MKAgentError) and "connection" or
"exception"
+ status = spec.get(what, 3)
+ sys.stdout.write("%s - %s\n" % (nagios_state_names[status], e))
+ sys.exit(status)
def service_ignored(hostname, checktype, service_description):