Module: check_mk
Branch: master
Commit: ff6bc592a59364dde553cb903671f91e4524d40c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff6bc592a59364…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 7 11:13:53 2012 +0200
Added new active check configuration for check_smtp
---
ChangeLog | 1 +
checks/check_smtp | 84 ++++++++++++++++++++++
web/plugins/wato/active_checks.py | 138 ++++++++++++++++++++++++++++++++++++-
3 files changed, 222 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 87cfc5c..79654a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -70,6 +70,7 @@
* parent scan: new option "ping probes", that allows skipping
unreachable gateways.
* User managament: Added fields for editing host/service notification commands
+ * Added new active check configuration for check_smtp
* FIX: Removed double collect_hosts() call in activate changes hook
* FIX: Fixed double hook execution when using localized multisite
* FIX: User list shows names of contactgroups when no alias given
diff --git a/checks/check_smtp b/checks/check_smtp
new file mode 100644
index 0000000..50cc3be
--- /dev/null
+++ b/checks/check_smtp
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def check_smtp_arguments(params):
+ description, settings = params
+ args = ''
+
+ if "expect" in settings:
+ args += ' -e %s' % quote_shell_string(settings["expect"])
+
+ if "port" in settings:
+ args += ' -p %s' % quote_shell_string(settings["port"])
+
+ if "ip_version" in settings:
+ if settings['ip_version'] == 'ipv4':
+ args += ' -4'
+ else:
+ args += ' -6'
+
+ for s in settings.get("commands", []):
+ args += ' -C %s' % quote_shell_string(s)
+
+ for s in settings.get("command_responses", []):
+ args += ' -R %s' % quote_shell_string(s)
+
+ if settings.get('from'):
+ args += ' -f %s' % quote_shell_string(settings["from"])
+
+ if "response_time" in settings:
+ args += ' -w %d -c %d' % (
+ settings["response_time"][0],
+ settings["response_time"][1])
+
+ if "timeout" in settings:
+ args += ' -t %d' % settings["timeout"]
+
+ if "auth" in settings:
+ auth = settings["auth"]
+ args += ' -A LOGIN -U %s -P %s' % (quote_shell_string(auth[0]),
quote_shell_string(auth[1]))
+
+ if settings.get('starttls', False):
+ args += ' -S'
+
+ if 'fqdn' in settings:
+ args += ' -F %s' % quote_shell_string(settings['fqdn'])
+
+ if 'cert_days' in settings:
+ args += ' -D %d' % settings['cert_days']
+
+ print args
+
+ return args
+
+
+active_check_info['smtp'] = {
+ "command_line" : '$USER1$/check_smtp $ARG1$',
+ "argument_function" : check_smtp_arguments,
+ "service_description" : lambda params: "SMTP %s" % params[0],
+ "has_perfdata" : True,
+}
+
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 6fc5619..f3259f8 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -578,7 +578,143 @@ register_rule(group,
match = 'all'
)
-
+register_rule(group,
+ "active_checks:smtp",
+ Tuple(
+ title = _("Check access to SMTP services"),
+ help = _("This check uses <tt>check_smtp</tt> from the standard
"
+ "Nagios plugins in order to try the response of an SMTP "
+ "server."),
+ elements = [
+ TextUnicode(
+ title = _("Name"),
+ help = _("The service description will be <b>SMTP</b>
plus this name"),
+ allow_empty = False),
+ Dictionary(
+ title = _("Optional parameters"),
+ elements = [
+ ( "port",
+ TextAscii(
+ title = _("TCP Port to connect to"),
+ help = _("The TCP Port the SMTP server is listening on.
"
+ "The default is <tt>25</tt>."),
+ size = 5,
+ allow_empty = False,
+ default_value = "25",
+ )
+ ),
+ ( "ip_version",
+ Alternative(
+ title = _("IP-Version"),
+ elements = [
+ FixedValue(
+ "ipv4",
+ totext = "",
+ title = _("IPv4")
+ ),
+ FixedValue(
+ "ipv6",
+ totext = "",
+ title = _("IPv6")
+ ),
+ ],
+ ),
+ ),
+ ( "expect",
+ TextAscii(
+ title = _("Expected String"),
+ help = _("String to expect in first line of server
response. "
+ "The default is <tt>220</tt>."),
+ size = 8,
+ allow_empty = False,
+ default_value = "220",
+ )
+ ),
+ ('commands',
+ ListOfStrings(
+ title = _("SMTP Commands"),
+ help = _("SMTP commands to execute."),
+ )
+ ),
+ ('command_responses',
+ ListOfStrings(
+ title = _("SMTP Responses"),
+ help = _("Expected responses to the given SMTP
commands."),
+ )
+ ),
+ ("from",
+ TextAscii(
+ title = _("FROM-Address"),
+ help = _("FROM-address to include in MAIL command, required
by Exchange 2000"),
+ size = 20,
+ allow_empty = True,
+ default_value = "",
+ )
+ ),
+ ("fqdn",
+ TextAscii(
+ title = _("FQDN"),
+ help = _("FQDN used for HELO"),
+ size = 20,
+ allow_empty = True,
+ default_value = "",
+ )
+ ),
+ ("cert_days",
+ Integer(
+ title = _("Minimum Certificate Age"),
+ help = _("Minimum number of days a certificate has to be
valid."),
+ unit = _("days"),
+ )
+ ),
+ ("starttls",
+ FixedValue(
+ True,
+ totext = "STARTTLS enabled.",
+ title = _("Use STARTTLS for the connection.")
+ )
+ ),
+ ( "auth",
+ Tuple(
+ title = _("Enable SMTP AUTH (LOGIN)"),
+ help = _("SMTP AUTH type to check (default none, only LOGIN
supported)"),
+ elements = [
+ TextAscii(
+ title = _("Username"),
+ size = 12,
+ allow_empty = False),
+ TextAscii(
+ title = _("Password"),
+ size = 12,
+ allow_empty = False),
+ ]
+ )
+ ),
+ ("response_time",
+ Tuple(
+ title = _("Expected response time"),
+ elements = [
+ Integer(
+ title = _("Warning at"),
+ unit = "sec"
+ ),
+ Integer(
+ title = _("Critical at"),
+ unit = "sec"
+ ),
+ ])
+ ),
+ ( "timeout",
+ Integer(
+ title = _("Seconds before connection times out"),
+ unit = _("sec"),
+ default_value = 10,
+ )
+ ),
+ ])
+ ]),
+ match = 'all'
+)
register_rule(group,
"custom_checks",