#!/usr/bin/env python3 import configparser import subprocess import haliteEmailer parser = configparser.ConfigParser() parser.read("../../halite.ini") HALITE_EMAIL = parser["email"]["email"] HALITE_EMAIL_PASSWORD = parser["email"]["password"] command = 'linkchecker --ignore-url=^mailto: --timeout=20 https://halite.io/' proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() stdout = stdout.decode('utf-8') stderr = stderr.decode('utf-8') if stdout.split("\n")[-3].find("0 errors") == -1: haliteEmailer.sendEmail(HALITE_EMAIL, HALITE_EMAIL_PASSWORD, "LINK ALERT", "There seem to be some broken links on http://halite.io/.<br>Here is what was given as the output of <b>\""+command+"\"</b> (<b>You will probably want more verbose output and so will have to run the command yourself</b>).<br><br>STDOUT:<br>"+stderr+"<br><br>STDERR:<br>"+stderr+"", HALITE_EMAIL)
import configparser import pymysql import haliteEmailer parser = configparser.ConfigParser() parser.read("../../halite.ini") DB_CONFIG = parser["database"] HALITE_EMAIL = parser["email"]["email"] HALITE_EMAIL_PASSWORD = parser["email"]["password"] db = pymysql.connect(host=DB_CONFIG["hostname"], user=DB_CONFIG['username'], passwd=DB_CONFIG['password'], db=DB_CONFIG['name']) cursor = db.cursor() cursor.execute( "select * from Worker WHERE TIMESTAMPDIFF(MINUTE, lastRequestTime, NOW()) > 30" ) results = cursor.fetchall() if len(results) == 0: print("All good!") else: message = "Some workers haven't communicated with the manager in a while!<br><br>" haliteEmailer.sendEmail(HALITE_EMAIL, HALITE_EMAIL_PASSWORD, str(len(results)) + " workers down", message, HALITE_EMAIL)
#!/usr/bin/env python3 import configparser import subprocess import haliteEmailer parser = configparser.ConfigParser() parser.read("../../halite.ini") HALITE_EMAIL = parser["email"]["email"] HALITE_EMAIL_PASSWORD = parser["email"]["password"] command = 'linkchecker --ignore-url=^mailto: --timeout=10 https://halite.io/' proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() stdout = stdout.decode('utf-8') stderr = stderr.decode('utf-8') if stdout.split("\n")[-3].find("0 errors") == -1: haliteEmailer.sendEmail(HALITE_EMAIL, HALITE_EMAIL_PASSWORD, "LINK ALERT", "There seem to be some broken links on http://halite.io/.<br>Here is what was given as the output of <b>\""+command+"\"</b> (<b>You will probably want more verbose output and so will have to run the command yourself</b>).<br><br>STDOUT:<br>"+stderr+"<br><br>STDERR:<br>"+stderr+"", HALITE_EMAIL)
#!/usr/bin/env python3 import configparser import pymysql import haliteEmailer parser = configparser.ConfigParser() parser.read("../../halite.ini") DB_CONFIG = parser["database"] HALITE_EMAIL = parser["email"]["email"] HALITE_EMAIL_PASSWORD = parser["email"]["password"] db = pymysql.connect(host=DB_CONFIG["hostname"], user=DB_CONFIG['username'], passwd=DB_CONFIG['password'], db=DB_CONFIG['name']) cursor = db.cursor() cursor.execute("select * from Worker WHERE TIMESTAMPDIFF(MINUTE, lastRequestTime, NOW()) > 30") results = cursor.fetchall() if len(results) == 0: print("All good!") else: message = "Some workers haven't communicated with the manager in a while!<br><br>" for res in results: message += "Worker with an id of "+str(res[0])+" and an api key "+str(res[1])+" hasn't contacted the manager for over 30 minutes.<br>" haliteEmailer.sendEmail(HALITE_EMAIL, HALITE_EMAIL_PASSWORD, "WORKER ALERT", message, HALITE_EMAIL)