Module: check_mk
Branch: master
Commit: 55c45c526746504488c16a1ca0cdc251bc246f3b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=55c45c52674650…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 10 13:32:19 2014 +0100
check_mail_loop: Added missing threshold configuration
---
checks/check_mail_loop | 4 ++++
doc/treasures/active_checks/check_mail_loop | 22 +++++++++++++---------
pnp-templates/check_mk_active-mail_loop.php | 6 +++++-
web/plugins/wato/active_checks.py | 9 ++++++++-
4 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/checks/check_mail_loop b/checks/check_mail_loop
index 2e9edbc..067240e 100644
--- a/checks/check_mail_loop
+++ b/checks/check_mail_loop
@@ -70,6 +70,10 @@ def check_mail_loop_arguments(params):
args += ' --status-suffix=%s' % quote_shell_string(g_hostname + '-' +
params['item'])
+ if 'duration' in params:
+ args += ' --warning=%d' % params['duration'][0]
+ args += ' --critical=%d' % params['duration'][1]
+
return args
diff --git a/doc/treasures/active_checks/check_mail_loop
b/doc/treasures/active_checks/check_mail_loop
index 25d341a..1d8761c 100755
--- a/doc/treasures/active_checks/check_mail_loop
+++ b/doc/treasures/active_checks/check_mail_loop
@@ -59,10 +59,12 @@ OPTIONS:
--mail-from MAIL Use this mail address as sender address
--mail-to MAIL Use this mail address as recipient address
- --warning AGE Age of the most recent mail in seconds to result
- in a WARNING state
- --critical AGE Age of the most recent mail in seconds to result
- in a CRITICAL state. Defaults to 1 hour
+ --warning AGE Loop duration of the most recent mail in seconds or
+ the average of all received mails within a single
+ check to raise a WARNING state
+ --critical AGE Loop duration of the most recent mail in seconds or
+ the average of all received mails within a single
+ check to raise a CRITICAL state
--connect-timeout Timeout in seconds for network connects (defaults to 10)
--status-dir PATH This plugin needs a file to store information about
@@ -312,8 +314,10 @@ def check_mails():
if critical != None and duration >= critical:
state = 2
+ output.append(' (>= %d)' % critical)
elif warning != None and duration >= warning:
state = max(state, 1)
+ output.append(' (>= %d)' % warning)
del g_expected[ident] # remove message from expect list
num_received += 1
@@ -330,13 +334,13 @@ def check_mails():
num_pending += 1
if num_received == 1:
- output.append('Mail received within %d seconds' % duration)
- perfdata.append(('duration', duration))
+ output.insert(0, 'Mail received within %d seconds' % duration)
+ perfdata.append(('duration', duration, warning or '', critical or
''))
elif num_received > 1:
- output.append('Received %d mails within average of %d seconds' %
(num_received, duration))
- perfdata.append(('duration', duration))
+ output.insert(0, 'Received %d mails within average of %d seconds' %
(num_received, duration))
+ perfdata.append(('duration', duration, warning or '', critical or
''))
else:
- output.append('Did not receive any new mail')
+ output.insert(0, 'Did not receive any new mail')
if num_lost:
output.append('Lost: %d (Did not arrive within %d seconds)' % (num_lost,
critical))
diff --git a/pnp-templates/check_mk_active-mail_loop.php
b/pnp-templates/check_mk_active-mail_loop.php
index 569e798..74ac890 100644
--- a/pnp-templates/check_mk_active-mail_loop.php
+++ b/pnp-templates/check_mk_active-mail_loop.php
@@ -29,5 +29,9 @@ $def[1] = "DEF:dur=$RRDFILE[1]:$DS[1]:MAX ";
$def[1] .= "AREA:dur#80f000:\"Duration (seconds)\" ";
$def[1] .= "LINE:dur#408000 ";
$def[1] .= "GPRINT:dur:LAST:\"%7.2lf %s LAST\" ";
-$def[1] .= "GPRINT:dur:MAX:\"%7.2lf %s MAX\" ";
+$def[1] .= "GPRINT:dur:MAX:\"%7.2lf %s MAX\\n\" ";
+if ($WARN[1])
+ $def[1] .= "HRULE:$WARN[1]#FFFF00:\"Warning at $WARN[1] sec\" ";
+if ($CRIT[1])
+ $def[1] .= "HRULE:$CRIT[1]#FF0000:\"Critical at $CRIT[1] sec\"
";
?>
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 41c7b63..8def316 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -1480,7 +1480,7 @@ register_rule(group,
'the SMTP protocol and then tries to receive these mails back by
querying the '
'inbox of a IMAP or POP3 mailbox. With this check you can verify
that your whole '
'mail delivery progress is working.'),
- optional_keys = ['smtp_server', 'smtp_tls', 'smtp_port',
'smtp_auth', 'connect_timeout', 'delete_messages'],
+ optional_keys = ['smtp_server', 'smtp_tls', 'smtp_port',
'smtp_auth', 'connect_timeout', 'delete_messages',
'duration'],
elements = [
('item', TextUnicode(
title = _('Name'),
@@ -1631,6 +1631,13 @@ register_rule(group,
default_value = 10,
unit = _('sec'),
)),
+ ("duration", Tuple(
+ title = _("Loop duration"),
+ elements = [
+ Age(title = _("Warning if above or equal")),
+ Age(title = _("Critical if above or equal")),
+ ])
+ ),
('delete_messages', FixedValue(True,
title = _('Delete processed messages'),
totext = _('Delete all processed message belonging to this
check'),