示例#1
0
 def check_heartbeat(self):
     cur_date = time.strftime("%d/%m/%Y")
     if self.last_heart_beat_date != cur_date:
         self.last_heart_beat_date = cur_date
         title = "%s heart beat" % self.server_name
         message = "This is the heart beat from your dear server."
         if not alert_sender.send_mail(self.admin_email, title, message):
             logger.log("ERROR", "[PSysMonitor] Sending heartbeat mail error!")
示例#2
0
 def check_heartbeat(self):
     cur_date = time.strftime("%d/%m/%Y")
     if self.last_heart_beat_date != cur_date:
         self.last_heart_beat_date = cur_date
         title = "%s heart beat" % self.server_name
         message = "This is the heart beat from your dear server."
         if not alert_sender.send_mail(self.admin_email, title, message):
             logger.log("ERROR",
                        "[PSysMonitor] Sending heartbeat mail error!")
示例#3
0
def traffker():

    endpoint_list = host_list()

    for endpoint in endpoint_list:
        check = ping(endpoint)
        dash = "-" * 20
        nc = next_check(endpoint)

        if interval_expired(endpoint) == 1:

            if check == None:
                # update to db with FAILURE
                update_endpoint_status(endpoint, "NONE", 0, nc)
                print(f"{endpoint} is DOWN! Sending alert!")
                print(f"Next check at: {nc}")
                print(dash)
                send_mail(endpoint)

            else:
                # update to db with SUCCESS
                check_ms = int(check * 1000)
                print(f"Endpoint: {endpoint} Response Time : {check_ms}ms")
                update_endpoint_status(endpoint, check_ms, 1, nc)
                print(f"{endpoint} is UP!")
                print(f"Next check at: {next_check(endpoint)}")
                print(dash)
        
        else:
            print("")
            print(f"{endpoint} check interval not expired.  Passing check.")
            print("")
            print(dash)    
    stime = 1
    #print(f"Check Done.  Sleeping for {stime} seconds.")
    time.sleep(stime)
示例#4
0
 def report_ok(self):
     if not alert_sender.send_mail(self.admin_email, self.server_name+" System Recover", "Congratulation"):
         logger.log("ERROR", "[PSysMonitor] Sending mail error!")
示例#5
0
 def report_exception(self, message):
     if not alert_sender.send_mail(self.admin_email, self.server_name+" System Warning", message):
         logger.log("ERROR", "[PSysMonitor] Sending mail error!")
示例#6
0
 def report_ok(self):
     if not alert_sender.send_mail(self.admin_email, self.server_name +
                                   " System Recover", "Congratulation"):
         logger.log("ERROR", "[PSysMonitor] Sending mail error!")
示例#7
0
 def report_exception(self, message):
     if not alert_sender.send_mail(self.admin_email, self.server_name +
                                   " System Warning", message):
         logger.log("ERROR", "[PSysMonitor] Sending mail error!")