{# plugins/snmp/templates/snmp/index.html — every SNMP device, those not answering first, each saying what its newest poll found: its readings in their units, or why it didn't answer (milestone 491). #} {% extends "base.html" %} {% from "_macros.html" import page_header, status_badge, stat_tile, empty_state %} {% block title %}SNMP — Steward{% endblock %} {% block content %} {% set admin = session.user_role == 'admin' %} {% call page_header("SNMP devices", (devices|length ~ " device" ~ ("s" if devices|length != 1 else "")) if devices else none) %} {% if admin %}Add device{% endif %} {% endcall %} {% if not devices %}
{{ empty_state("No SNMP devices yet. Add a switch, a UPS, a printer or a server that answers SNMP, and Steward polls it every minute.", "Add device" if admin else none, "/plugins/snmp/devices/new") }}
{% endif %} {% for d in devices %}
{% if d.reach == 'up' %}{{ status_badge('up', 'Answering') }} {% elif d.reach == 'down' %}{{ status_badge('down', 'Not answering') }} {% elif d.reach == 'stale' %}{{ status_badge('stale', 'Not polled') }} {% else %}{{ status_badge('pending', 'Not polled yet') }}{% endif %}

{{ d.name }}

{{ d.address }}{% if d.port != 161 %}:{{ d.port }}{% endif %} SNMP v{{ d.version }} History {% if admin %}Edit{% endif %}
{% if d.reach == 'down' %}

{{ d.says }}

{%- if d.ok_at %}Last answered {{ d.ok_at|ago }}; the readings below are from then.{% else %}It has never answered.{% endif %} Tried {{ d.polled_at|ago }}.

{% elif d.reach == 'stale' %}

{{ d.says }} Last polled {{ d.polled_at|ago }}.

{% elif d.reach == 'pending' %}

Not polled yet: the first poll runs within a minute of saving.

{% endif %} {% if d.reach != 'pending' and d.readings %}
{% for r in d.readings %}{{ stat_tile(r.name, r.text, hint="from the second poll" if r.counter and r.text == "—" else none) }}{% endfor %}
{% endif %} {% if d.missing %}

Not answered by this device: {{ d.missing|join(", ") }}. It may not support them; Edit to remove them.

{% endif %}
{% endfor %} {% endblock %}