Cleanup config.nodes_of
[check_mk.git] / checks / check_ftp
blobfee5908a371e552410a68c9c544e500e807fca5b
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_ftp_arguments(params):
29 if isinstance(params, tuple):
30 host, settings = params
31 else:
32 host = "$HOSTADDRESS$"
33 settings = params
35 args = ' -H %s' % quote_shell_string(host)
37 if "port" in settings:
38 args += ' -p %d' % settings['port']
40 if "response_time" in settings:
41 args += ' -w %f -c %f' % (settings["response_time"][0] / 1000.0,
42 settings["response_time"][1] / 1000.0)
44 if "timeout" in settings:
45 args += ' -t %d' % settings["timeout"]
47 if "refuse_state" in settings:
48 args += ' -r %s' % settings["refuse_state"]
50 if settings.get("escape_send_string"):
51 args += ' --escape'
53 if "send_string" in settings:
54 args += ' -s %s' % quote_shell_string(settings["send_string"])
56 if "expect" in settings:
57 for s in settings["expect"]:
58 args += ' -e %s' % quote_shell_string(s)
60 if settings.get("ssl"):
61 args += ' --ssl'
63 if "cert_days" in settings:
64 # legacy behavior
65 if isinstance(settings["cert_days"], int):
66 args += ' -D %d' % settings["cert_days"]
67 else:
68 warn, crit = settings["cert_days"]
69 args += ' -D %d,%d' % (warn, crit)
71 return args
74 def check_ftp_get_item(params):
75 if isinstance(params, tuple):
76 return "FTP " + params[0]
77 else:
78 if "port" in params and params["port"] != 21:
79 return "FTP Port " + str(params["port"])
80 return "FTP"
83 active_check_info['ftp'] = {
84 "command_line": '$USER1$/check_ftp $ARG1$',
85 "argument_function": check_ftp_arguments,
86 "service_description": check_ftp_get_item,
87 "has_perfdata": True,