{# Unified Hosts widget — monitor status + agent glance per host, links to the hub.
Name sits on its own line (never truncated); its data wraps beneath it, grouped
under the host. Prefer vertical growth over cramming a row. #}
{% if hosts %}
{% for host in hosts %}
{% set hs = host_status.get(host.id) %}
{% set ut = uptime.get(host.id, {}) %}
{% set a = agent.get(host.name, {}) %}
{% set down = hs and hs.state == 'down' %}
{% set spark = cpu_sparks.get(host.name) %}
{# Line 1 — status dot + full host name (own line) + cpu trend #}
{# Line 2 — monitors + agent metrics; wraps instead of truncating #}
{% if hs and hs.latency_ms is not none %}
ping {{ "%.0f"|format(hs.latency_ms) }}ms
{% endif %}
{% if ut.get('24h') is not none %}
24h {{ "%.1f"|format(ut['24h']) }}%
{% endif %}
{% if a %}
{% if a.get('cpu_pct') is not none %}cpu {{ "%.0f"|format(a.cpu_pct) }}%{% if spark %}{{ spark | safe }}{% endif %}{% endif %}
{% if a.get('mem_used_pct') is not none %}mem {{ "%.0f"|format(a.mem_used_pct) }}%{% endif %}
{% if a.get('disk_root') is not none %}disk / {{ "%.0f"|format(a.disk_root) }}%{% endif %}
{% if not a.fresh %}stale{% endif %}
{% else %}
no agent
{% endif %}