Module: check_mk
Branch: master
Commit: 8e915562f24a44a2899c0fa875cf979f48fd9b24
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8e915562f24a44…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Oct 26 15:34:43 2017 +0200
5351 check_http: Use HTTPS instead of HTTP in service description for SSL/TLS connections
For Check HTTP checks the service description now uses HTTPS instead of
HTTP if a connection via SSL/TLS is used. This makes it easy to distinguish
if a Check uses HTTP or HTTPS for a connection.
This feature is automatically enabled for new Check_MK installations.
If you upgrade an existing Check_MK installation you have to enable it
in the global settings via the option "Use new service descriptions"
in the section "Execution of checks". Be aware that the change may effect
existing rules, performance data (if present), and the availability
history.
Change-Id: Ic4a67be14196935b6b2c564175b66136d70cd4d8
---
.werks/5351 | 20 ++++++++++++++++++++
checks/check_http | 14 +++++++++++---
cmk_base/config.py | 15 +++++++++++++--
web/htdocs/wato.py | 1 +
web/plugins/wato/active_checks.py | 3 ++-
web/plugins/wato/check_mk_configuration.py | 1 +
6 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/.werks/5351 b/.werks/5351
new file mode 100644
index 0000000..c2d5e94
--- /dev/null
+++ b/.werks/5351
@@ -0,0 +1,20 @@
+Title: check_http: Use HTTPS instead of HTTP in service description for SSL/TLS connections
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cre
+Version: 1.5.0i1
+Date: 1509024010
+Class: feature
+
+For Check HTTP checks the service description now uses HTTPS instead of
+HTTP if a connection via SSL/TLS is used. This makes it easy to distinguish
+if a Check uses HTTP or HTTPS for a connection.
+
+This feature is automatically enabled for new Check_MK installations.
+If you upgrade an existing Check_MK installation you have to enable it
+in the global settings via the option "Use new service descriptions"
+in the section "Execution of checks". Be aware that the change may effect
+existing rules, performance data (if present), and the availability
+history.
+
diff --git a/checks/check_http b/checks/check_http
index aaa6e27..85d3232 100644
--- a/checks/check_http
+++ b/checks/check_http
@@ -157,10 +157,18 @@ def check_http_arguments(params):
def check_http_desc(params):
- if params[0].startswith("^"):
- return params[0][1:]
+ description, settings = params
+
+ if description.startswith("^"):
+ return description[1:]
+
+ # here we have to cover connection and certificate checks
+ if settings.get("ssl") or settings.get("cert_days"):
+ protocol = "HTTPS"
+ else:
+ protocol = "HTTP"
- return "HTTP %s" % params[0]
+ return "%s %s" % (protocol, description)
active_check_info['http'] = {
diff --git a/cmk_base/config.py b/cmk_base/config.py
index cca564a..6d73d15 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -1050,13 +1050,24 @@ def service_description(hostname, check_type, item):
return get_final_service_description(hostname, descr)
+_old_active_check_service_descriptions = {
+ "http": lambda params: (params[0][1:] if params[0].startswith("^")
+ else "HTTP %s" % params[0])
+}
+
+
def active_check_service_description(hostname, active_check_type, params):
import cmk_base.checks as checks
if active_check_type not in checks.active_check_info:
return "Unimplemented check %s" % active_check_type
- act_info = checks.active_check_info[active_check_type]
- description = act_info["service_description"](params)
+ if (active_check_type in _old_active_check_service_descriptions and
+ active_check_type not in use_new_descriptions_for):
+ description = _old_active_check_service_descriptions[active_check_type](params)
+ else:
+ act_info = checks.active_check_info[active_check_type]
+ description = act_info["service_description"](params)
+
description = description.replace('$HOSTNAME$', hostname)
return get_final_service_description(hostname, description)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1243d97..a8b2069 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14698,6 +14698,7 @@ def create_sample_config():
"nullmailer_mailq",
"barracuda_mailqueues",
"qmail_stats",
+ "http",
],
"enable_rulebased_notifications": True,
}
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 95e2f83..1e23127 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -864,7 +864,8 @@ register_rule(group,
TextUnicode(
title = _("Name"),
help = _("Will be used in the service description. If the name starts with "
- "a caret (<tt>^</tt>), the service description will not be prefixed with <tt>HTTP</tt>." ),
+ "a caret (<tt>^</tt>), the service description will not be prefixed with either "
+ "<tt>HTTP</tt> or <tt>HTTPS</tt>." ),
allow_empty = False),
Alternative(
title = _("Mode of the Check"),
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 4d05751..c94682e 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1270,6 +1270,7 @@ register_configvar(group,
( "nullmailer_mailq", _("Nullmailer: Mail Queue")),
( "barracuda_mailqueues", _("Barracuda: Mail Queue")),
( "qmail_stats", _("Qmail: Mail Queue")),
+ ( "http", _("Check HTTP: Use HTTPS instead of HTTP for SSL/TLS connectoins")),
],
render_orientation = "vertical",
),