2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def check_smtp_arguments(params
):
29 _description
, settings
= params
32 if "expect" in settings
:
33 args
+= ' -e %s' % quote_shell_string(settings
["expect"])
35 if "port" in settings
:
36 port
= int(settings
["port"]) # ValueSpec was broken, convert to int
37 args
+= ' -p %d' % port
39 # Be compatible to legacy option
40 if "ip_version" in settings
:
41 settings
["address_family"] = settings
.pop("ip_version")
43 # Use the address family of the monitored host by default
44 address_family
= settings
.get("address_family")
45 if address_family
is None:
46 address_family
= "ipv6" if is_ipv6_primary(host_name()) else "ipv4"
48 if address_family
== "ipv6":
50 address
= "$_HOSTADDRESS_6$"
53 address
= "$_HOSTADDRESS_4$"
55 for s
in settings
.get("commands", []):
56 args
+= ' -C %s' % quote_shell_string(s
)
58 for s
in settings
.get("command_responses", []):
59 args
+= ' -R %s' % quote_shell_string(s
)
61 if settings
.get('from'):
62 args
+= ' -f %s' % quote_shell_string(settings
["from"])
64 if "response_time" in settings
:
65 args
+= ' -w %0.4f -c %0.4f' % (settings
["response_time"][0], settings
["response_time"][1])
67 if "timeout" in settings
:
68 args
+= ' -t %d' % settings
["timeout"]
70 if "auth" in settings
:
71 auth
= settings
["auth"]
72 args
+= ' -A LOGIN -U %s -P %s' % (quote_shell_string(auth
[0]), quote_shell_string(auth
[1]))
74 if settings
.get('starttls', False):
77 if 'fqdn' in settings
:
78 args
+= ' -F %s' % quote_shell_string(settings
['fqdn'])
80 if "cert_days" in settings
:
82 if isinstance(settings
["cert_days"], int):
83 args
+= ' -D %d' % settings
["cert_days"]
85 warn
, crit
= settings
["cert_days"]
86 args
+= ' -D %d,%d' % (warn
, crit
)
88 if 'hostname' in settings
:
89 args
+= ' -H %s' % settings
['hostname']
91 args
+= ' -H ' + address
95 def check_smtp_desc(params
):
96 if params
[0].startswith("^"):
98 return "SMTP %s" % params
[0]
101 active_check_info
['smtp'] = {
102 "command_line": '$USER1$/check_smtp $ARG1$',
103 "argument_function": check_smtp_arguments
,
104 "service_description": check_smtp_desc
,
105 "has_perfdata": True,