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.
27 def check_mail_loop_arguments(params
):
30 if 'smtp_server' in params
:
31 args
+= [ '--smtp-server=%s' % params
['smtp_server'] ]
33 args
+= [ '--smtp-server=$HOSTADDRESS$' ]
35 if 'imap_tls' in params
:
36 args
+= [ '--imap-tls' ]
38 if 'smtp_tls' in params
:
39 args
+= [ '--smtp-tls' ]
41 if 'smtp_port' in params
:
42 args
+= [ '--smtp-port=%d' % params
['smtp_port'] ]
44 if 'smtp_auth' in params
:
45 args
+= [ '--smtp-username=%s' % params
['smtp_auth'][0] ]
46 args
+= [ passwordstore_get_cmdline("--smtp-password=%s", params
['smtp_auth'][1]) ]
48 fetch_proto
, fetch_params
= params
['fetch']
49 args
+= [ '--fetch-protocol=%s' % fetch_proto
]
51 if 'server' in fetch_params
:
52 args
+= [ '--fetch-server=%s' % fetch_params
['server'] ]
54 args
+= [ '--fetch-server=$HOSTADDRESS$' ]
56 fetch_use_ssl
, fetch_port
= fetch_params
['ssl']
58 args
+= [ '--fetch-ssl' ]
59 if fetch_port
!= None:
60 args
+= [ '--fetch-port=%d' % fetch_port
]
62 args
+= [ '--fetch-username=%s' % fetch_params
['auth'][0] ]
63 args
+= [ passwordstore_get_cmdline("--fetch-password=%s", fetch_params
['auth'][1]) ]
65 args
+= [ '--mail-from=%s' % params
['mail_from'] ]
66 args
+= [ '--mail-to=%s' % params
['mail_to'] ]
68 if 'connect_timeout' in params
:
69 args
+= [ '--connect-timeout=%d' % params
['connect_timeout'] ]
71 if 'delete_messages' in params
:
72 args
+= [ '--delete-messages' ]
74 args
+= [ '--status-suffix=%s' % (host_name() + '-' + params
['item']) ]
76 if 'duration' in params
:
77 args
+= [ '--warning=%d' % params
['duration'][0] ]
78 args
+= [ '--critical=%d' % params
['duration'][1] ]
80 if 'subject' in params
:
81 args
+= ' --subject=%s' % quote_shell_string(params
['subject'])
86 active_check_info
['mail_loop'] = {
87 "command_line" : '$USER1$/check_mail_loop $ARG1$',
88 "argument_function" : check_mail_loop_arguments
,
89 "service_description" : lambda params
: "Mail Loop %s" % params
['item'],
90 "has_perfdata" : True,