Récupération de déconnexion et non notification des états non graves
This commit is contained in:
parent
81ac8af5cc
commit
4b127ac1c6
6
data.py
6
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
|
||||
|
|
10
main.py
10
main.py
|
@ -14,17 +14,17 @@ from bot import MUCBot
|
|||
from data import DataStore
|
||||
from localServer import LocalServer
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
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)
|
||||
|
||||
|
@ -33,6 +33,8 @@ if __name__ == '__main__':
|
|||
log.info("Exiting...")
|
||||
cleanExit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue