Module: check_mk
Branch: master
Commit: 10a4544f079dbed2afbab1bbfec65eee6706df47
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=10a4544f079dbe…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Jun 23 14:54:02 2016 +0200
3550 HW/SW inventory: Now able to raise an alert when SW packages info is missing
This option can be configured in the WATO rule <i>Do HW/SW Inventory</i>.
---
.werks/3550 | 9 +++++++++
ChangeLog | 1 +
checks/check_cmk_inv | 5 +++--
modules/check_mk.py | 8 ++++++--
modules/inventory.py | 4 ++++
web/plugins/wato/inventory.py | 5 +++++
6 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/.werks/3550 b/.werks/3550
new file mode 100644
index 0000000..e1d4c3d
--- /dev/null
+++ b/.werks/3550
@@ -0,0 +1,9 @@
+Title: HW/SW inventory: Now able to raise an alert when SW packages info is missing
+Level: 1
+Component: inv
+Compatible: compat
+Version: 1.4.0i1
+Date: 1466686328
+Class: feature
+
+This option can be configured in the WATO rule <i>Do HW/SW Inventory</i>.
diff --git a/ChangeLog b/ChangeLog
index 0926906..4fa3e3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -517,6 +517,7 @@
* 3581 mssql_versions: Added product name to inventory information
* 3585 Implemented API for exporting the full host inventory...
* 3591 mssql_clusters: Added information about nodes to MSSQL instance inventory
+ * 3550 HW/SW inventory: Now able to raise an alert when SW packages info is
missing...
* 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 1c10f5a..afde8f7 100644
--- a/checks/check_cmk_inv
+++ b/checks/check_cmk_inv
@@ -28,10 +28,11 @@ def check_cmk_inv(params):
if params == None:
params = {} # convert from legacy rule syntax
- return "--inv-fail-status=%d --hw-changes=%d --sw-changes=%d" % (
+ return "--inv-fail-status=%d --hw-changes=%d --sw-changes=%d
--sw-missing=%d" % (
params.get("fail_status", 1),
params.get("hw_changes", 0),
- params.get("sw_changes", 0))
+ params.get("sw_changes", 0),
+ params.get("sw_missing", 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 67840ef..32b9715 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3994,6 +3994,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
+ --sw-missing=S --inventory-as-check: Use monitoring state S for missing SW packages
info
--inv-fail-status=S Use monitoring state S in case if error during inventory
NOTES:
@@ -4981,8 +4982,8 @@ 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=",
"inv-fail-status=",
- "cmc-file=", "browse-man", "list-man",
"update-dns-cache", "cap", "real-time-checks" ]
+ "checks=", "inventory",
"inventory-as-check=", "hw-changes=", "sw-changes=",
"sw-missing=",
+ "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',
'--handle-alerts', '--notify',
'--real-time-checks',
@@ -5008,6 +5009,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_sw_missing = 0
opt_inv_fail_status = 1 # State in case of an error (default: WARN)
# Scan modifying options first (makes use independent of option order)
@@ -5065,6 +5067,8 @@ for o,a in opts:
opt_inv_hw_changes = int(a)
elif o == "--sw-changes":
opt_inv_sw_changes = int(a)
+ elif o == "--sw-missing":
+ opt_inv_sw_missing = int(a)
elif o == "--inv-fail-status":
opt_inv_fail_status = int(a)
diff --git a/modules/inventory.py b/modules/inventory.py
index 83998b4..57983e5 100644
--- a/modules/inventory.py
+++ b/modules/inventory.py
@@ -199,6 +199,10 @@ def do_inv_check(hostname):
infotext = "found %d entries" % num_entries
state = 0
+ if not inv_tree.get("software") and opt_inv_sw_missing:
+ infotext += ", software information is missing"
+ state = opt_inv_sw_missing
+ infotext += state_markers[opt_inv_sw_missing]
if old_timestamp:
path = inventory_archive_dir + "/" + hostname + "/%d" %
old_timestamp
diff --git a/web/plugins/wato/inventory.py b/web/plugins/wato/inventory.py
index a600757..4b22f3b 100644
--- a/web/plugins/wato/inventory.py
+++ b/web/plugins/wato/inventory.py
@@ -39,6 +39,11 @@ register_rule(group,
title = _("State when software changes are detected"),
default_value = 0,
)),
+ ( "sw_missing",
+ MonitoringState(
+ title = _("State when software packages info is
missing"),
+ default_value = 0,
+ )),
( "hw_changes",
MonitoringState(
title = _("State when hardware changes are detected"),