diff --git a/scripts/loadbalancer/loadbalancer.py b/scripts/loadbalancer/loadbalancer.py index 26d07cb..6a40241 100755 --- a/scripts/loadbalancer/loadbalancer.py +++ b/scripts/loadbalancer/loadbalancer.py @@ -27,9 +27,22 @@ def run(): c = json.load(fp) print(c) - for area in AREAS: - results = run_area(c, area) - print(results) + try: + results_by_ip = {} + + for area in AREAS: + for host_ip, host_ok in run_area(c, area).items(): + results_by_ip.setdefault(host_ip, True) + results_by_ip[host_ip] &= host_ok + + for host_ip, host_ok in results_by_ip.items(): + if not host_ok: + print(f'{host_ip} ERROR') + # TODO send message + + except Exception as e: + print(e) + # TODO send message def run_area(c, area): diff --git a/scripts/loadbalancer/telegram.py b/scripts/loadbalancer/telegram.py new file mode 100644 index 0000000..21063d6 --- /dev/null +++ b/scripts/loadbalancer/telegram.py @@ -0,0 +1,12 @@ +from telegram import Bot + + +bot = Bot(token='YOUR_BOT_TOKEN') + +# Replace 'CHAT_ID' with the chat ID you want to send the message to +chat_id = 'CHAT_ID' + +# The message you want to send +message = 'Hello, this is a test message from my bot!' + +bot.send_message(chat_id=chat_id, text=message)