feat: добавлено подробное логирование состояния серверов
This commit is contained in:
@@ -239,6 +239,24 @@ def send_telegram_message(
|
||||
response.raise_for_status()
|
||||
|
||||
|
||||
def to_log(
|
||||
server_target: str,
|
||||
event_type: str,
|
||||
traffic_stats: dict,
|
||||
monthly_period: dict,
|
||||
):
|
||||
period_start_str = monthly_period["start"].strftime("%Y-%m-%d %H:%M:%S")
|
||||
period_reset_str = monthly_period["reset"].strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
print(f"Traffic check for server: {server_target}")
|
||||
print(f"Event: {event_type}")
|
||||
print(
|
||||
f"Traffic stats: {traffic_stats["percentage"]}%, "
|
||||
f"{traffic_stats["used"]} GB / {traffic_stats["limit"]} GB"
|
||||
)
|
||||
print(f"Monthly period: {period_start_str} -> {period_reset_str}")
|
||||
|
||||
|
||||
def main():
|
||||
config = load_config()
|
||||
|
||||
@@ -273,7 +291,9 @@ def main():
|
||||
)
|
||||
send_telegram_message(message)
|
||||
|
||||
print(f"""Server {server["target"]}: {event["event"]}""")
|
||||
to_log(
|
||||
server["target"], event["event"], traffic_stats, monthly_period
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f"""Error processing server {server["target"]}: {e}""")
|
||||
|
||||
Reference in New Issue
Block a user