Module: check_mk
Branch: master
Commit: bf2e71dd4c39ba132a002d9478cd6e445416d2b4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf2e71dd4c39ba…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Jan 25 15:27:59 2012 +0100
Wato: Added function that wato can use reload instead of restart
---
modules/automation.py | 11 ++++++++---
web/htdocs/config.py | 2 +-
web/htdocs/wato.py | 8 ++++----
web/plugins/wato/check_mk_configuration.py | 12 ++++++++++++
4 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/modules/automation.py b/modules/automation.py
index bfb1be5..f6e5213 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -51,8 +51,10 @@ def do_automation(cmd, args):
result = automation_get_autochecks(args)
elif cmd == "set-autochecks":
result = automation_set_autochecks(args)
+ elif cmd == "reload":
+ result = automation_restart("reload")
elif cmd == "restart":
- result = automation_restart()
+ result = automation_restart("restart")
else:
raise MKAutomationError("Automation command '%s' is not
implemented." % cmd)
@@ -354,7 +356,7 @@ def automation_delete_host(args):
"%s/%s.*" % (tcp_cache_dir, hostname)]:
os.system("rm -rf '%s'" % path)
-def automation_restart():
+def automation_restart(job="restart"):
# make sure, Nagios does not inherit any open
# filedescriptors. This really happens, e.g. if
# check_mk is called by WATO via Apache. Nagios inherits
@@ -395,7 +397,10 @@ def automation_restart():
if backup_path:
os.remove(backup_path)
do_precompile_hostchecks()
- do_restart_nagios(False)
+ if job == 'restart':
+ do_restart_nagios(False)
+ elif job == 'reload':
+ do_restart_nagios(True)
else:
if backup_path:
os.rename(backup_path, nagios_objects_file)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index f0d1362..bbf57ee 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -592,7 +592,7 @@ wato_hide_filenames = True
wato_max_snapshots = 50
wato_num_hostspecs = 12
wato_num_itemspecs = 15
-
+wato_activation_method = 'restart'
wato_write_nagvis_auth = False
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 0bb819f..a3e81bf 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2718,7 +2718,7 @@ def mode_changelog(phase):
sitestatus_do_async_replication = True
else:
try:
- check_mk_local_automation("restart")
+ check_mk_local_automation(config.wato_activation_method)
except Exception, e:
if config.debug:
raise
@@ -6109,8 +6109,8 @@ def synchronize_site(site, restart):
# Isolated restart without prior synchronization. Currently this
# is only being called for the local site.
def restart_site(site):
- start = time.time()
- check_mk_automation(site["id"], "restart")
+ start = time.time()
+ check_mk_automation(site["id"], config.wato_activation_method)
duration = time.time() - start
update_replication_status(site["id"],
{ "need_restart" : False }, { "restart" : duration })
@@ -6360,7 +6360,7 @@ def automation_push_snapshot():
create_distributed_wato_file(site_id, mode)
log_audit(None, "replication", _("Synchronized with master (my
site id is %s.)") % site_id)
if html.var("restart", "no") == "yes":
- check_mk_local_automation("restart")
+ check_mk_local_automation(config.wato_activation_method)
return True
except Exception, e:
if config.debug:
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 0066e42..858d5cb 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -162,6 +162,18 @@ register_configvar(group,
default_value = 50),
domain = "multisite")
+register_configvar(group,
+ "wato_activation_method",
+ DropdownChoice(
+ title = _("Wato restart mode for Nagios"),
+ help = _("Should Wato restart or reload Nagios when activating
changes"),
+ choices = [
+ ('restart', _("Restart")),
+ ('reload' , _("Reload") ),
+ ]),
+ domain = "multisite"
+ )
+
group = _("Operation mode of Check_MK")
register_configvar(group,