From e7b96fbfa76a6f5d0d6f4a35450c121762216168 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 17 Jun 2026 20:43:33 -0400 Subject: [PATCH] feat(host_agent): surface network, disk I/O, and temperature in fleet widget The agent already collects + ingests net throughput, disk I/O, and temps; add them to the fleet-glance rows (fmt_bps + two-line io cells + temp with 70/85C threshold color), each shown only when the host reports it so VMs/ containers without sensors don't show blank cells. Co-Authored-By: Claude Opus 4.8 (1M context) --- plugins/host_agent/routes.py | 2 ++ .../host_agent/templates/widget_table.html | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/plugins/host_agent/routes.py b/plugins/host_agent/routes.py index 644dbee..d8c66b1 100644 --- a/plugins/host_agent/routes.py +++ b/plugins/host_agent/routes.py @@ -409,6 +409,8 @@ async def _fleet_rows(session) -> list[dict]: "temp_max": m.get("temp_c_max"), "net_rx_bps": m.get("net_rx_bps"), "net_tx_bps": m.get("net_tx_bps"), + "disk_read_bps": m.get("disk_read_bps"), + "disk_write_bps": m.get("disk_write_bps"), "sparks": sparks, }) rows.sort(key=lambda r: r["host"].name.lower()) diff --git a/plugins/host_agent/templates/widget_table.html b/plugins/host_agent/templates/widget_table.html index 30fac53..d543b8d 100644 --- a/plugins/host_agent/templates/widget_table.html +++ b/plugins/host_agent/templates/widget_table.html @@ -14,6 +14,24 @@
{{ svg | safe }}
{% endmacro %} +{# Human-readable throughput, matching the host-detail page. #} +{% macro fmt_bps(v) %} +{%- if v is none -%}— +{%- elif v >= 1048576 -%}{{ "%.1f"|format(v / 1048576) }} MB/s +{%- elif v >= 1024 -%}{{ "%.1f"|format(v / 1024) }} KB/s +{%- else -%}{{ "%.0f"|format(v) }} B/s +{%- endif -%} +{% endmacro %} +{# Two-line down/up (or read/write) throughput cell. #} +{% macro io_cell(label, down_sym, down_val, up_sym, up_val, title="") %} +
+
{{ label }}
+
+
{{ down_sym }} {{ fmt_bps(down_val) }}
+
{{ up_sym }} {{ fmt_bps(up_val) }}
+
+
+{% endmacro %}
{% for r in rows %} {% set stale = r.stale %} @@ -40,6 +58,17 @@ {{ metric_cell("mem", r.mem_used_pct, "%.0f%%", r.sparks.mem, metric_style(r.mem_used_pct), "Memory in use") }} {{ metric_cell("disk /", r.disk_root, "%.0f%%", r.sparks.disk, metric_style(r.disk_root), "Root filesystem (/) usage") }} {{ metric_cell("load", r.load_1m, "%.2f", r.sparks.load, "", "Load average (1m)") }} + {# Extra agent metrics — shown only when the host reports them (VMs/containers + often have no temp sensor, etc.) so absent data doesn't clutter the row. #} + {% if r.net_rx_bps is not none or r.net_tx_bps is not none %} + {{ io_cell("net", "↓", r.net_rx_bps, "↑", r.net_tx_bps, "Network throughput (down / up)") }} + {% endif %} + {% if r.disk_read_bps is not none or r.disk_write_bps is not none %} + {{ io_cell("disk i/o", "rd", r.disk_read_bps, "wr", r.disk_write_bps, "Disk I/O (read / write)") }} + {% endif %} + {% if r.temp_max is not none %} + {{ metric_cell("temp", r.temp_max, "%.0f°C", "", metric_style(r.temp_max, warn=70, crit=85), "Hottest sensor") }} + {% endif %}
{% endfor %}