Module: check_mk
Branch: master
Commit: a317497a208f89117768a1ec0bcd41719dc7bec3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a317497a208f89…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 4 15:24:12 2016 +0200
3319 HW/SW-Inventory service can now be OK in case of unreachable host
The active check for performing the HW/SW-inventory used to always take the
WARN state if the inventory cannot be done (mostly because the target host
was down). This can now be set other states as well. Set this to OK if you
inventorized workstations that are allowed to be switched off. This setting
is in the rule set {{Do hardware/software Inventory}}.
---
.werks/3319 | 13 +++++++++++++
ChangeLog | 1 +
checks/check_cmk_inv | 5 ++++-
modules/check_mk.py | 6 +++++-
modules/inventory.py | 4 ++--
web/plugins/wato/inventory.py | 9 +++++++++
6 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/.werks/3319 b/.werks/3319
new file mode 100644
index 0000000..4521de6
--- /dev/null
+++ b/.werks/3319
@@ -0,0 +1,13 @@
+Title: HW/SW-Inventory service can now be OK in case of unreachable host
+Level: 2
+Component: inv
+Compatible: compat
+Version: 1.2.9i1
+Date: 1459776126
+Class: feature
+
+The active check for performing the HW/SW-inventory used to always take the
+WARN state if the inventory cannot be done (mostly because the target host
+was down). This can now be set other states as well. Set this to OK if you
+inventorized workstations that are allowed to be switched off. This setting
+is in the rule set {{Do hardware/software Inventory}}.
diff --git a/ChangeLog b/ChangeLog
index 9fa55ea..ec5c5cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -241,6 +241,7 @@
HW/SW-Inventory:
* 3192 snmp_extended_info: now inventorizes all physical components of devices which
support the ENTITY-MIB
+ * 3319 HW/SW-Inventory service can now be OK in case of unreachable host...
* 3219 FIX: lnx_distro: Now detecting Oracle VM Server correctly
* 3229 FIX: lnx_distro: SLES based systems have now an OS name inventorized\
* 3265 FIX: mk_inventory.solaris: fix problem on Solaris 10, do prtdiag and prtpicl
only in global zone
diff --git a/checks/check_cmk_inv b/checks/check_cmk_inv
index a0b9b6e..1c10f5a 100644
--- a/checks/check_cmk_inv
+++ b/checks/check_cmk_inv
@@ -28,7 +28,10 @@ def check_cmk_inv(params):
if params == None:
params = {} # convert from legacy rule syntax
- return "--hw-changes=%d --sw-changes=%d" %
(params.get("hw_changes", 0), params.get("sw_changes", 0))
+ return "--inv-fail-status=%d --hw-changes=%d --sw-changes=%d" % (
+ params.get("fail_status", 1),
+ params.get("hw_changes", 0),
+ params.get("sw_changes", 0))
active_check_info['cmk_inv'] = {
"command_line" : 'cmk $ARG1$ --cache --inventory-as-check
$HOSTNAME$',
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 012c22f..db652bb 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3933,6 +3933,7 @@ OPTIONS:
You can specify this option multiple times.
--hw-changes=S --inventory-as-check: Use monitoring state S for HW changes
--sw-changes=S --inventory-as-check: Use monitoring state S for SW changes
+ --inv-fail-status=S Use monitoring state S in case if error during inventory
NOTES:
-I can be restricted to certain check types. Write '--checks df -I' if you
@@ -4914,7 +4915,7 @@ long_options = [ "help", "version",
"verbose", "compile", "debug", "interactive"
"no-cache", "update", "restart",
"reload", "dump", "fake-dns=",
"man", "nowiki", "config-check",
"backup=", "restore=",
"check-inventory=", "check-discovery=",
"discover-marked-hosts", "paths",
- "checks=", "inventory",
"inventory-as-check=", "hw-changes=", "sw-changes=",
+ "checks=", "inventory",
"inventory-as-check=", "hw-changes=", "sw-changes=",
"inv-fail-status=",
"cmc-file=", "browse-man", "list-man",
"update-dns-cache", "cap", "real-time-checks" ]
non_config_options = ['-L', '--list-checks', '-P',
'--package', '-M',
@@ -4941,6 +4942,7 @@ exit_status = 0
opt_verbose = 0 # start again from 0, was already faked at the beginning
opt_inv_hw_changes = 0
opt_inv_sw_changes = 0
+opt_inv_fail_status = 1 # State in case of an error (default: WARN)
# Scan modifying options first (makes use independent of option order)
for o,a in opts:
@@ -4997,6 +4999,8 @@ for o,a in opts:
opt_inv_hw_changes = int(a)
elif o == "--sw-changes":
opt_inv_sw_changes = int(a)
+ elif o == "--inv-fail-status":
+ opt_inv_fail_status = int(a)
# Perform actions (major modes)
try:
diff --git a/modules/inventory.py b/modules/inventory.py
index f5dcf97..07ae365 100644
--- a/modules/inventory.py
+++ b/modules/inventory.py
@@ -209,8 +209,8 @@ def do_inv_check(hostname):
except Exception, e:
if opt_debug:
raise
- sys.stdout.write("WARN - Inventory failed: %s\n" % e)
- sys.exit(1)
+ sys.stdout.write("Inventory failed: %s\n" % e)
+ sys.exit(opt_inv_fail_status)
def count_nodes(tree):
diff --git a/web/plugins/wato/inventory.py b/web/plugins/wato/inventory.py
index df8fca8..a600757 100644
--- a/web/plugins/wato/inventory.py
+++ b/web/plugins/wato/inventory.py
@@ -44,6 +44,15 @@ register_rule(group,
title = _("State when hardware changes are detected"),
default_value = 0,
)),
+ ( "fail_status",
+ MonitoringState(
+ title = _("State when inventory fails"),
+ help = _("The check takes this state in case the inventory
cannot be "
+ "updated because of any possible reason. A common use
is "
+ "setting this to OK for workstations that can be
switched "
+ "off - so you will get no notifications in that
case."),
+ default_value = 1,
+ )),
]
),
title = _("Do hardware/software Inventory"),