Compare commits
3
Commits
882d00c9b1
..
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4920d61368 | ||
|
|
53402699f4 | ||
|
|
d793cf9449 |
Vendored
+8
-1
@@ -1,5 +1,12 @@
|
||||
traffic-checker (0.1.1-1) unstable; urgency=medium
|
||||
|
||||
* Add logging function for traffic check status in stdout.
|
||||
* Defer state save until successful telegram delivery.
|
||||
|
||||
-- Vladimir Khvan <thisisnotablownfuse@gmail.com> Sun, 02 Aug 2026 02:54:53 +0300
|
||||
|
||||
traffic-checker (0.1-1) unstable; urgency=medium
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Vladimir Khvan <thisisnotablownfuse@gmail.com> Sat, 01 Aug 2026 04:00:00 +0300
|
||||
-- Vladimir Khvan <thisisnotablownfuse@gmail.com> Sat, 01 Aug 2026 04:00:00 +0300
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "traffic-checker"
|
||||
version = "0.1"
|
||||
version = "0.1.1"
|
||||
description = "Traffic consumption monitoring CLI tool for remote servers with automated alerting"
|
||||
requires-python = ">=3.11"
|
||||
authors = [
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -259,10 +277,6 @@ def main():
|
||||
state,
|
||||
)
|
||||
|
||||
state[server["uuid"]] = event["server_state"]
|
||||
|
||||
save_state(state_file_path, state)
|
||||
|
||||
if event["event"] != "none":
|
||||
message = format_message(
|
||||
event["event"],
|
||||
@@ -273,7 +287,13 @@ def main():
|
||||
)
|
||||
send_telegram_message(message)
|
||||
|
||||
print(f"""Server {server["target"]}: {event["event"]}""")
|
||||
to_log(
|
||||
server["target"], event["event"], traffic_stats, monthly_period
|
||||
)
|
||||
|
||||
state[server["uuid"]] = event["server_state"]
|
||||
|
||||
save_state(state_file_path, state)
|
||||
|
||||
except Exception as e:
|
||||
print(f"""Error processing server {server["target"]}: {e}""")
|
||||
|
||||
Reference in New Issue
Block a user