Cleanup config.nodes_of
[check_mk.git] / checks / check_mail_loop
blob6ff678fd5c941341135c40a8aa70360b5195cd33
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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_mail_loop_arguments(params):
29 args = []
31 if 'smtp_server' in params:
32 args += ['--smtp-server=%s' % params['smtp_server']]
33 else:
34 args += ['--smtp-server=$HOSTADDRESS$']
36 if 'imap_tls' in params:
37 args += ['--imap-tls']
39 if 'smtp_tls' in params:
40 args += ['--smtp-tls']
42 if 'smtp_port' in params:
43 args += ['--smtp-port=%d' % params['smtp_port']]
45 if 'smtp_auth' in params:
46 args += ['--smtp-username=%s' % params['smtp_auth'][0]]
47 args += [passwordstore_get_cmdline("--smtp-password=%s", params['smtp_auth'][1])]
49 fetch_proto, fetch_params = params['fetch']
50 args += ['--fetch-protocol=%s' % fetch_proto]
52 if 'server' in fetch_params:
53 args += ['--fetch-server=%s' % fetch_params['server']]
54 else:
55 args += ['--fetch-server=$HOSTADDRESS$']
57 fetch_use_ssl, fetch_port = fetch_params['ssl']
58 if fetch_use_ssl:
59 args += ['--fetch-ssl']
60 if fetch_port is not None:
61 args += ['--fetch-port=%d' % fetch_port]
63 args += ['--fetch-username=%s' % fetch_params['auth'][0]]
64 args += [passwordstore_get_cmdline("--fetch-password=%s", fetch_params['auth'][1])]
66 args += ['--mail-from=%s' % params['mail_from']]
67 args += ['--mail-to=%s' % params['mail_to']]
69 if 'connect_timeout' in params:
70 args += ['--connect-timeout=%d' % params['connect_timeout']]
72 if 'delete_messages' in params:
73 args += ['--delete-messages']
75 args += ['--status-suffix=%s' % (host_name() + '-' + params['item'])]
77 if 'duration' in params:
78 args += ['--warning=%d' % params['duration'][0]]
79 args += ['--critical=%d' % params['duration'][1]]
81 if 'subject' in params:
82 args += ['--subject=%s' % params['subject']]
84 return args
87 active_check_info['mail_loop'] = {
88 "command_line": '$USER1$/check_mail_loop $ARG1$',
89 "argument_function": check_mail_loop_arguments,
90 "service_description": lambda params: "Mail Loop %s" % params['item'],
91 "has_perfdata": True,