{# HTMX fragment — included in both /ping/ page and dashboard widget #} {% macro pill_bg(p) %} {%- if p is none or p.status.value == 'down' or p.response_time_ms is none -%} #6a1515 {%- elif p.response_time_ms <= good_ms -%} #1a6632 {%- elif p.response_time_ms <= warn_ms -%} #6b5c00 {%- else -%} #7a3800 {%- endif -%} {% endmacro %} {% macro pill_title(p) %} {%- if p is none -%}No data {%- elif p.status.value == 'down' -%}Down — {{ p.probed_at.strftime('%H:%M:%S') }} UTC {%- else -%}{{ "%.1f"|format(p.response_time_ms) }} ms — {{ p.probed_at.strftime('%H:%M:%S') }} UTC {%- endif -%} {% endmacro %} {% if hosts %} {% for host in hosts %} {% set host_pings = pings_by_host.get(host.id, []) %} {% set last = host_pings[-1] if host_pings else none %}
{{ host.name }} {{ host.address }}
{% for _ in range([30 - host_pings|length, 0]|max) %} {% endfor %} {% for p in host_pings %} {% endfor %}
{% if last is none %} {% elif last.status.value == 'down' or last.response_time_ms is none %} DOWN {% elif last.response_time_ms <= good_ms %} {{ "%.1f"|format(last.response_time_ms) }} ms {% elif last.response_time_ms <= warn_ms %} {{ "%.1f"|format(last.response_time_ms) }} ms {% else %} {{ "%.1f"|format(last.response_time_ms) }} ms {% endif %}
{% if uptime_pcts is defined %} {% set pct = uptime_pcts.get(host.id) %}
{% if pct is not none %}{{ "%.1f"|format(pct) }}%{% else %}—{% endif %} {{ range_key }}
{% endif %}
{% endfor %} {% else %}

No ping-enabled hosts. Add hosts →

{% endif %}