From e5274805b656db56277499e325112800fd13f061 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9?=
Date: Tue, 7 Jul 2026 15:46:33 +0700
Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B2=D0=BE=D1=81=D1=81=D1=82=D0=B0?=
=?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3?=
=?UTF-8?q?=D0=B8=D0=BA=D0=B0=20FAILURE=5FTHRESHOLD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
monitor.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/monitor.py b/monitor.py
index 3aaa0e4..4e79e10 100644
--- a/monitor.py
+++ b/monitor.py
@@ -488,6 +488,7 @@ def main() -> None:
"comment": comment, "status": "unknown",
"rtt": None, "down_since": None,
"last_seen": None, "last_notify": None,
+ "fail_count": 0,
}
else:
hosts_state[ip]["comment"] = comment
@@ -507,6 +508,7 @@ def main() -> None:
log.info("✅ %-34s %.1f ms", label, rtt)
state["rtt"] = rtt
state["last_seen"] = now
+ state["fail_count"] = 0
if state["status"] == "down":
ds = state.get("down_since")
@@ -524,10 +526,11 @@ def main() -> None:
state["status"] = "up"
else:
- log.warning("❌ %-34s нет ответа", label)
+ state["fail_count"] = state.get("fail_count", 0) + 1
+ log.warning("❌ %-34s нет ответа (%d/%d)", label, state["fail_count"], FAILURE_THRESHOLD)
state["rtt"] = None
- if state["status"] != "down":
+ if state["fail_count"] >= FAILURE_THRESHOLD and state["status"] != "down":
state.update({"status": "down", "down_since": now, "last_notify": now})
notify(
f"{obj_prefix()}"