Module: check_mk
Branch: master
Commit: f8447dade9d36c3f8332d21904f65ab99dd5cc4a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f8447dade9d36c…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Mar 28 09:07:36 2019 +0100
check_http: add validation
We now explicitly check for a invalid configuration
that never worked anyway.
CMK-1873
Change-Id: I16e00a7bf8c6d408f2f17a6c116ebf6343cb632f
---
checks/check_http | 4 +---
cmk/gui/plugins/wato/active_checks.py | 8 ++++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/checks/check_http b/checks/check_http
index 812e157..ebeb13e 100644
--- a/checks/check_http
+++ b/checks/check_http
@@ -137,9 +137,7 @@ def _url_args(host, proxy, settings):
args += ["-H", host.address]
else:
args += ["-I", host.address]
- # TODO: what if we have a proxy, *and* virthost?
- # This was not possible earlier, so for now
- # ignore 'virthost' in that case.
+ # Proxy *and* virthost is not allowed
if "virthost" in settings:
args += ["-H", settings["virthost"]]
diff --git a/cmk/gui/plugins/wato/active_checks.py
b/cmk/gui/plugins/wato/active_checks.py
index 0a932d9..c5cc2c4 100644
--- a/cmk/gui/plugins/wato/active_checks.py
+++ b/cmk/gui/plugins/wato/active_checks.py
@@ -1276,6 +1276,7 @@ class RulespecActiveChecksHttp(HostRulespec):
)),
],
required_keys=["name", "host", "mode"],
+ validate=self._validate_all,
),
forth=self._transform_check_http,
)
@@ -1285,6 +1286,13 @@ class RulespecActiveChecksHttp(HostRulespec):
if url.scheme or url.netloc or not url.path.startswith('/'):
raise MKUserError(varprefix, _("Invalid URI (see help for
details)"))
+ def _validate_all(self, value, varprefix):
+ _name, mode = value['mode']
+ if 'proxy' in value and 'virthost' in mode:
+ msg = _("Unfortunately, using a proxy and a virtual host is not
supported (try '%s')."
+ ) % _("Host settings")
+ raise MKUserError(varprefix, msg)
+
def _transform_check_http(self, params):
if isinstance(params, dict):
return params