Module: check_mk
Branch: master
Commit: 0cc190099ced455579eb7ec28964f0521fb77440
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0cc190099ced45…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Mar 27 20:41:01 2019 +0100
check_http: user friendly URI configuration
CMK-1873
Change-Id: I2910d469d5ea0cfcefe19d3f2131556c2c48298c
---
cmk/gui/plugins/wato/active_checks.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/cmk/gui/plugins/wato/active_checks.py
b/cmk/gui/plugins/wato/active_checks.py
index 3af738d..0a932d9 100644
--- a/cmk/gui/plugins/wato/active_checks.py
+++ b/cmk/gui/plugins/wato/active_checks.py
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import urlparse
import six
import cmk.gui.mkeventd as mkeventd
@@ -64,6 +65,8 @@ from cmk.gui.plugins.wato import (
IndividualOrStoredPassword,
)
+from cmk.gui.exceptions import MKUserError
+
@rulespec_group_registry.register
class RulespecGroupActiveChecks(RulespecGroup):
@@ -1041,8 +1044,12 @@ class RulespecActiveChecksHttp(HostRulespec):
("uri",
TextAscii(
title=_("URI to fetch (default is
<tt>/</tt>)"),
+ help=_("The URI of the request. This
should start with"
+ " '/' and not include the
domain"
+ " (e.g.
'/index.html')."),
allow_empty=False,
- default_value="/")),
+ default_value="/",
+ validate=self._validate_uri)),
("ssl",
Transform(
DropdownChoice(
@@ -1273,6 +1280,11 @@ class RulespecActiveChecksHttp(HostRulespec):
forth=self._transform_check_http,
)
+ def _validate_uri(self, value, varprefix):
+ url = urlparse.urlsplit(value)
+ if url.scheme or url.netloc or not url.path.startswith('/'):
+ raise MKUserError(varprefix, _("Invalid URI (see help for
details)"))
+
def _transform_check_http(self, params):
if isinstance(params, dict):
return params