fix: восстановлена логика FAILURE_THRESHOLD

This commit is contained in:
2026-07-07 15:46:33 +07:00
parent 5c3181bb27
commit e5274805b6
+5 -2
View File
@@ -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()}"