mirror of
https://github.com/simple-login/app.git
synced 2024-09-29 21:21:29 +02:00
monitoring: alert when fails for 10 minutes
This commit is contained in:
parent
b99085419e
commit
731b8db5cb
@ -8,11 +8,13 @@ from app.models import Monitoring
|
|||||||
from server import create_app
|
from server import create_app
|
||||||
|
|
||||||
# the number of consecutive fails
|
# the number of consecutive fails
|
||||||
# if more than 3 fails, alert
|
# if more than _max_nb_fails, alert
|
||||||
# reset whenever the system comes back to normal
|
# reset whenever the system comes back to normal
|
||||||
# a system is considered fail if incoming_queue + active_queue > 50
|
# a system is considered fail if incoming_queue + active_queue > 50
|
||||||
_nb_failed = 0
|
_nb_failed = 0
|
||||||
|
|
||||||
|
_max_nb_fails = 10
|
||||||
|
|
||||||
|
|
||||||
def get_stats():
|
def get_stats():
|
||||||
"""Look at different metrics and alert appropriately"""
|
"""Look at different metrics and alert appropriately"""
|
||||||
@ -35,7 +37,7 @@ def get_stats():
|
|||||||
if incoming_queue + active_queue > 50:
|
if incoming_queue + active_queue > 50:
|
||||||
_nb_failed += 1
|
_nb_failed += 1
|
||||||
|
|
||||||
if _nb_failed > 3:
|
if _nb_failed > _max_nb_fails:
|
||||||
# reset
|
# reset
|
||||||
_nb_failed = 0
|
_nb_failed = 0
|
||||||
|
|
||||||
@ -59,5 +61,5 @@ if __name__ == "__main__":
|
|||||||
with app.app_context():
|
with app.app_context():
|
||||||
get_stats()
|
get_stats()
|
||||||
|
|
||||||
# 2 min
|
# 1 min
|
||||||
sleep(120)
|
sleep(60)
|
||||||
|
Loading…
Reference in New Issue
Block a user