Traefik: routers are graded from their latest scrape (router_state: crit on any real 5xx share, warn on p95 past the latency critical cutoff or a high 4xx share). Failing and slow routers lead as cards that say why; healthy ones fold into one table that stays open or shut across polls. Proxy counts are stat tiles; certificates are graded by Settings -> Thresholds (tls_days). UniFi: WAN health is a stat strip (latency graded by the thresholds), devices carry status dots, event categories and firewall actions are badges, the alarm count reuses .count-badge (renamed from .nav-count). SNMP: each device wears a status badge and its readings are stat tiles. Agent fleet: the table comes first, with a Status column (Reporting / Silent / Never reported, by the host page's stale_after_seconds), silent agents first, hosts linked, last seen as |ago. Audit: entries name their entity (one query per type, steward/audit/ service.py) and link it; something deleted since keeps the name its entry recorded and says "(deleted)". Tokens: charts read colours through chart-colors.js (stewardColor resolves a token to the rgb the browser computed; Chart.js defaults take the page's text and border colours), so host, history, Traefik and SNMP charts drop their hex. Template hex colours reach 0 (HEX_CEILING = 0), the last rgba pills go, and heavy weights (600/700/bold, 60 of them) become 500, the house pair being 400/500; a guard keeps templates there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
2.7 KiB
HTML
83 lines
2.7 KiB
HTML
{# plugins/snmp/templates/snmp/device.html #}
|
|
{% extends "base.html" %}
|
|
{% from "_macros.html" import crumbs %}
|
|
{% block title %}SNMP — {{ device_name }} — Steward{% endblock %}
|
|
{% block breadcrumb %}{{ crumbs([("SNMP", "/plugins/snmp/"), (device_name, "")]) }}{% endblock %}
|
|
{% block content %}
|
|
<div style="display:flex;align-items:center;gap:1rem;margin-bottom:1.5rem;flex-wrap:wrap;">
|
|
<h1 class="page-title" style="margin:0;">{{ device_name }}</h1>
|
|
<span style="font-size:0.8rem;color:var(--text-dim);">{{ device.host }}</span>
|
|
<div style="margin-left:auto;display:flex;gap:0.5rem;">
|
|
{% for h in [1, 6, 24, 168] %}
|
|
<a href="?hours={{ h }}" class="range-btn{% if hours == h %} active{% endif %}"{% if hours == h %} aria-current="true"{% endif %}>
|
|
{% if h < 24 %}{{ h }}h{% elif h == 24 %}24h{% else %}7d{% endif %}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if oid_labels %}
|
|
<div class="card">
|
|
<canvas id="snmp-chart" style="width:100%;max-height:320px;"></canvas>
|
|
</div>
|
|
|
|
<script>
|
|
(function(){
|
|
const raw = {{ history_json | safe }};
|
|
const labels = {{ oid_labels | tojson }};
|
|
// Series colours from the tokens, in an order that keeps neighbours apart.
|
|
const palette = ["--blue", "--yellow", "--green", "--red", "--gold", "--orange", "--text-muted"].map(stewardColor);
|
|
|
|
// Collect all unique timestamps, sorted
|
|
const tsSet = new Set();
|
|
for (const pts of Object.values(raw)) {
|
|
for (const [ts] of pts) tsSet.add(ts);
|
|
}
|
|
const allTs = Array.from(tsSet).sort();
|
|
|
|
if (allTs.length < 2) {
|
|
document.getElementById("snmp-chart").parentElement.innerHTML =
|
|
'<p style="color:var(--text-muted);padding:1rem;">Not enough data for a chart yet.</p>';
|
|
return;
|
|
}
|
|
|
|
const datasets = [];
|
|
labels.forEach((label, i) => {
|
|
const pts = raw[label] || [];
|
|
const map = Object.fromEntries(pts.map(([ts, v]) => [ts, v]));
|
|
datasets.push({
|
|
label,
|
|
data: allTs.map(ts => map[ts] ?? null),
|
|
borderColor: palette[i % palette.length],
|
|
backgroundColor: "transparent",
|
|
borderWidth: 1.5,
|
|
pointRadius: 0,
|
|
tension: 0.2,
|
|
spanGaps: true,
|
|
});
|
|
});
|
|
|
|
const ctx = document.getElementById("snmp-chart").getContext("2d");
|
|
new Chart(ctx, {
|
|
type: "line",
|
|
data: { labels: allTs.map(ts => ts.substring(11, 16)), datasets },
|
|
options: {
|
|
responsive: true,
|
|
interaction: { mode: "index", intersect: false },
|
|
plugins: {
|
|
legend: { position: "top", labels: { boxWidth: 12 } },
|
|
},
|
|
scales: {
|
|
x: { ticks: { maxTicksLimit: 12 } },
|
|
},
|
|
},
|
|
});
|
|
})();
|
|
</script>
|
|
{% else %}
|
|
<div class="card" style="color:var(--text-muted);text-align:center;padding:2rem;">
|
|
No OIDs configured for this device.
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|