{# 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. #} {% from "_macros.html" import metric_style %} {% if hosts %}
{% for host in hosts %} {% set ping = latest_pings.get(host.id) %} {% set dns = latest_dns.get(host.id) %} {% set ut = uptime.get(host.id, {}) %} {% set a = agent.get(host.name, {}) %} {% set down = host.ping_enabled and ping and ping.status.value != 'up' %} {% set spark = cpu_sparks.get(host.name) %}
{# Line 1 — status dot + full host name (own line) + cpu trend #}
{% if session.user_id %} {{ host.name }} {% else %} {{ host.name }} {% endif %} {% if spark %}{{ spark | safe }}{% endif %}
{# Line 2 — monitors + agent metrics; wraps instead of truncating #}
{% if host.ping_enabled and ping and ping.response_time_ms is not none %} ping {{ "%.0f"|format(ping.response_time_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) }}%{% 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 %}
{% endfor %}
{% else %}
No hosts yet. Add one.
{% endif %}