fix: восстановлена логика FAILURE_THRESHOLD
This commit is contained in:
+5
-2
@@ -488,6 +488,7 @@ def main() -> None:
|
|||||||
"comment": comment, "status": "unknown",
|
"comment": comment, "status": "unknown",
|
||||||
"rtt": None, "down_since": None,
|
"rtt": None, "down_since": None,
|
||||||
"last_seen": None, "last_notify": None,
|
"last_seen": None, "last_notify": None,
|
||||||
|
"fail_count": 0,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
hosts_state[ip]["comment"] = comment
|
hosts_state[ip]["comment"] = comment
|
||||||
@@ -507,6 +508,7 @@ def main() -> None:
|
|||||||
log.info("✅ %-34s %.1f ms", label, rtt)
|
log.info("✅ %-34s %.1f ms", label, rtt)
|
||||||
state["rtt"] = rtt
|
state["rtt"] = rtt
|
||||||
state["last_seen"] = now
|
state["last_seen"] = now
|
||||||
|
state["fail_count"] = 0
|
||||||
|
|
||||||
if state["status"] == "down":
|
if state["status"] == "down":
|
||||||
ds = state.get("down_since")
|
ds = state.get("down_since")
|
||||||
@@ -524,10 +526,11 @@ def main() -> None:
|
|||||||
state["status"] = "up"
|
state["status"] = "up"
|
||||||
|
|
||||||
else:
|
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
|
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})
|
state.update({"status": "down", "down_since": now, "last_notify": now})
|
||||||
notify(
|
notify(
|
||||||
f"{obj_prefix()}"
|
f"{obj_prefix()}"
|
||||||
|
|||||||
Reference in New Issue
Block a user