feat(settings): configurable monitoring thresholds
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 8s
CI / integration (push) Successful in 2m19s
CI / publish (push) Successful in 1m3s

Move the hardcoded warn/crit cutoffs into Settings -> Thresholds (DB-backed,
live, no restart). New thresholds.* keys + to_thresholds_cfg() + a
threshold_style(value, kind) jinja global that reads them; latency reuses the
existing ping good/warn keys, uptime is direction-aware (floors).

Replace the _macros metric_style/uptime_style macros (now removed) with the
global across Hosts-Overview, host_agent fleet + panel, Uptime/SLA widget, and
the ping page uptime column — all now honor the configured cutoffs. Uptime keeps
its green 'good' look when not degraded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 20:52:58 -04:00
parent eefa38cc75
commit 591706bd39
11 changed files with 187 additions and 50 deletions
+2 -5
View File
@@ -54,11 +54,8 @@
</div>
{% if uptime_pcts is defined %}
{% set pct = uptime_pcts.get(host.id) %}
<div style="min-width:4.5rem;text-align:right;font-size:0.78rem;font-variant-numeric:tabular-nums;color:
{% if pct is none %}var(--text-dim)
{% elif pct >= 99 %}var(--green)
{% elif pct >= 95 %}var(--yellow)
{% else %}var(--red){% endif %};">
{% set us = threshold_style(pct, 'uptime') if pct is not none else 'color:var(--text-dim);' %}
<div style="min-width:4.5rem;text-align:right;font-size:0.78rem;font-variant-numeric:tabular-nums;{{ us if us else 'color:var(--green);' }}">
{% if pct is not none %}{{ "%.1f"|format(pct) }}%{% else %}—{% endif %}
<span style="color:var(--text-dim);font-size:0.7rem;margin-left:0.15rem;">{{ range_key }}</span>
</div>