Module: check_mk
Branch: master
Commit: b4b0596e9b25e8051c4504785d623efa55c1bc25
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4b0596e9b25e8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Nov 6 13:19:37 2014 +0100
#1508 Allow input of plugin output and perfdata when faking check results
The command <i>Fake check results</i> on hosts and services now allows
to optionally specify the plugin output and the performance data of
the check. It is allowed to leave both new input field empty - then
everying behaves like before.
The extension now allows to send check results to the monitoring
via HTTP. Please refer to the documentation about using Multisite
as a webservice (Automation).
---
.werks/1508 | 16 ++++++++++++++
ChangeLog | 1 +
web/plugins/views/commands.py | 47 ++++++++++++++++++++++++++++++-----------
3 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/.werks/1508 b/.werks/1508
new file mode 100644
index 0000000..af9ca18
--- /dev/null
+++ b/.werks/1508
@@ -0,0 +1,16 @@
+Title: Allow input of plugin output and perfdata when faking check results
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.5i7
+Date: 1415276255
+Class: feature
+
+The command <i>Fake check results</i> on hosts and services now allows
+to optionally specify the plugin output and the performance data of
+the check. It is allowed to leave both new input field empty - then
+everying behaves like before.
+
+The extension now allows to send check results to the monitoring
+via HTTP. Please refer to the documentation about using Multisite
+as a webservice (Automation).
diff --git a/ChangeLog b/ChangeLog
index 38274fb..0086776 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@
NOTE: Please refer to the migration notes!
Multisite:
+ * 1508 Allow input of plugin output and perfdata when faking check results...
* 1164 FIX: Fixed links from servicegroup overviews to single servicegroups
* 1166 FIX: Also prevting stylesheet update issues during version updates (just like
for JS files)
* 1481 FIX: Fix broken layout of Host-, Service- and Contactgroup filters
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index dd8a41f..7c8ff69 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -172,10 +172,15 @@ config.declare_permission("action.fakechecks",
[ "admin" ])
def command_fake_checks(cmdtag, spec, row):
- for s in [0,1,2,3]:
+ for s in [0, 1, 2, 3]:
statename = html.var("_fake_%d" % s)
if statename:
- pluginoutput = _("Manually set to %s by %s") %
(html.attrencode(statename), config.user_id)
+ pluginoutput = html.var_utf8("_fake_output").strip()
+ if not pluginoutput:
+ pluginoutput = _("Manually set to %s by %s") %
(html.attrencode(statename), config.user_id)
+ perfdata = html.var("_fake_perfdata")
+ if perfdata:
+ pluginoutput += "|" + perfdata
if cmdtag == "SVC":
cmdtag = "SERVICE"
command = "PROCESS_%s_CHECK_RESULT;%s;%s;%s" % (cmdtag, spec, s,
pluginoutput)
@@ -183,14 +188,35 @@ def command_fake_checks(cmdtag, spec, row):
return command, title
+def render_fake_form(what):
+ html.write("<table><tr><td>")
+ html.write("%s: " % _("Plugin output"))
+ html.write("</td><td>")
+ html.text_input("_fake_output", "", size=50)
+ html.write("</td></tr><tr><td>")
+ html.write("%s: " % _("Performance data"))
+ html.write("</td><td>")
+ html.text_input("_fake_perfdata", "", size=50)
+ html.write("</td></tr><tr><td>")
+ html.write(_("Set to:"))
+ html.write("</td><td>")
+ if what == "host":
+ html.button("_fake_0", _("Up"))
+ html.button("_fake_1", _("Down"))
+ html.button("_fake_2", _("Unreachable"))
+ else:
+ html.button("_fake_0", _("OK"))
+ html.button("_fake_1", _("Warning"))
+ html.button("_fake_2", _("Critical"))
+ html.button("_fake_3", _("Unknown"))
+ html.write("</td></tr></table>")
+
multisite_commands.append({
"tables" : [ "host" ],
"permission" : "action.fakechecks",
"title" : _("Fake check results"),
- "render" : lambda: \
- html.button("_fake_0", _("Up")) == \
- html.button("_fake_1", _("Down")) == \
- html.button("_fake_2", _("Unreachable")),
+ "group" : _("Fake check results"),
+ "render" : lambda: render_fake_form("host"),
"action" : command_fake_checks,
})
@@ -198,11 +224,8 @@ multisite_commands.append({
"tables" : [ "service" ],
"permission" : "action.fakechecks",
"title" : _("Fake check results"),
- "render" : lambda: \
- html.button("_fake_0", _("OK")) == \
- html.button("_fake_1", _("Warning")) == \
- html.button("_fake_2", _("Critical")) == \
- html.button("_fake_3", _("Unknown")),
+ "group" : _("Fake check results"),
+ "render" : lambda: render_fake_form("service"),
"action" : command_fake_checks,
})
@@ -267,7 +290,7 @@ def command_acknowledgement(cmdtag, spec, row):
multisite_commands.append({
"tables" : [ "host", "service" ],
"permission" : "action.acknowledge",
- "title" : _("Acknowledging Problems"),
+ "title" : _("Acknowledge Problems"),
"render" : lambda: \
html.button("_acknowledge", _("Acknowledge")) == \
html.button("_remove_ack", _("Remove Acknowledgement")) == \