Module: check_mk
Branch: master
Commit: 4a984c4600faa5a1d1025c1d14e2a7a911fc2362
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4a984c4600faa5…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Nov 14 17:04:44 2011 +0100
Multisite: New command for sending custom notifications
---
ChangeLog | 1 +
web/htdocs/views.py | 72 ++++++++++++++++++++++++++++++++++++---------------
2 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e862d05..b9dafa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,7 @@
* New nifty sidebar snapin "Speed-O-Meter"
* Implemented logout functionality in OMD environments
* New filter for the (new) state in host/service alerts
+ * New command for sending custom notifications
WATO:
* Evolved to full featured monitoring configuration tool!
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 7e89114..5f0d6c8 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -79,6 +79,11 @@ def load_plugins():
_("Fake check results"),
_("Manually submit check results for host and service checks"),
[ "admin" ])
+ config.declare_permission("action.customnotification",
+ _("Send custom notification"),
+ _("Manually let the core send a notification to a host or service in
order "
+ "to test if notifications are setup correctly"),
+ [ "user", "admin" ])
config.declare_permission("action.acknowledge",
_("Acknowledge"),
_("Acknowledge host and service problems and remove
acknowledgements"),
@@ -1895,14 +1900,14 @@ def show_downtime_actions():
if config.may("action.downtimes"):
html.write("<tr><td
class=legend>"+_('Downtimes')+"</td>\n"
"<td class=content>\n"
- "<input type=submit name=_remove_downtimes
value=\""+_('Remove')+"\"> "
+ "<input type=submit name=_remove_downtimes
value=\""+_('Remove')+"\">"
"</td></tr>\n")
def show_comment_actions():
if config.may("action.addcomment"):
html.write("<tr><td
class=legend>"+_('Comments')+"</td>\n"
"<td class=content>\n"
- "<input type=submit name=_remove_comments
value=\""+_('Remove')+"\"> "
+ "<input type=submit name=_remove_comments
value=\""+_('Remove')+"\">"
"</td></tr>\n")
@@ -1910,16 +1915,16 @@ def show_host_service_actions(what):
if config.may("action.notifications"):
html.write("<tr><td
class=legend>"+_('Notifications')+"</td>\n"
"<td class=content>\n"
- "<input type=submit name=_enable_notifications
value=\""+_('Enable')+"\"> "
- "<input type=submit name=_disable_notifications
value=\""+_('Disable')+"\"> "
+ "<input type=submit name=_enable_notifications
value=\""+_('Enable')+"\"> "
+ "<input type=submit name=_disable_notifications
value=\""+_('Disable')+"\">"
"</td></tr>\n")
if config.may("action.enablechecks") or
config.may("action.reschedule"):
html.write("<tr><td class=legend>"+_('Active
checks')+"</td>\n"
"<td class=content>\n")
if config.may("action.enablechecks"):
- html.write("<input type=submit name=_enable_checks
value=\""+_('Enable')+"\"> "
- "<input type=submit name=_disable_checks
value=\""+_('Disable')+"\"> ")
+ html.write("<input type=submit name=_enable_checks
value=\""+_('Enable')+"\"> "
+ "<input type=submit name=_disable_checks
value=\""+_('Disable')+"\"> ")
if config.may("action.reschedule"):
html.write("<input type=submit name=_resched_checks
value=\""+_('Reschedule next check now')+"\">\n"
"</td></tr>\n")
@@ -1927,8 +1932,8 @@ def show_host_service_actions(what):
if config.may("action.enablechecks"):
html.write("<tr><td class=legend>"+_('Passive
checks')+"</td>\n"
"<td class=content>\n")
- html.write("<input type=submit name=_enable_passive_checks
value=\""+_('Enable')+"\"> "
- "<input type=submit name=_disable_passive_checks
value=\""+_('Disable')+"\"> "
+ html.write("<input type=submit name=_enable_passive_checks
value=\""+_('Enable')+"\"> "
+ "<input type=submit name=_disable_passive_checks
value=\""+_('Disable')+"\">"
"</td></tr>\n")
if config.may("action.clearmodattr"):
@@ -1948,29 +1953,46 @@ def show_host_service_actions(what):
html.write(" ")
html.write("</td></tr>\n")
+ if config.may("action.customnotification"):
+ html.write("<tr><td class=legend>"+_('Custom
notification')+"</td>\n")
+ html.write("<td class=content>")
+ html.write(_('Comment') + ": ")
+ html.text_input("_cusnot_comment", "TEST", size=20)
+ html.write(" ")
+ html.checkbox("_cusnot_forced", False)
+ html.write(_("forced") + " ")
+ html.checkbox("_cusnot_broadcast", False)
+ html.write(_("broadcast") + " ")
+ html.write(" ")
+ html.write("<input type=submit name=_customnotification
value=\"" + _('Send') +"\">")
+ html.write("</td></tr>\n")
+
if config.may("action.acknowledge"):
html.write("<tr><td rowspan=3
class=legend>"+_('Acknowledge')+"</td>\n")
- html.write("<td class=content><input type=submit name=_acknowledge
value=\""+_('Acknowledge')+"\"> "
+ html.write("<td class=content><input type=submit name=_acknowledge
value=\""+_('Acknowledge')+"\"> "
"<input type=submit name=_remove_ack
value=\""+_('Remove
Acknowledgement')+"\"></td></tr>\n")
html.write("<tr><td class=content>")
html.checkbox("_ack_sticky", True)
- html.write(" "+_('sticky')+" ")
+ html.write(_('sticky')+" ")
html.checkbox("_ack_notify", True)
- html.write(" "+_('send notification')+"
")
+ html.write(_('send notification')+" ")
html.checkbox("_ack_persistent", False)
- html.write(" "+_('persistent comment'))
+ html.write(_('persistent comment'))
html.write("</td></tr>\n")
- html.write("<tr><td class=content><div
class=textinputlegend>"+_('Comment:')+"</div>")
- html.text_input("_ack_comment", size=65)
+ html.write("<tr><td class=content>")
+ html.write(_("Comment") + ": ")
+ html.text_input("_ack_comment", size=48)
html.write("</td></tr>\n")
if config.may("action.addcomment"):
- html.write("<tr><td rowspan=2 class=legend>"+_('Add
comment')+"</td>\n")
- html.write("<td class=content><input type=submit name=_add_comment
value=\""+_('Add
comment')+"\"></td></tr>\n"
- "<tr><td class=content><div
class=textinputlegend>"+_('Comment')+":</div>")
- html.text_input("_comment", size=65)
+ html.write("<tr><td class=legend>"+_('Add
comment')+"</td>\n")
+ html.write("<td class=content>")
+ html.write(_('Comment')+": ")
+ html.text_input("_comment", size=33)
+ html.write(" ")
+ html.write("<input type=submit name=_add_comment
value=\""+_('Add comment')+"\">")
html.write("</td></tr>\n")
if config.may("action.downtimes"):
@@ -1992,11 +2014,11 @@ def show_host_service_actions(what):
html.write("</td></tr>")
html.write("<tr><td class=content>")
html.checkbox("_down_flexible", False)
- html.write(" "+_('flexible with max. duration')+" ")
+ html.write(_('flexible with max. duration')+" ")
html.time_input("_down_duration", 2, 0)
html.write("
"+_('(HH:MM)')+"</td></tr>\n")
- html.write("<tr><td class=content><div
class=textinputlegend>"+_('Comment')+":</div>\n")
- html.text_input("_down_comment", size=65)
+ html.write("<tr><td class=content>" +
_('Comment')+": ")
+ html.text_input("_down_comment", size=48)
def nagios_action_command(what, row):
if what in [ "host", "service" ]:
@@ -2087,6 +2109,14 @@ def nagios_host_service_action_command(what, dataset):
command = "PROCESS_HOST_CHECK_RESULT;%s;%s;%s" % (spec,
hoststate, pluginoutput)
title = _("<b>manually set check results to %s</b> for") %
statename
+ elif html.var("_customnotification") and
config.may("action.customnotification"):
+ comment = html.var("_cusnot_comment")
+ broadcast = html.get_checkbox("_cusnot_broadcast") and 1 or 0
+ forced = html.get_checkbox("_cusnot_forced") and 2 or 0
+ command = "SEND_CUSTOM_%s_NOTIFICATION;%s;%s;%s;%s" % \
+ ( cmdtag, spec, broadcast + forced, config.user_id, comment)
+ title = _("<b>send a custom notification</b> regarding")
+
elif html.var("_acknowledge") and
config.may("action.acknowledge"):
comment = html.var_utf8("_ack_comment")
if not comment: