def test(username=config_user.USER, password=config_user.PASSWORD): try: imap = imaplib.IMAP4('localhost', 143) imap.login(username, password) show_ok('Cyrus') except socket.error, e: show_ko('Cyrus', 'Try: systemctl restart cyrus-imapd.service', e)
def test(server='127.0.0.1', port=12345): try: s = socket.socket() s.connect((server, port)) show_ok('OpenDMARC') except socket.error, e: show_ko('OpenDMARC', 'Try: systemctl restart opendmarc.service', e)
def test(socket='/var/run/clamav/clamd.ctl'): try: client = clamd.ClamdUnixSocket(socket) client.ping() show_ok('ClamavDeamon') except clamd.ConnectionError, e: show_ko('ClamavDeamon', 'Try: systemctl restart clamav-daemon.socket', e)
def test(ntp_server='127.0.0.1'): try: c = ntplib.NTPClient() response = c.request(ntp_server) if DEBUG: print(ctime(response.tx_time)) show_ok('Ntpd') except ntplib.NTPException, e: show_ko('Ntpd', 'Try: systemctl restart ntp.service', e)
def test(server='127.0.0.1', port='80'): try: r = requests.get('http://{}:{}/'.format(server, port)) if r.status_code == 200: show_ok('Nginx') else: show_ko('Nginx', 'Try: systemctl restart nginx.service') except requests.exceptions.ConnectionError, e: show_ko('Nginx', 'Try: systemctl restart nginx.service', e)
def test(uid=UID, password=PASSWORD, server='ldap://localhost'): try: LDAP = ldap.initialize(server) LDAP.bind_s(uid, password) show_ok('LDAP') except ldap.INVALID_CREDENTIALS: show_ko('LDAP', 'Your username or password is incorrect.') except ldap.LDAPError, e: if type(e.message) == dict and 'desc' in e.message: error = e.message['desc'] else: error = e show_ko('LDAP', 'Try: systemctl restart slapd.service', error)
def test(username=config_user.USER, password=config_user.PASSWORD, server='localhost', port=587): try: smtp = smtplib.SMTP() smtp.connect(server, port) smtp.ehlo() smtp.starttls() smtp.ehlo() smtp.login(username, password) show_ok('Postfix') except smtplib.SMTPResponseException, e: show_ko('Postfix', 'Try: systemctl restart postfix.service', e)
def test(test_mode=False): command = 'nslcd --check' process_exec = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process_exec.wait() if test_mode: returncode = 1 else: returncode = process_exec.returncode if returncode == 0: show_ok('nslcd') else: show_ko('nslcd', 'Try: systemctl restart nslcd.service')
def test(base='/var/www/www', script='/ping.php', server='127.0.0.1:9000'): command = 'SCRIPT_NAME={script} SCRIPT_FILENAME={base}{script} REQUEST_METHOD=GET cgi-fcgi -bind -connect {server}'.format( base=base, script=script, server=server) if DEBUG: print(command) process_exec = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process_exec.wait() returncode = process_exec.returncode if DEBUG: print(returncode) if returncode == 0: show_ok('php5-fpm') else: error = '\n'.join(process_exec.stderr.readlines()) show_ko('php5-fpm', 'Try: systemctl restart php5-fpm.service', error)
def test(username=config_user.USER, password=config_user.PASSWORD, mux='/var/run/saslauthd/mux'): cmd = '/usr/sbin/testsaslauthd -u {} -p {} -f {}'.format(username, password, mux) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, close_fds=True) p.wait() if p.returncode == 0: show_ok('SASL') else: hint = [] error = [] error.append('Failed with mux: {}'.format(mux)) for line in p.stdout.readlines(): error.append(line) if mux == '/var/run/saslauthd/mux': hint.append('Try: ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd') hint.append('Try: systemctl restart saslauthd.service') show_ko('SASL', '\n'.join(hint), '\n'.join(error))
def test(socket_path='/var/spool/postfix/spamass/spamass.sock'): if os.path.exists(socket_path): show_ok('Spamassassin-milter') else: show_ko('Spamassassin-milter', 'Try: systemctl restart spamass-milter.service')
def test(socket_path='/var/spool/postfix/clamav/clamav-milter.ctl'): if os.path.exists(socket_path): show_ok('Clamav-milter') else: show_ko('Clamav-milter', 'Try: systemctl restart clamav-milter.service')