Ansible schedule form: structured playbook-variable fields + first-item dropdown defaults #2
@@ -1,6 +1,6 @@
|
||||
{# docker/widget.html — dashboard widget: container status overview #}
|
||||
{% if not containers and running_count == 0 and stopped_count == 0 %}
|
||||
<div style="color:var(--text-muted);font-size:0.85rem;padding:0.5rem 0;">No containers found.</div>
|
||||
<p class="empty" style="padding:0.5rem 0;font-size:0.85rem;">No containers found.</p>
|
||||
{% else %}
|
||||
|
||||
<div style="display:flex;gap:1rem;margin-bottom:0.65rem;">
|
||||
|
||||
@@ -398,16 +398,21 @@ async def widget_history():
|
||||
points = (await session.execute(
|
||||
select(PluginMetric).where(
|
||||
PluginMetric.source_module == SOURCE_MODULE,
|
||||
PluginMetric.resource_name == host.name,
|
||||
PluginMetric.metric_name.in_(
|
||||
("cpu_pct", "mem_used_pct", "disk_used_pct_worst")),
|
||||
PluginMetric.recorded_at >= cutoff,
|
||||
or_(
|
||||
and_(PluginMetric.resource_name == host.name,
|
||||
PluginMetric.metric_name.in_(("cpu_pct", "mem_used_pct"))),
|
||||
and_(PluginMetric.resource_name == host.name + ":/",
|
||||
PluginMetric.metric_name == "disk_used_pct"),
|
||||
),
|
||||
).order_by(PluginMetric.recorded_at)
|
||||
)).scalars().all()
|
||||
|
||||
series: dict[str, list[dict]] = {"cpu_pct": [], "mem_used_pct": [], "disk_used_pct_worst": []}
|
||||
# Disk = root (/), consistent with the host panel — not the opaque "worst".
|
||||
series: dict[str, list[dict]] = {"cpu_pct": [], "mem_used_pct": [], "disk_root": []}
|
||||
for p in points:
|
||||
series[p.metric_name].append({"t": p.recorded_at.isoformat(), "v": p.value})
|
||||
key = "disk_root" if p.resource_name != host.name else p.metric_name
|
||||
series[key].append({"t": p.recorded_at.isoformat(), "v": p.value})
|
||||
|
||||
return await render_template("widget_history.html", host=host, series=series, hours=hours)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
type: "line",
|
||||
data: {
|
||||
datasets: [
|
||||
{ label: "CPU %", data: series.cpu_pct.map(p => ({x: p.t, y: p.v})) },
|
||||
{ label: "Mem %", data: series.mem_used_pct.map(p => ({x: p.t, y: p.v})) },
|
||||
{ label: "Disk % worst", data: series.disk_used_pct_worst.map(p => ({x: p.t, y: p.v})) },
|
||||
{ label: "CPU %", data: series.cpu_pct.map(p => ({x: p.t, y: p.v})) },
|
||||
{ label: "Mem %", data: series.mem_used_pct.map(p => ({x: p.t, y: p.v})) },
|
||||
{ label: "Disk / %", data: series.disk_root.map(p => ({x: p.t, y: p.v})) },
|
||||
],
|
||||
},
|
||||
options: {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
{% for r in rows %}
|
||||
{% set stale = r.stale %}
|
||||
<div style="display:flex;align-items:center;gap:0.6rem;font-size:0.82rem;padding:0.3rem 0;border-bottom:1px solid var(--border);">
|
||||
<span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}"></span>
|
||||
<span class="dot {% if stale %}dot-dim{% elif (r.cpu_pct or 0) >= 90 or (r.mem_used_pct or 0) >= 90 or (r.disk_worst or 0) >= 90 %}dot-warn{% else %}dot-up{% endif %}"
|
||||
title="{% if stale %}stale / no recent data{% else %}warns at CPU/memory ≥90% or any disk mount ≥90% (the 'disk /' figure shows root only){% endif %}"></span>
|
||||
<a href="/hosts/{{ r.host.id }}"
|
||||
style="flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500;">
|
||||
{{ r.host.name }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# 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>
|
||||
<p class="empty" style="padding:0.5rem 0;font-size:0.85rem;">No client data yet.</p>
|
||||
{% else %}
|
||||
|
||||
<div style="display:flex;gap:1rem;margin-bottom:0.75rem;flex-wrap:wrap;">
|
||||
|
||||
@@ -462,9 +462,16 @@ async def start_run(
|
||||
|
||||
except _Aborted:
|
||||
final_status = "cancelled"
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.exception("Ansible run %s failed with exception", run_id)
|
||||
final_status = "cancelled" if run_id in _cancelled else "failed"
|
||||
# Surface WHY in the run output instead of an empty "failed" (e.g. ENOSPC
|
||||
# when the temp dir can't be created — the run never reaches Ansible).
|
||||
msg = f"[run error] {type(exc).__name__}: {exc}"
|
||||
_broadcast(run_id, msg)
|
||||
if len(failures) < _FAILURE_CAP:
|
||||
failures.append(msg[:500])
|
||||
db_output = (db_output + "\n" + msg) if db_output else msg
|
||||
finally:
|
||||
if logf is not None:
|
||||
logf.close()
|
||||
|
||||
@@ -27,7 +27,7 @@ WIDGET_REGISTRY: dict[str, dict] = {
|
||||
"label": "Status — Overview",
|
||||
"description": "Unified up/down/pending summary across ping, DNS, and HTTP monitors",
|
||||
"hx_url": "/status/widget",
|
||||
"detail_url": "/status",
|
||||
"detail_url": "/status/",
|
||||
"plugin": None,
|
||||
"poll": True,
|
||||
"params": [],
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
{% set problems = entries | rejectattr("status", "equalto", "up") | list %}
|
||||
{% if not entries %}
|
||||
<div style="color:var(--text-muted);font-size:0.85rem;padding:0.3rem 0;">No monitors configured.</div>
|
||||
<p class="empty" style="padding:0.3rem 0;font-size:0.85rem;">No monitors configured.</p>
|
||||
{% elif not problems %}
|
||||
<div style="color:var(--green);font-size:0.85rem;padding:0.3rem 0;">✓ All {{ up }} monitors are up.</div>
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user