{% import "agent_form.html" as f with context %} {# how the agent is doing, as its computer last said: whether it runs, and for each channel whether it is up, who it is there, since when, when it last heard anything, and what last went wrong #} {% macro field(label) -%}
{{ caller() }}
{%- endmacro %} {% if health is none %}
{{ t.text("agents.no_status") }}
{% else %}
{# a computer gone offline says nothing now: its last beat is not how the agent is #} {% if selected.status == "offline" %} {% call field("agent") %}{{ t.text("agents.health.offline") }}{% endcall %} {% else %} {% call field("agent") %}{{ t.text("agents.health." ~ ("running" if health.running else ("troubled" if health.status == "started" else "stopped"))) }}{% endcall %} {% if health.status != "started" %}

{{ health.status }}

{% endif %} {% for problem in health.problems %}

{{ problem }}

{% endfor %} {% endif %}
{# what it used today, as the card by its face says #} {% if usage %}
{{ t.text("agents.health.usage") }}
{% call field("input") %}{{ usage.input }}{% endcall %} {% call field("output") %}{{ usage.output }}{% endcall %} {% call field("cached") %}{{ usage.cached }}{% endcall %} {% if usage.cost %}{% call field("cost") %}${{ usage.cost }}{% endcall %}{% endif %}
{% endif %} {% if health.channels and selected.status != "offline" %}
{{ t.text("agents.step.channels") }}
{% for channel in health.channels %}
{{ f.logo("channel", channel.kind) }} {{ f.kind_name("channel", channel.kind) }}
{% call field("link") %}{{ t.text("agents.health." ~ ("ok" if channel.ok else "down")) }}{% if not channel.ok %} {{ channel.state }}{% endif %}{% endcall %} {% if channel.identity %}{% call field("identity") %}{{ channel.identity }}{% endcall %}{% endif %} {% if channel.since_ms %}{% call field("since") %}{{ channel.since_ms|clock }}{% endcall %}{% endif %} {% if channel.last_ms %}{% call field("last") %}{{ channel.last_ms|ago }}{% endcall %}{% endif %} {% if channel.error %}{% call field("error") %}{{ channel.error }}{% endcall %}{% endif %}
{% endfor %} {% endif %}
{% endif %}