Files
FabledSteward/steward/templates/hosts/list.html
T
bvandeusen f29255039d
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 9s
CI / integration (push) Successful in 2m16s
CI / publish (push) Successful in 54s
feat(hosts): Phase 2+3 — agent column, fold fleet + management into Hosts
- Hosts list: new Agent column (latest CPU/mem read from the generic
  PluginMetric table — no host_agent import) + an admin "Agent fleet" button.
- /plugins/host_agent/ (old fleet page) now redirects to /hosts/ (folded into
  the hub; kept as a redirect so widgets/links don't 404).
- Agent management moved off the "settings" URL: the management page is now
  /plugins/host_agent/fleet/ ("Agent fleet" — bulk provision/install/update +
  registrations + curl install), reachable from the Hosts list. Old
  /plugins/host_agent/settings/ redirects there. Per-host management lives on
  the host detail page; this page is now explicitly the bulk/fleet view.

Milestone 70 phases 2-3. Phase 4 (plugins capability/integration split + nav
cleanup) next.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 20:51:33 -04:00

124 lines
6.3 KiB
HTML

{% extends "base.html" %}
{% block title %}Hosts — Steward{% endblock %}
{% block content %}
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:1.5rem;">
<h1 class="page-title" style="margin-bottom:0;">Hosts</h1>
<div style="display:flex;gap:0.5rem;">
<a class="btn btn-ghost" href="/hosts/uptime">SLA</a>
{% if session.user_role == 'admin' %}
<a class="btn btn-ghost" href="/plugins/host_agent/fleet/">Agent fleet</a>
{% endif %}
<a class="btn" href="/hosts/new">Add Host</a>
</div>
</div>
{% if hosts %}
<div class="card-flush">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Probe</th>
<th style="text-align:center;">Ping</th>
<th style="text-align:center;">Latency</th>
<th style="text-align:center;">DNS</th>
<th style="text-align:center;" title="Uptime last 24 hours">24h</th>
<th style="text-align:center;" title="Uptime last 7 days">7d</th>
<th style="text-align:center;" title="Uptime last 30 days">30d</th>
<th style="text-align:center;" title="Agent CPU / memory (latest)">Agent</th>
<th></th>
</tr>
</thead>
<tbody>
{% for host in hosts %}
{% set ping = latest_pings.get(host.id) %}
{% set dns = latest_dns.get(host.id) %}
{% set ut = uptime.get(host.id, {}) %}
<tr>
<td><a href="/hosts/{{ host.id }}" style="font-weight:600;">{{ host.name }}</a></td>
<td style="color:var(--text-muted);">{{ host.address }}</td>
<td style="color:var(--text-muted);font-size:0.85rem;">
{{ host.probe_type.value | upper }}{% if host.probe_type.value == 'tcp' %}:{{ host.probe_port }}{% endif %}
</td>
<td style="text-align:center;">
{% if not host.ping_enabled %}
<span style="color:var(--text-dim);font-size:0.8rem;">off</span>
{% elif ping is none %}
<span style="color:var(--text-muted);font-size:0.8rem;"></span>
{% elif ping.status.value == 'up' %}
<span class="dot dot-up" title="Up"></span>
{% else %}
<span class="dot dot-down" title="Down"></span>
{% endif %}
</td>
<td style="text-align:center;font-size:0.9rem;">
{% if ping and ping.response_time_ms is not none %}
{% if ping.response_time_ms < 10 %}
<span style="color:var(--green);">{{ ping.response_time_ms | round(1) }} ms</span>
{% elif ping.response_time_ms < 100 %}
<span style="color:var(--yellow);">{{ ping.response_time_ms | round(1) }} ms</span>
{% else %}
<span style="color:var(--orange);">{{ ping.response_time_ms | round(1) }} ms</span>
{% endif %}
{% else %}
<span style="color:var(--text-dim);"></span>
{% endif %}
</td>
<td style="text-align:center;">
{% if not host.dns_enabled %}
<span style="color:var(--text-dim);font-size:0.8rem;">off</span>
{% elif dns is none %}
<span style="color:var(--text-muted);font-size:0.8rem;"></span>
{% elif dns.status.value == 'resolved' %}
<span class="dot dot-up" title="{{ dns.resolved_ip }}"></span>
{% else %}
<span class="dot dot-down" title="Failed"></span>
{% endif %}
</td>
{% for window in ["24h", "7d", "30d"] %}
{% set pct = ut.get(window) %}
<td style="text-align:center;font-size:0.82rem;font-family:ui-monospace,monospace;">
{% if not host.ping_enabled %}
<span style="color:var(--text-dim);"></span>
{% elif pct is none %}
<span style="color:var(--text-muted);"></span>
{% elif pct >= 99.9 %}
<span style="color:var(--green);">{{ "%.1f"|format(pct) }}%</span>
{% elif pct >= 99 %}
<span style="color:var(--yellow);">{{ "%.1f"|format(pct) }}%</span>
{% elif pct >= 95 %}
<span style="color:var(--orange);">{{ "%.1f"|format(pct) }}%</span>
{% else %}
<span style="color:var(--red);">{{ "%.1f"|format(pct) }}%</span>
{% endif %}
</td>
{% endfor %}
{% set am = agent_metrics.get(host.name) %}
<td style="text-align:center;font-size:0.8rem;font-family:ui-monospace,monospace;">
{% if am %}
<span style="color:var(--text-muted);" title="CPU / memory">
{{ '%.0f'|format(am.get('cpu_pct', 0)) }}% / {{ '%.0f'|format(am.get('mem_used_pct', 0)) }}%
</span>
{% else %}
<span style="color:var(--text-dim);"></span>
{% endif %}
</td>
<td class="td-actions">
<a href="/hosts/{{ host.id }}/edit" class="btn btn-sm btn-ghost" style="margin-right:0.5rem;">Edit</a>
<form method="post" action="/hosts/{{ host.id }}/delete" style="display:inline;">
<button type="submit" class="btn btn-sm btn-danger"
onclick="return confirm('Delete {{ host.name }}?')">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="card">
<p style="color:var(--text-muted);">No hosts yet. <a href="/hosts/new">Summon one to the table.</a></p>
</div>
{% endif %}
{% endblock %}