mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
telegram
This commit is contained in:
@@ -26,5 +26,5 @@ HTTP_HOST_LIST=
|
|||||||
|
|
||||||
# --- Load Balancer script
|
# --- Load Balancer script
|
||||||
|
|
||||||
TELEGRAM_BOT_TOKEN=
|
TELEGRAM_TOKEN=
|
||||||
TELEGRAM_BOT_CHAT_ID=
|
TELEGRAM_CHAT_ID=
|
||||||
@@ -40,24 +40,24 @@ def run():
|
|||||||
if not host_ok:
|
if not host_ok:
|
||||||
message = f'ERROR with host: {host_ip}'
|
message = f'ERROR with host: {host_ip}'
|
||||||
print(message)
|
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:
|
except Exception as e:
|
||||||
message = f'ERROR with loadbalancer: {e}'
|
message = f'ERROR with loadbalancer: {e}'
|
||||||
print(message)
|
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):
|
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()
|
results = dict()
|
||||||
|
|
||||||
for host_ip in c['http_host_list']:
|
for host_ip in c['http_host_list']:
|
||||||
try:
|
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
|
results[host_ip] = True
|
||||||
except Exception:
|
except Exception:
|
||||||
results[host_ip] = False
|
results[host_ip] = False
|
||||||
@@ -79,7 +79,7 @@ def check_host(domain, host_ip, area, version):
|
|||||||
assert pycurl_status(url, domain, host_ip) == 200
|
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'
|
url = f'https://assets.openfreemap.com/versions/deployed_{area}.txt'
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ def setup_loadbalancer(c):
|
|||||||
config = {
|
config = {
|
||||||
'domain_ledns': domain_ledns,
|
'domain_ledns': domain_ledns,
|
||||||
'http_host_list': http_host_list,
|
'http_host_list': http_host_list,
|
||||||
'telegram_bot_token': dotenv_val('TELEGRAM_BOT_TOKEN'),
|
'telegram_token': dotenv_val('TELEGRAM_TOKEN'),
|
||||||
'telegram_bot_chat_id': dotenv_val('TELEGRAM_BOT_CHAT_ID'),
|
'telegram_chat_id': dotenv_val('TELEGRAM_CHAT_ID'),
|
||||||
}
|
}
|
||||||
|
|
||||||
config_str = json.dumps(config, indent=2, ensure_ascii=False)
|
config_str = json.dumps(config, indent=2, ensure_ascii=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user