Module: check_mk
Branch: master
Commit: 830c7e3af9aee60a7ec989e58929d657aa9f1ae2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=830c7e3af9aee6…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jun 26 14:04:47 2013 +0200
new global option: default downtime and duration
---
ChangeLog | 1 +
web/plugins/config/builtin.py | 3 +++
web/plugins/views/commands.py | 18 ++++++++++++------
web/plugins/wato/check_mk_configuration.py | 27 +++++++++++++++++++++++++++
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fa73107..98050a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,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 option: Default downtime duration and comment
WATO:
* Allow to configure check-/retry_interval in second precision
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 4bd4728..3f9b6db 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -180,6 +180,9 @@ auth_by_http_header = False
# Add an icon pointing to the WATO rule to each service
multisite_draw_ruleicon = False
+# Default downtime configuration
+default_downtime = {}
+
# _ _ ____ ____
# | | | |___ ___ _ __| _ \| __ )
# | | | / __|/ _ \ '__| | | | _ \
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index 3155329..e9fc174 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -377,6 +377,10 @@ def command_downtime(cmdtag, spec, row):
if down_to:
comment = html.var_utf8("_down_comment")
+ try: # Catch formatting errors
+ comment = comment % { "user": config.user_id, "duration":
int(down_to - down_from) }
+ except:
+ pass
if not comment:
raise MKUserError("_down_comment", _("You need to supply a
comment for your downtime."))
if html.var("_down_flexible"):
@@ -414,8 +418,15 @@ 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.button("_down_from_now", _("From now for"))
+ html.write(" ")
+ html.number_input("_down_minutes", downtime_duration, size=4,
submit="_down_from_now")
+ html.write(" " + _("minutes"))
+ html.write("<hr>")
html.write(_('Downtime Comment')+": ")
- html.text_input("_down_comment", size=40, submit="")
+ html.text_input("_down_comment", downtime_comment, size=60,
submit="")
html.write("<hr>")
html.button("_down_2h", _("2 hours"))
html.button("_down_today", _("Today"))
@@ -430,11 +441,6 @@ def paint_downtime_buttons(what):
html.write(" "+_('to')+" ")
html.datetime_input("_down_to", time.time() + 7200,
submit="_down_custom")
html.write("<hr>")
- html.button("_down_from_now", _("From now for"))
- html.write(" ")
- html.number_input("_down_minutes", 60, size=4,
submit="_down_from_now")
- html.write(" " + _("minutes"))
- html.write("<hr>")
html.checkbox("_down_flexible", False, label=_('flexible with max.
duration')+" ")
html.time_input("_down_duration", 2, 0)
html.write(" "+_('(HH:MM)'))
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 96766c6..c95790d 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -265,6 +265,33 @@ 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
duration. "\
+ "The schedule downtime formular uses these values as default.
"),
+ elements = [
+ ("duration", Integer(
+ title = _("Duration"),
+ help = _("The duration in minutes of the default downtime"),
+ minvalue = 1,
+ unit = _("minutes"),
+ default_value = 120,
+ )),
+ ("comment", TextAscii(
+ title = _("Downtime comment"),
+ help = _("The default comment for a downtime. "\
+ "You can use the placeholders %(user)s and %(duration)s
"\
+ "which will replaced when the downtime command is
sent"),
+ default_value = _("Downtime of %(duration)s minutes triggered by
%(user)s"),
+ size = 80
+ )),
+ ],
+ ),
+ domain = "multisite",
+)
+
+register_configvar(group,
"wato_activation_method",
DropdownChoice(
title = _("WATO restart mode for Nagios"),