Module: check_mk
Branch: master
Commit: 56a1a75c6ac58430cbb480cec7db2643ae41968e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=56a1a75c6ac584…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jul 3 14:13:03 2013 +0200
Reworked default downtime into adhoc downtime
---
ChangeLog | 2 +-
web/plugins/config/builtin.py | 2 +-
web/plugins/views/commands.py | 26 ++++++++++++----
web/plugins/wato/check_mk_configuration.py | 45 +++++++++++++++-------------
4 files changed, 47 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 50ce77e..198cee4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,7 +65,7 @@
* Sorter Host IP address: fixed sorting, no longer uses str compare on ip
* Views: New: Draw rule editor icon in multisite views (default off)
Can be activated in global settings
- * New global multisite options: Default downtime duration and comment
+ * New global multisite options: Adhoc downtime with duration and comment
Display current date in dashboard
* LDAP: Using asynchronous searches / added optional support for paginated
searches (Can be enabled in connection settings)
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index c1abc51..d5ebc38 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -181,7 +181,7 @@ auth_by_http_header = False
multisite_draw_ruleicon = False
# Default downtime configuration
-default_downtime = {}
+adhoc_downtime = {}
# Display dashboard date
pagetitle_date_format = None
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index e8ae959..8598ef1 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -347,7 +347,10 @@ 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")
@@ -376,7 +379,10 @@ def command_downtime(cmdtag, spec, row):
return commands, title
if down_to:
- comment = html.var_utf8("_down_comment")
+ if html.var("_down_adhoc"):
+ comment = config.adhoc_downtime.get("comment","")
+ else:
+ comment = html.var_utf8("_down_comment")
if not comment:
raise MKUserError("_down_comment", _("You need to supply a
comment for your downtime."))
if html.var("_down_flexible"):
@@ -414,14 +420,13 @@ def get_child_hosts(site, hosts, recurse):
return list(new_childs)
def paint_downtime_buttons(what):
- downtime_duration = config.default_downtime.get("duration", 60)
- downtime_comment = config.default_downtime.get("comment", "")
+
html.write(_('Downtime Comment')+": ")
- html.text_input("_down_comment", downtime_comment, size=60,
submit="")
+ html.text_input("_down_comment", "", size=60,
submit="")
html.write("<hr>")
html.button("_down_from_now", _("From now for"))
html.write(" ")
- html.number_input("_down_minutes", downtime_duration, size=4,
submit="_down_from_now")
+ html.number_input("_down_minutes", 60, size=4,
submit="_down_from_now")
html.write(" " + _("minutes"))
html.write("<hr>")
html.button("_down_2h", _("2 hours"))
@@ -432,6 +437,15 @@ def paint_downtime_buttons(what):
html.write(" - ")
html.button("_down_remove", _("Remove all"))
html.write("<hr>")
+ if config.adhoc_downtime and config.adhoc_downtime.get("duration"):
+ adhoc_duration = config.adhoc_downtime.get("duration")
+ adhoc_comment = config.adhoc_downtime.get("comment", "")
+ html.button("_down_adhoc", _("Adhoc for %d minutes") %
adhoc_duration)
+ html.write(" ")
+ html.write(_('with comment')+": ")
+ html.write(adhoc_comment)
+ html.write("<hr>")
+
html.button("_down_custom", _("Custom time range"))
html.datetime_input("_down_from", time.time(),
submit="_down_custom")
html.write(" "+_('to')+" ")
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index f6b1537..9186127 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -280,26 +280,31 @@ register_configvar(group,
domain = "multisite")
register_configvar(group,
- "default_downtime",
- Dictionary(
- title = _("Default downtime settings"),
- help = _("This setting allows to set a default downtime comment and the
duration for the button <i>From now for...</i>. "\
- "The schedule downtime formular uses these values as default.
"),
- optional_keys = False,
- elements = [
- ("duration", Integer(
- title = _("Duration"),
- help = _("The duration in minutes of the default downtime."),
- minvalue = 1,
- unit = _("minutes"),
- default_value = 60,
- )),
- ("comment", TextUnicode(
- title = _("Downtime comment"),
- help = _("The default comment for a downtime."),
- size = 80
- )),
- ],
+ "adhoc_downtime",
+ Optional(
+ Dictionary(
+ optional_keys = False,
+ elements = [
+ ("duration", Integer(
+ title = _("Duration"),
+ help = _("The duration in minutes of the adhoc
downtime."),
+ minvalue = 1,
+ unit = _("minutes"),
+ default_value = 60,
+ )),
+ ("comment", TextUnicode(
+ title = _("Adhoc comment"),
+ help = _("The comment which is automatically sent with an
adhoc downtime"),
+ size = 80,
+ allow_empty = False
+ )),
+ ],
+ ),
+ title = _("Adhoc downtime"),
+ label = _("Enable adhoc downtime"),
+ help = _("This setting allows to set an adhoc downtime comment and its
duration. "
+ "When enabled a new button <tt>Adhoc downtime for xx
minutes</tt> will "
+ "be available in the command form"),
),
domain = "multisite",
)