Module: check_mk
Branch: master
Commit: b0dae8649ddf20d313a22c3838376d758818b57e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b0dae8649ddf20…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 16 15:19:57 2012 +0200
WATO: Added new internal hook pre-activate-changes to execute custom
code BEFORE Check_MK is called to restart Nagios
---
ChangeLog | 2 ++
web/htdocs/wato.py | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 75d6c9a..599a486 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,8 @@
of userids to hide the listed users from the WATO user management GUI.
* WATO API: Added new method rewrite_configuration to trigger a rewrite of
all host related wato configuration files to distribute changed tags
+ * WATO: Added new internal hook pre-activate-changes to execute custom
+ code BEFORE Check_MK is called to restart Nagios
Multisite
* Added config option default_ts_format to configure default timestamp
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index b0de0e2..73f9f7c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3379,6 +3379,9 @@ def check_mk_local_automation(command, args=[],
indata=""):
"<li>Retry this operation</li></ol>\n" %
(html.apache_user(), sudoline))
+ if command == 'restart':
+ call_hook_pre_activate_changes()
+
if config.debug:
log_audit(None, "automation", "Automation: %s" % "
".join(cmd))
try:
@@ -10360,6 +10363,20 @@ def call_hook_folder_deleted(folder):
if 'folder-deleted' in g_hooks:
call_hooks("folder-deleted", folder)
+def call_hook_pre_activate_changes():
+ """
+ This hook is executed when one applies the pending configuration changes
+ from wato but BEFORE the nagios restart is executed.
+
+ It can be used to create custom input files for nagios/Check_MK.
+
+ The registered hooks are called with a dictionary as parameter which
+ holds all available with the hostnames as keys and the attributes of
+ the hosts as values.
+ """
+ if hook_registered('pre-activate-changes'):
+ call_hooks("pre-activate-changes", collect_hosts(g_root_folder))
+
def call_hook_activate_changes():
"""
This hook is executed when one applies the pending configuration changes