Module: check_mk
Branch: master
Commit: 226fbe13a620bd512c8062ffad892aae2d4d9160
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=226fbe13a620bd…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon Apr 1 09:16:01 2019 +0200
check_http: refactor common args
CMK-1873
Change-Id: I45042d19605af74548304524660483f9249c4dbf
---
checks/check_http | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/checks/check_http b/checks/check_http
index ebeb13e..5e63dd1 100644
--- a/checks/check_http
+++ b/checks/check_http
@@ -97,9 +97,6 @@ def _get_proxy(params):
def _certificate_args(host, proxy, settings, sni_flag):
args = []
- if host.family == 'ipv6':
- args += ['-6']
-
if "cert_days" in settings:
# legacy behavior
if isinstance(settings["cert_days"], int):
@@ -114,8 +111,6 @@ def _certificate_args(host, proxy, settings, sni_flag):
if proxy:
args += ['--ssl', '-j', 'CONNECT']
- if proxy.auth:
- args += ["-b", proxy.auth]
args.append(proxy.address)
elif sni_flag:
@@ -141,9 +136,6 @@ def _url_args(host, proxy, settings):
if "virthost" in settings:
args += ["-H", settings["virthost"]]
- if host.family == 'ipv6':
- args += ['-6']
-
# TODO: I think this should be overridden by the proxy port
# in the same way as in the cert check. (mo)
if host.port:
@@ -178,9 +170,6 @@ def _url_args(host, proxy, settings):
username, password = settings["auth"]
args += ["-a", passwordstore_get_cmdline("%s:%%s" % username,
password)]
- if proxy and proxy.auth:
- args += ["-b", proxy.auth]
-
if "onredirect" in settings:
args += ['--onredirect=%s' % settings["onredirect"]]
@@ -231,6 +220,19 @@ def _url_args(host, proxy, settings):
return args
+def _common_args(host, proxy, sni_flag):
+ args = []
+
+ if host.family == 'ipv6':
+ args += ['-6']
+ if sni_flag:
+ args += ['--sni']
+ if proxy and proxy.auth:
+ args += ["-b", proxy.auth]
+
+ return args
+
+
def check_http_arguments(params):
params = _transform_check_http(params)
@@ -239,9 +241,10 @@ def check_http_arguments(params):
host = _get_host(params)
proxy = _get_proxy(params)
- args = ['--sni'] if params.get("sni") else []
+ sni_flag = bool(params.get("sni"))
+ args = _common_args(host, proxy, sni_flag)
if mode_name == 'cert':
- return args + _certificate_args(host, proxy, settings,
params.get("sni"))
+ return args + _certificate_args(host, proxy, settings, sni_flag)
return args + _url_args(host, proxy, settings)