From 02bfe0eb55edd8c9be608e49a6053fe2ce673bd2 Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Sun, 9 Jun 2024 22:32:43 +0200 Subject: [PATCH] telegram --- config/.env.sample | 4 ++-- scripts/loadbalancer/loadbalancer.py | 12 ++++++------ ssh_lib/tasks.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/.env.sample b/config/.env.sample index 28344a7..f1e1043 100644 --- a/config/.env.sample +++ b/config/.env.sample @@ -26,5 +26,5 @@ HTTP_HOST_LIST= # --- Load Balancer script -TELEGRAM_BOT_TOKEN= -TELEGRAM_BOT_CHAT_ID= \ No newline at end of file +TELEGRAM_TOKEN= +TELEGRAM_CHAT_ID= \ No newline at end of file diff --git a/scripts/loadbalancer/loadbalancer.py b/scripts/loadbalancer/loadbalancer.py index fb17b0c..8df1b06 100755 --- a/scripts/loadbalancer/loadbalancer.py +++ b/scripts/loadbalancer/loadbalancer.py @@ -40,24 +40,24 @@ def run(): if not host_ok: message = f'ERROR with host: {host_ip}' print(message) - telegram_send_message(message, c['telegram_bot_token'], c['telegram_chat_id']) + telegram_send_message(message, c['telegram_token'], c['telegram_chat_id']) except Exception as e: message = f'ERROR with loadbalancer: {e}' print(message) - telegram_send_message(message, c['telegram_bot_token'], c['telegram_chat_id']) + telegram_send_message(message, c['telegram_token'], c['telegram_chat_id']) def run_area(c, area): - deployed_version = get_deployed_version(area) + target_version = get_target_version(area) - print(f'deployed version: {area}: {deployed_version}') + print(f'target version: {area}: {target_version}') results = dict() for host_ip in c['http_host_list']: try: - check_host(c['domain_ledns'], host_ip, area, deployed_version) + check_host(c['domain_ledns'], host_ip, area, target_version) results[host_ip] = True except Exception: results[host_ip] = False @@ -79,7 +79,7 @@ def check_host(domain, host_ip, area, version): assert pycurl_status(url, domain, host_ip) == 200 -def get_deployed_version(area): +def get_target_version(area): url = f'https://assets.openfreemap.com/versions/deployed_{area}.txt' response = requests.get(url) response.raise_for_status() diff --git a/ssh_lib/tasks.py b/ssh_lib/tasks.py index b7bdaab..f8a9ef0 100644 --- a/ssh_lib/tasks.py +++ b/ssh_lib/tasks.py @@ -229,8 +229,8 @@ def setup_loadbalancer(c): config = { 'domain_ledns': domain_ledns, 'http_host_list': http_host_list, - 'telegram_bot_token': dotenv_val('TELEGRAM_BOT_TOKEN'), - 'telegram_bot_chat_id': dotenv_val('TELEGRAM_BOT_CHAT_ID'), + 'telegram_token': dotenv_val('TELEGRAM_TOKEN'), + 'telegram_chat_id': dotenv_val('TELEGRAM_CHAT_ID'), } config_str = json.dumps(config, indent=2, ensure_ascii=False)