Module: check_mk
Branch: master
Commit: 5cfdf11f0c4c6aa8dea7d279877b58e106606793
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5cfdf11f0c4c6a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue May 1 11:54:26 2012 +0200
Formalization of check_tcp finished
---
ChangeLog | 1 +
checks/check_tcp | 42 +++++++++++++++++-
web/htdocs/valuespec.py | 2 +-
web/plugins/wato/active_checks.py | 85 ++++++++++++++++++++++++++++---------
4 files changed, 106 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 67e8b26..9876b89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,7 @@
* You can configure parents now (via a host attribute, no rules are
neccessary).
* You can now do an automated scan for parents and layer 3 (IP)
+ * You can configure active checks (check_tcp, ...) via WATO now
* FIX: fix page header after confirmation dialogs
* FIX: Fixed umlaut problem in host aliases and ip addresses created by WATO
* FIX: Fixed exception caused by validation problems during editing tags in WATO
diff --git a/checks/check_tcp b/checks/check_tcp
index b3b2fd9..e1e13cc 100644
--- a/checks/check_tcp
+++ b/checks/check_tcp
@@ -8,18 +8,56 @@
def check_tcp_arguments(params):
port, settings = params
args = ' -p %d' % port
+
if "response_time" in settings:
args += ' -w %f -c %f' % (
settings["response_time"][0]/1000.0,
settings["response_time"][1]/1000.0)
- if settings.get("escape_send_string"):
- args += ' --escape'
+
+ if "timeout" in settings:
+ args += ' -t %d' % settings["timeout"]
+
+ if "refuse_state" in settings:
+ args += ' -r %s' % settings["refuse_state"]
+
if "send_string" in settings:
args += ' -s %s' % quote_shell_string(settings["send_string"])
+ if settings.get("escape_send_string"):
+ args += ' --escape'
+
+ if "expect" in settings:
+ for s in settings["expect"]:
+ args += ' -e %s' % quote_shell_string(s)
+
+ if settings.get("expect_all"):
+ args += ' -A'
+
+ if settings.get("jail"):
+ args += ' --jail'
+
+ if "mismatch_state" in settings:
+ args += ' -M %s' % settings["mismatch_state"]
+
+ if "delay" in settings:
+ args += ' -d %d' % settings["delay"]
+
+ if "maxbytes" in settings:
+ args += ' -m %d' % settings["maxbytes"]
+
+ if settings.get("ssl"):
+ args += ' --ssl'
+
+ if "cert_days" in settings:
+ args += ' -D %d' % settings["cert_days"]
+
+ if "quit_string" in settings:
+ args += ' -q %s' % quote_shell_string(settings["quit_string"])
return args
+
+
active_check_info['tcp'] = {
"command_line" : '$USER1$/check_tcp -H $HOSTADDRESS$
$ARG1$',
"argument_function" : check_tcp_arguments,
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 1df71f6..74cbba8 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1471,7 +1471,7 @@ class Dictionary(ValueSpec):
div_id, not visible and "none" or ""))
if self._columns == 1 and vs.help():
html.write("<ul class=help>%s</ul>" % vs.help())
- vs.render_input(vp, value.get(param, vs.canonical_value()))
+ vs.render_input(vp, value.get(param, vs.default_value()))
html.write("</div></td></tr>")
html.write("</table>")
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index f52997d..3e1d6de 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -19,10 +19,23 @@ register_rule(group,
Tuple(
title = _("Expected response time"),
elements = [
- Float(title = _("Warning at"), unit =
"ms"),
- Float(title = _("Critical at"), unit =
"ms"),
+ Float(
+ title = _("Warning at"),
+ unit = "ms",
+ default_value = 100.0),
+ Float(
+ title = _("Critical at"),
+ unit = "ms",
+ default_value = 200.0),
])
),
+ ( "timeout",
+ Integer(
+ title = _("Seconds before connection times out"),
+ label = _("sec"),
+ default_value = 10,
+ )
+ ),
( "refuse_state",
DropdownChoice(
title = _("State for connection refusal"),
@@ -31,19 +44,6 @@ register_rule(group,
('ok', _("OK")),
])
),
-# Das hier fehlt noch:
-# -m, --maxbytes=INTEGER
-# Close connection once more than this number of bytes are received
-# -d, --delay=INTEGER
-# Seconds to wait between sending string and polling for response
-# -D, --certificate=INTEGER
-# Minimum number of days a certificate has to be valid.
-# -S, --ssl
-# Use SSL for the connection.
-# -t, --timeout=INTEGER
-# Seconds before connection times out (default: 10)
-# Und dann fehlt noch bei den meisten die Umseztung in Parameter
-
( "send_string",
TextAscii(
@@ -69,12 +69,14 @@ register_rule(group,
totext = _("expect all"),
title = _("Expect <b>all</b> of those strings
in the response"))
),
- ( "quit_string",
- TextAscii(
- title = _("Final string to send"),
- help = _("String to send server to initiate a clean close
of "
- "the connection"),
- size = 30)
+ ( "jail",
+ FixedValue(
+ value = True,
+ title = _("Hide response from socket"),
+ help = _("As soon as you configure expected strings in
"
+ "the response the check will output the response
- "
+ "as long as you do not hide it with this
option"),
+ totext = _("hide response"))
),
( "mismatch_state",
DropdownChoice(
@@ -84,6 +86,47 @@ register_rule(group,
('ok', _("OK")),
])
),
+ ( "delay",
+ Integer(
+ title = _("Seconds to wait before polling"),
+ help = _("Seconds to wait between sending string and
polling for response"),
+ label = _("sec"),
+ default_value = 0,
+ )
+ ),
+ ( "maxbytes",
+ Integer(
+ title = _("Maximum number of bytes to receive"),
+ help = _("Close connection once more than this number of
"
+ "bytes are received. Per default the number of
"
+ "read bytes is not limited. This setting is only
"
+ "used if you expect strings in the
response."),
+ default_value = 1024,
+ ),
+ ),
+
+ ( "ssl",
+ FixedValue(
+ value = True,
+ totext = _("use SSL"),
+ title = _("Use SSL for the connection."))
+
+ ),
+ ( "cert_days",
+ Integer(
+ title = _("SSL certificate validation"),
+ help = _("Minimum number of days a certificate has to be
valid"),
+ label = _("days"),
+ default_value = 30)
+ ),
+
+ ( "quit_string",
+ TextAscii(
+ title = _("Final string to send"),
+ help = _("String to send server to initiate a clean close
of "
+ "the connection"),
+ size = 30)
+ ),
]),
]
),