Module: check_mk
Branch: master
Commit: fa27b44fab56bd2c6e50b058f7108769b6964d27
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa27b44fab56bd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 22 13:44:33 2016 +0200
3420 FIX check_ftp, check_tcp, check_smtp: add missing CRIT levels for certificate live
time
Thanks to Gregor Hoffleit.
---
.werks/3420 | 10 ++++++
ChangeLog | 1 +
checks/check_ftp | 7 +++-
checks/check_smtp | 9 +++--
checks/check_tcp | 7 +++-
web/plugins/wato/active_checks.py | 67 ++++++++++++++++++++++++-------------
6 files changed, 73 insertions(+), 28 deletions(-)
diff --git a/.werks/3420 b/.werks/3420
new file mode 100644
index 0000000..7f8662a
--- /dev/null
+++ b/.werks/3420
@@ -0,0 +1,10 @@
+Title: check_ftp, check_tcp, check_smtp: add missing CRIT levels for certificate live
time
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461325421
+
+Thanks to Gregor Hoffleit.
diff --git a/ChangeLog b/ChangeLog
index 874aa8b..997bf1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -176,6 +176,7 @@
* 3434 FIX: cmctc_lcp: Fixed broken check in case parameter are specified
* 3435 FIX: check_varnish_uptime: Fixed broken check
* 3419 FIX: solaris_mem: avoid crash in case of empty agent section, treat section as
missing...
+ * 3420 FIX: check_ftp, check_tcp, check_smtp: add missing CRIT levels for certificate
live time...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/check_ftp b/checks/check_ftp
index 596e470..b3c0e34 100644
--- a/checks/check_ftp
+++ b/checks/check_ftp
@@ -61,7 +61,12 @@ def check_ftp_arguments(params):
args += ' --ssl'
if "cert_days" in settings:
- args += ' -D %d' % settings["cert_days"]
+ # legacy behavior
+ if type(settings["cert_days"]) == int:
+ args += ' -D %d' % settings["cert_days"]
+ else:
+ warn, crit = settings["cert_days"]
+ args += ' -D %d,%d' % (warn, crit)
return args
diff --git a/checks/check_smtp b/checks/check_smtp
index c5db085..2aabd5e 100644
--- a/checks/check_smtp
+++ b/checks/check_smtp
@@ -78,8 +78,13 @@ def check_smtp_arguments(params):
if 'fqdn' in settings:
args += ' -F %s' % quote_shell_string(settings['fqdn'])
- if 'cert_days' in settings:
- args += ' -D %d' % settings['cert_days']
+ if "cert_days" in settings:
+ # legacy behavior
+ if type(settings["cert_days"]) == int:
+ args += ' -D %d' % settings["cert_days"]
+ else:
+ warn, crit = settings["cert_days"]
+ args += ' -D %d,%d' % (warn, crit)
if 'hostname' in settings:
args += ' -H %s' % settings['hostname']
diff --git a/checks/check_tcp b/checks/check_tcp
index ce46f85..ded7076 100644
--- a/checks/check_tcp
+++ b/checks/check_tcp
@@ -68,7 +68,12 @@ def check_tcp_arguments(params):
args += ' --ssl'
if "cert_days" in settings:
- args += ' -D %d' % settings["cert_days"]
+ # legacy behavior
+ if type(settings["cert_days"]) == int:
+ args += ' -D %d' % settings["cert_days"]
+ else:
+ warn, crit = settings["cert_days"]
+ args += ' -D %d,%d' % (warn, crit)
if "quit_string" in settings:
args += ' -q %s' % quote_shell_string(settings["quit_string"])
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 9e4f373..1a86264 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -250,6 +250,14 @@ register_rule(group,
match = "all",
)
+# Several active checks just had crit levels as one integer
+def transform_cert_days(cert_days):
+ if type(cert_days) != tuple:
+ return (cert_days, 0)
+ else:
+ return cert_days
+
+
register_rule(group,
"active_checks:ftp",
Transform(
@@ -312,11 +320,17 @@ register_rule(group,
),
( "cert_days",
- Integer(
- title = _("SSL certificate validation"),
- help = _("Minimum number of days a certificate has to be
valid"),
- unit = _("days"),
- default_value = 30)
+ Transform(
+ Tuple(
+ title = _("SSL certificate validation"),
+ help = _("Minimum number of days a certificate has to be
valid"),
+ elements = [
+ Integer(title = _("Warning at or below"),
minvalue = 0, unit = _("days")),
+ Integer(title = _("Critical at or below"),
minvalue = 0, unit = _("days")),
+ ],
+ ),
+ forth = transform_cert_days,
+ ),
),
]),
forth = lambda x: type(x) == tuple and x[1] or x,
@@ -631,11 +645,17 @@ register_rule(group,
),
( "cert_days",
- Integer(
- title = _("SSL certificate validation"),
- help = _("Minimum number of days a certificate has to be
valid"),
- unit = _("days"),
- default_value = 30)
+ Transform(
+ Tuple(
+ title = _("SSL certificate validation"),
+ help = _("Minimum number of days a certificate has to
be valid"),
+ elements = [
+ Integer(title = _("Warning at or below"),
minvalue = 0, unit = _("days")),
+ Integer(title = _("Critical at or below"),
minvalue = 0, unit = _("days")),
+ ],
+ ),
+ forth = transform_cert_days,
+ ),
),
( "quit_string",
@@ -691,12 +711,6 @@ register_rule(group,
]))
-# cert_days was only an integer for warning level until version 1.2.7
-def transform_check_http_cert_days(cert_days):
- if type(cert_days) != tuple:
- cert_days = (cert_days, 0)
- return cert_days
-
ip_address_family_element = ("address_family",
DropdownChoice(
title = _("IP Address Family"),
@@ -1008,7 +1022,7 @@ register_rule(group,
Integer(title = _("Critical at or
below"), minvalue = 0, unit = _("days")),
],
),
- forth = transform_check_http_cert_days,
+ forth = transform_cert_days,
),
),
( "cert_host",
@@ -1241,13 +1255,18 @@ register_rule(group,
default_value = "",
)
),
- ("cert_days",
- Integer(
- title = _("Minimum Certificate Age"),
- help = _("Minimum number of days a certificate has to
be valid."),
- unit = _("days"),
- )
- ),
+ ( "cert_days",
+ Transform(
+ Tuple(
+ title = _("Minimum Certificate Age"),
+ help = _("Minimum number of days a certificate has
to be valid"),
+ elements = [
+ Integer(title = _("Warning at or below"),
minvalue = 0, unit = _("days")),
+ Integer(title = _("Critical at or below"),
minvalue = 0, unit = _("days")),
+ ],
+ ),
+ forth = transform_cert_days,
+ )),
("starttls",
FixedValue(
True,