fix: clear plugin data and timers on connection UP transition
Moves the plugin-state purge from the boot flag to the UP transition, so stale history and alerts are cleared on any reconnect (reboot, or recovery from overdue/unknown) not just detected reboots. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -477,11 +477,23 @@ def handle_datagram(msg: dict, addr, transport, ctx: dict):
|
|||||||
notify_mod.Notification(title=f"[INFO] {uname}", body=f"{host.name} booted", level="INFO"),
|
notify_mod.Notification(title=f"[INFO] {uname}", body=f"{host.name} booted", level="INFO"),
|
||||||
))
|
))
|
||||||
if message:
|
if message:
|
||||||
eventlog(uname, "INFO", "msg: %s" % message, service=service)
|
eventlog(uname, "INFO", message, service=service)
|
||||||
|
|
||||||
if conn.getstate() != hbdcls.Connection.UP:
|
if conn.getstate() != hbdcls.Connection.UP:
|
||||||
lasts = conn.state
|
lasts = conn.state
|
||||||
d = conn.newstate(hbdcls.Connection.UP, now)
|
d = conn.newstate(hbdcls.Connection.UP, now)
|
||||||
|
# On reboot, pre-boot plugin data and derived alerts are stale.
|
||||||
|
# Cancel all plugin timers and wipe plugin state so timers restart
|
||||||
|
# cleanly from the first two post-boot samples.
|
||||||
|
for pname in list(host.plugin_timers):
|
||||||
|
host.cancel_plugin_timer(pname)
|
||||||
|
host.plugin_data.clear()
|
||||||
|
stale_plugin_keys = [
|
||||||
|
k for k in host.alert_states
|
||||||
|
if k not in ("rtt",) and not k.startswith("connectivity.")
|
||||||
|
]
|
||||||
|
for k in stale_plugin_keys:
|
||||||
|
del host.alert_states[k]
|
||||||
# Clear connectivity alert now that the host is back up
|
# Clear connectivity alert now that the host is back up
|
||||||
_set_connectivity_alert(host, conn.afam, "OK")
|
_set_connectivity_alert(host, conn.afam, "OK")
|
||||||
# Don't log/notify RECOVER for a brand-new host seen for the first time —
|
# Don't log/notify RECOVER for a brand-new host seen for the first time —
|
||||||
|
|||||||
Reference in New Issue
Block a user