fix(mcp): get_monitor says how often a monitor on the global interval runs (#5433)

check_interval_s was `m.check_interval_seconds or None`, so a monitor
following monitors.poll_interval_seconds read as null and a reader
couldn't tell how often it ran. Monitor results now carry the effective
interval and `interval_from: "monitor" | "global"`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 21:50:20 -04:00
co-authored by Claude Opus 5.5
parent ca12652277
commit 8edc0c30a3
2 changed files with 22 additions and 5 deletions
@@ -76,6 +76,9 @@ def test_monitor_rule_ack_and_maintenance_writes(app):
assert made["target"] == "https://nas.lan" and made["host_name"] == host_name
assert made["config"]["headers"] == {"Authorization": "<redacted>"}
assert made["config"]["verify_ssl"] is True
# No interval of its own: it says which it follows, and how often (#5433).
assert (made["check_interval_s"], made["interval_from"]) == (
int(app.config.get("MONITORS_POLL_INTERVAL", 60)), "global")
# ── rules ──────────────────────────────────────────────────────────
opts = await a.get_alert_rule_options("http")
@@ -100,7 +103,9 @@ def test_monitor_rule_ack_and_maintenance_writes(app):
assert renamed["carried"]["from"] == mon_name and renamed["carried"]["rules"] == 1
async with app.db_sessionmaker() as s:
assert (await s.get(AlertRule, rule["rule_id"])).resource_name == f"{mon_name}-2"
assert "carried" not in await m.update_monitor(f"{mon_name}-2", check_interval_s=30)
own = await m.update_monitor(f"{mon_name}-2", check_interval_s=30)
assert "carried" not in own
assert (own["check_interval_s"], own["interval_from"]) == (30, "monitor")
# Another http monitor may not take the same name: they would share one history.
with pytest.raises(ValueError, match="already named"):
await m.create_monitor(f"{mon_name}-2", "http", "other.lan")