File: //lib/python2.7/site-packages/lap/ftp.py
import socket
socket.setdefaulttimeout(5)
from ftplib import FTP
def __run__(params):
try:
timeout = 5
if params.get("timeout"):
timeout = params.get("timeout")
connection = FTP()
connection.connect(params.get("hostname", "localhost"), params.get("port", 21), timeout)
if params.get("username") and params.get("password"):
connection.login(params.get("username"), params.get("password"))
except socket.timeout:
return [2, 'CRITICAL: Socket timeout']
except socket.gaierror:
return [2, 'CRITICAL: Unable to resolve domain']
except Exception, e:
return [2,'CRITICAL: %s' % repr(e)]
else:
return [0, "OK"]