feat: add http, snmp, docker plugins; new widgets and routes for traefik/unifi/ups

- Add HTTP monitor plugin: endpoint checking with status history, latency tracking, time-range views
- Add SNMP plugin: OID polling, device management, metric recording
- Add Docker plugin: container status, resource usage, widget
- Traefik: access log widget, request chart widget, expanded routes
- UniFi: clients widget, devices widget, expanded poll routes
- UPS: history widget, additional routes
- Update plugin index with new entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 17:40:36 -04:00
parent d9886e8680
commit be4654fc72
45 changed files with 2701 additions and 1 deletions
+54
View File
@@ -301,3 +301,57 @@ async def widget():
active_alarms=active_alarms,
top_clients=top_clients,
)
@unifi_bp.get("/widget/clients")
@require_role(UserRole.viewer)
async def widget_clients():
"""HTMX dashboard widget: top active clients."""
limit = max(1, min(20, int(request.args.get("limit", 5) or 5)))
widget_id = request.args.get("wid", "0")
async with current_app.db_sessionmaker() as db:
result = await db.execute(
select(UnifiClientSnapshot)
.order_by(UnifiClientSnapshot.scraped_at.desc())
.limit(1)
)
snapshot = result.scalar_one_or_none()
clients = json.loads(snapshot.top_clients_json)[:limit] if snapshot else []
return await render_template(
"unifi/widget_clients.html",
clients=clients,
snapshot=snapshot,
widget_id=widget_id,
)
@unifi_bp.get("/widget/devices")
@require_role(UserRole.viewer)
async def widget_devices():
"""HTMX dashboard widget: infrastructure devices with optional type filter."""
type_filter = request.args.get("type_filter", "all")
widget_id = request.args.get("wid", "0")
async with current_app.db_sessionmaker() as db:
result = await db.execute(
select(UnifiDevice).order_by(UnifiDevice.state.desc(), UnifiDevice.name)
)
all_devices = result.scalars().all()
if type_filter == "wireless":
devices = [d for d in all_devices if d.device_type == "uap"]
elif type_filter == "wired":
devices = [d for d in all_devices if d.device_type != "uap"]
elif type_filter == "offline":
devices = [d for d in all_devices if d.state != 1]
else:
devices = list(all_devices)
return await render_template(
"unifi/widget_devices.html",
devices=devices,
type_filter=type_filter,
widget_id=widget_id,
)
+42
View File
@@ -0,0 +1,42 @@
{# unifi/widget_clients.html — dashboard widget: top active clients #}
{% if not snapshot %}
<div style="color:var(--text-muted);font-size:0.85rem;padding:0.5rem 0;">No client data yet.</div>
{% else %}
<div style="display:flex;gap:1rem;margin-bottom:0.75rem;flex-wrap:wrap;">
<div>
<span style="font-size:1.4rem;font-weight:700;line-height:1;">{{ snapshot.total_clients }}</span>
<span style="font-size:0.78rem;color:var(--text-muted);margin-left:0.25rem;">total</span>
</div>
<div>
<span style="font-size:1.4rem;font-weight:700;line-height:1;color:var(--accent);">{{ snapshot.wireless_clients }}</span>
<span style="font-size:0.78rem;color:var(--text-muted);margin-left:0.25rem;">wireless</span>
</div>
<div>
<span style="font-size:1.4rem;font-weight:700;line-height:1;color:var(--text-muted);">{{ snapshot.wired_clients }}</span>
<span style="font-size:0.78rem;color:var(--text-muted);margin-left:0.25rem;">wired</span>
</div>
</div>
{% if clients %}
<div style="display:grid;gap:3px;">
{% for c in clients %}
<div style="display:flex;align-items:center;gap:0.5rem;font-size:0.82rem;padding:0.15rem 0;">
<span class="dot {% if c.type == 'wireless' %}dot-up{% else %}dot-dim{% endif %}"></span>
<span style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
{{ c.hostname or c.ip or c.mac }}
</span>
{% if c.tx_rate or c.rx_rate %}
<span style="font-size:0.75rem;color:var(--text-muted);font-family:ui-monospace,monospace;flex-shrink:0;">
{% if c.tx_rate %}↑{{ "%.0f" | format(c.tx_rate / 1000) }}k{% endif %}
{% if c.rx_rate %} ↓{{ "%.0f" | format(c.rx_rate / 1000) }}k{% endif %}
</span>
{% endif %}
</div>
{% endfor %}
</div>
{% else %}
<div style="color:var(--text-muted);font-size:0.82rem;">No clients connected.</div>
{% endif %}
{% endif %}
+36
View File
@@ -0,0 +1,36 @@
{# unifi/widget_devices.html — dashboard widget: infrastructure devices #}
{% if not devices %}
<div style="color:var(--text-muted);font-size:0.85rem;padding:0.5rem 0;">
{% if type_filter != "all" %}No {{ type_filter }} devices found.{% else %}No devices found.{% endif %}
</div>
{% else %}
{% set online = devices | selectattr("state", "equalto", 1) | list %}
{% set offline = devices | rejectattr("state", "equalto", 1) | list %}
<div style="display:flex;gap:1rem;margin-bottom:0.75rem;">
<div>
<span style="font-size:1.4rem;font-weight:700;line-height:1;color:var(--green);">{{ online | length }}</span>
<span style="font-size:0.78rem;color:var(--text-muted);margin-left:0.25rem;">online</span>
</div>
{% if offline %}
<div>
<span style="font-size:1.4rem;font-weight:700;line-height:1;color:var(--red);">{{ offline | length }}</span>
<span style="font-size:0.78rem;color:var(--text-muted);margin-left:0.25rem;">offline</span>
</div>
{% endif %}
</div>
<div style="display:grid;gap:3px;">
{% for d in devices %}
<div style="display:flex;align-items:center;gap:0.5rem;font-size:0.82rem;padding:0.15rem 0;">
<span class="dot {% if d.state == 1 %}dot-up{% else %}dot-down{% endif %}"></span>
<span style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
{{ d.name or d.mac }}
</span>
<span style="font-size:0.72rem;color:var(--text-dim);flex-shrink:0;">{{ d.model or d.device_type or "" }}</span>
</div>
{% endfor %}
</div>
{% endif %}