feat: maintenance windows, reports, uptime widget, alert improvements
- Add maintenance window scheduling to suppress alerts during planned downtime (model, routes, templates) - Add weekly email/webhook reports with host summary (core/reports.py, Settings → Reports tab) - Add host uptime history widget with per-check sparkline view - Expand alert rules: dynamic metric catalog for plugin sources, per-rule HTMX field loading, maintenance window awareness - Register additional dashboard widgets (uptime, SNMP, UniFi, UPS) - Add Settings → Reports tab configuration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import uuid
|
||||
from datetime import datetime, timezone
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import and_, or_, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from fabledscryer.models.alerts import (
|
||||
@@ -14,6 +14,7 @@ from fabledscryer.models.alerts import (
|
||||
AlertRule,
|
||||
AlertState,
|
||||
AlertStateEnum,
|
||||
MaintenanceWindow,
|
||||
)
|
||||
from fabledscryer.models.metrics import PluginMetric
|
||||
|
||||
@@ -60,6 +61,26 @@ async def record_metric(
|
||||
session.add(metric)
|
||||
await session.flush()
|
||||
|
||||
# Check active maintenance windows — skip rule evaluation if suppressed
|
||||
mw_result = await session.execute(
|
||||
select(MaintenanceWindow).where(
|
||||
MaintenanceWindow.start_at <= now,
|
||||
MaintenanceWindow.end_at >= now,
|
||||
or_(
|
||||
MaintenanceWindow.scope_source.is_(None),
|
||||
and_(
|
||||
MaintenanceWindow.scope_source == source_module,
|
||||
or_(
|
||||
MaintenanceWindow.scope_resource.is_(None),
|
||||
MaintenanceWindow.scope_resource == resource_name,
|
||||
),
|
||||
),
|
||||
),
|
||||
).limit(1)
|
||||
)
|
||||
if mw_result.scalar_one_or_none() is not None:
|
||||
return # suppressed by maintenance window
|
||||
|
||||
# Load matching enabled rules
|
||||
result = await session.execute(
|
||||
select(AlertRule).where(
|
||||
|
||||
Reference in New Issue
Block a user