diff --git a/data.py b/data.py index cffb09f..6c1185a 100644 --- a/data.py +++ b/data.py @@ -14,6 +14,7 @@ PRIORITY = { "CRITICAL":2, "UNKNOWN": 2, "DOWN": 3, + "DRBD": 3 } @@ -158,6 +159,9 @@ class DataStore: # Service problem else: + if "DRBD" in service: + status = "DRBD" + cur_problem = None # Look for existing problem @@ -191,7 +195,7 @@ class DataStore: cur.status = worst_problem.status cur.worst = worst_problem.name - if PRIORITY[status] >= 2 or ("RECOVERY" in mtype and cur.worst == None): + if PRIORITY[status] >= 2: self.notify(destmuc) return diff --git a/main.py b/main.py index 7495fd5..8fb5edc 100755 --- a/main.py +++ b/main.py @@ -14,25 +14,27 @@ from bot import MUCBot from data import DataStore from localServer import LocalServer +def cleanExit(): + global localservthread + localservthread.pleaseStop = True + time.sleep(1) + # stop tcp server + sockfd = socket.socket() + port = 12346 + sockfd.connect(('127.0.0.1', port)) + sockfd.send(b'') + sockfd.close() + time.sleep(1) + + exit(0) + + +def signalHandler(sig, frame): + log.info("Exiting...") + cleanExit() + if __name__ == '__main__': - def cleanExit(): - global localservthread - localservthread.pleaseStop = True - # stop tcp server - sockfd = socket.socket() - port = 12346 - sockfd.connect(('127.0.0.1', port)) - sockfd.send(b'') - sockfd.close() - - exit(0) - - - def signalHandler(sig, frame): - log.info("Exiting...") - cleanExit() - # Register SIGINT signal handler signal.signal(signal.SIGINT, signalHandler) @@ -114,7 +116,8 @@ if __name__ == '__main__': exit(1) try: - xmpp.process() + log.info("Launching XMPP connection until disconnection (ERRORS: %s)" % ERRORS) + xmpp.loop.run_until_complete(xmpp.disconnected) except KeyboardInterrupt: cleanExit() except Exception as e: @@ -122,6 +125,5 @@ if __name__ == '__main__': if ERRORS >= 3: log.critical("3 consecutive errors. Aborting...") cleanExit() - ERRORS += 1 del xmpp