Module: check_mk
Branch: master
Commit: 1be408dcd181c3b84453048cf2d4809d055fd66a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1be408dcd181c3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 29 14:24:55 2013 +0100
Automatically schedule inventory check after service config change
Now after each change of the service configuration of a host via WATO -
may it be via manual changes or a bulk inventory - the inventory check
is automatically rescheduled in order to reflect the new service state
correctly immediately.
You can switch off this behaviour via a new global option called <i>Inventory
triggers inventory check</i>. The default setting is <b>on</b>.
---
.werks/9 | 14 ++++++++++++++
ChangeLog | 1 +
modules/automation.py | 15 +++++++++++++++
modules/check_mk.py | 1 +
web/plugins/wato/check_mk_configuration.py | 14 ++++++++++++++
5 files changed, 45 insertions(+)
diff --git a/.werks/9 b/.werks/9
new file mode 100644
index 0000000..be7f088
--- /dev/null
+++ b/.werks/9
@@ -0,0 +1,14 @@
+Title: Automatically schedule inventory check after service config change
+Level: 2
+Component: wato
+Version: 1.2.3i7
+Date: 1385731404
+Class: feature
+
+Now after each change of the service configuration of a host via WATO -
+may it be via manual changes or a bulk inventory - the inventory check
+is automatically rescheduled in order to reflect the new service state
+correctly immediately.
+
+You can switch off this behaviour via a new global option called <i>Inventory
+triggers inventory check</i>. The default setting is <b>on</b>.
diff --git a/ChangeLog b/ChangeLog
index 660f019..580014d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -61,6 +61,7 @@
* 0053 New rule for configuring the display_name of a service...
* 0216 Supporting float values as SNMP timeout value now...
* 0082 Improved online help for LDAP connections...
+ * 0009 Automatically schedule inventory check after service config change...
* 0048 FIX: Tests on host diagnose page are executed parallel now...
* 0033 FIX: Fixed problem when saving settings in WATOs host diagnostic page...
* 0205 FIX: NagVis related permissions of roles can be edited again...
diff --git a/modules/automation.py b/modules/automation.py
index 94dc497..6b4da4a 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -465,6 +465,21 @@ def automation_write_autochecks_file(hostname, table):
for ct, item, paramstring in table:
f.write(" (%r, %r, %r, %s),\n" % (hostname, ct, item, paramstring))
f.write("]\n")
+ if inventory_check_autotrigger and inventory_check_interval:
+ schedule_inventory_check(hostname)
+
+def schedule_inventory_check(hostname):
+ try:
+ import socket
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.connect(livestatus_unix_socket)
+ now = int(time.time())
+ command = "SCHEDULE_FORCED_SVC_CHECK;%s;Check_MK inventory;%d" %
(hostname, now)
+ s.send("COMMAND [%d] %s\n" % (now, command))
+ except Exception, e:
+ if opt_debug:
+ raise
+
def automation_parse_autochecks_file(hostname):
def split_python_tuple(line):
diff --git a/modules/check_mk.py b/modules/check_mk.py
index c1113cd..24c5164 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -246,6 +246,7 @@ inventory_check_interval = None # Nagios intervals (4h =
240)
inventory_check_severity = 1 # warning
inventory_check_do_scan = True # include SNMP scan for SNMP devices
inventory_max_cachefile_age = 120 # secs.
+inventory_check_autotrigger = True # Automatically trigger inv-check after
automation-inventory
always_cleanup_autochecks = True
# Nagios templates and other settings concerning generation
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index f07a86f..9162b01 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1064,6 +1064,20 @@ register_configvar(group,
]
))
+register_configvar(group,
+ "inventory_check_autotrigger",
+ Checkbox(
+ title = _("Inventory triggers inventory check"),
+ label = _("Automatically schedule inventory check after service
configuration changes"),
+ help = _("When this option is enabled then after each change of the service
"
+ "configuration of a host via WATO - may it be via manual changes or
a bulk "
+ "inventory - the inventory check is automatically rescheduled in
order "
+ "to reflect the new service state correctly immediately."),
+ default_value = True,
+ ))
+
+
+
_if_portstate_choices = [
( '1', 'up(1)'),