Module: check_mk
Branch: master
Commit: 0fa1ffedc2f919c9cda1719f96d962f90edc6ab2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0fa1ffedc2f919…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Sep 24 17:58:38 2014 +0200
#1405 Checkbox for settings downtimes on the hosts of the selected services
In the Multisite command box for setting downtimes on services there is now
a new checkbox called <i>Schedule downtimes on the affected hosts instead
of their services</i>. When you check this then the scheduled downtimes
are set on the hosts of the selected services rather then on the services
themselves. Note: When a host is in scheduled downtime then all its services
are considered to be in a scheduled downtime, as well. There is no need to
set a downtime on these.
---
.werks/1405 | 16 ++++++++++++++++
ChangeLog | 1 +
web/htdocs/views.py | 11 +++++++----
web/plugins/views/commands.py | 16 +++++++++++++++-
4 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/.werks/1405 b/.werks/1405
new file mode 100644
index 0000000..6709ad5
--- /dev/null
+++ b/.werks/1405
@@ -0,0 +1,16 @@
+Title: Checkbox for settings downtimes on the hosts of the selected services
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411574194
+Class: feature
+
+In the Multisite command box for setting downtimes on services there is now
+a new checkbox called <i>Schedule downtimes on the affected hosts instead
+of their services</i>. When you check this then the scheduled downtimes
+are set on the hosts of the selected services rather then on the services
+themselves. Note: When a host is in scheduled downtime then all its services
+are considered to be in a scheduled downtime, as well. There is no need to
+set a downtime on these.
+
diff --git a/ChangeLog b/ChangeLog
index 75f6489..49e9399 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -105,6 +105,7 @@
* 1066 Implemented Dashboard Designer...
* 1392 WATO Folder filter: show only the paths a user is allowed to see
* 1398 Allow to spread times of next check when rescheduling...
+ * 1405 Checkbox for settings downtimes on the hosts of the selected services...
* 1067 FIX: Fixed login problem in LDAP connector when no user filter specified...
* 1094 FIX: sidebar snaping 'Tree of folders': fixed exception
* 1154 FIX: Availability: Fixed unwanted redirect to edit annotation page after
editing availability options...
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index d264da8..e3717ed 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2007,13 +2007,16 @@ def do_actions(view, what, action_rows, backurl):
return False
count = 0
+ already_executed = set([])
for nr, row in enumerate(action_rows):
core_commands, title, executor = core_command(what, row, nr, len(action_rows))
for command in core_commands:
- if type(command) == unicode:
- command = command.encode("utf-8")
- executor(command, row["site"])
- count += 1
+ if command not in already_executed:
+ if type(command) == unicode:
+ command = command.encode("utf-8")
+ executor(command, row["site"])
+ already_executed.add(command)
+ count += 1
message = None
if command:
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index b92a10d..3439e96 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -365,10 +365,12 @@ def command_downtime(cmdtag, spec, row):
down_to = time.time() + minutes * 60
title = _("<b>schedule an immediate downtime for the next %d
minutes</b> on" % minutes)
+
elif html.var("_down_adhoc"):
minutes = config.adhoc_downtime.get("duration",0)
down_to = time.time() + minutes * 60
title = _("<b>schedule an immediate downtime for the next %d
minutes</b> on" % minutes)
+
elif html.var("_down_custom"):
down_from = html.get_datetime_input("_down_from")
down_to = html.get_datetime_input("_down_to")
@@ -381,6 +383,9 @@ def command_downtime(cmdtag, spec, row):
time.asctime(time.localtime(down_to)))
elif html.var("_down_remove"):
+ if html.var("_on_hosts"):
+ raise MKUserError("_on_hosts", _("The checkbox for setting
host downtimes does not work when removing downtimes."))
+
downtime_ids = []
if cmdtag == "HOST":
prefix = "host_"
@@ -412,6 +417,10 @@ def command_downtime(cmdtag, spec, row):
if html.var("_include_childs"): # only for hosts
specs = [ spec ] + get_child_hosts(row["site"], [spec], recurse =
not not html.var("_include_childs_recurse"))
+ elif html.var("_on_hosts"): # set on hosts instead of services
+ specs = [ spec.split(";")[0] ]
+ title += " the hosts of"
+ cmdtag = "HOST"
else:
specs = [ spec ]
@@ -420,6 +429,7 @@ def command_downtime(cmdtag, spec, row):
+ comment) for spec in specs]
return commands, title
+
def get_child_hosts(site, hosts, recurse):
hosts = set(hosts)
html.live.set_only_sites([site])
@@ -437,6 +447,7 @@ def get_child_hosts(site, hosts, recurse):
new_childs.update(rec_childs)
return list(new_childs)
+
def paint_downtime_buttons(what):
html.write(_('Downtime Comment')+": ")
@@ -472,11 +483,14 @@ def paint_downtime_buttons(what):
html.checkbox("_down_flexible", False, label=_('flexible with max.
duration')+" ")
html.time_input("_down_duration", 2, 0)
html.write(" "+_('(HH:MM)'))
+ html.write("<hr>")
if what == "host":
- html.write("<hr>")
html.checkbox("_include_childs", False, label=_('Also set downtime
on child hosts'))
html.write(" ")
html.checkbox("_include_childs_recurse", False, label=_('Do this
recursively'))
+ else:
+ html.checkbox("_on_hosts", False, label=_('Schedule downtimes on
the affected <b>hosts</b> instead of their services'))
+
multisite_commands.append({