File: //usr/lib/python2.7/site-packages/lap/check_ftp_laserhouse.py
import yaml
from ftplib import FTP
def __run__(params):
server = params.get("server")
user = params.get("user")
password = params.get("password")
try:
ftp = FTP(server,user,password)
except Exception, e:
return [2, "CRITICAL - Error: %s" % repr(e)]
try:
qtdfiles = len(ftp.nlst('/'))
except Exception, e:
return [2, "CRITICAL - Error: %s" % repr(e)]
ftp.quit()
if qtdfiles < 2:
return [2, "CRITICAL 2 - Lack of LaserHouse files. Less than 2 files into the main folder"]
else:
return [0, "OK - FTP Connection is working"]