nas-burnin/claude-sandbox/truenas-burnin/app/templates/stats.html
echoparkbaby 3e0000528f TrueNAS Burn-In Dashboard v0.9.0 — Live mode, thermal monitoring, adaptive concurrency
Go live against real TrueNAS SCALE 25.10:
- Remove mock-truenas dependency; mount SSH key as Docker secret
- Filter expired disk records from /api/v2.0/disk (expiretime field)
- Route all SMART operations through SSH (SCALE 25.10 removed REST smart/test endpoint)
- Poll drive temperatures via POST /api/v2.0/disk/temperatures (SCALE-specific)
- Store raw smartctl output in smart_tests.raw_output for proof of test execution
- Fix percent-remaining=0 false jump to 100% on test start
- Fix terminal WebSocket: add mounted key file fallback (/run/secrets/ssh_key)
- Fix WebSocket support: uvicorn → uvicorn[standard] (installs websockets)

HBA/system sensor temps on dashboard:
- SSH to TrueNAS and run sensors -j each poll cycle
- Parse coretemp (CPU package) and pch_* (PCH/chipset — storage I/O proxy)
- Render as compact chips in stats bar, color-coded green/yellow/red
- Live updates via new SSE system-sensors event every 12s

Adaptive concurrency signal:
- Thermal pressure indicator in stats bar: hidden when OK, WARM/HOT when running
  burn-in drives hit temp_warn_c / temp_crit_c thresholds
- Thermal gate in burn-in queue: jobs wait up to 3 min before acquiring semaphore
  slot if running drives are already at warning temp; times out and proceeds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 06:33:36 -05:00

183 lines
6.3 KiB
HTML

{% extends "layout.html" %}
{% block title %}TrueNAS Burn-In — Stats{% endblock %}
{% block content %}
<div class="page-toolbar">
<h1 class="page-title">Analytics</h1>
<div class="toolbar-right">
<span class="page-subtitle">{{ drives_total }} drives tracked</span>
</div>
</div>
<!-- Overall stat cards -->
<div class="stats-row" style="margin-bottom:24px">
<div class="overview-card">
<span class="ov-value">{{ overall.total or 0 }}</span>
<span class="ov-label">Total Jobs</span>
</div>
<div class="overview-card ov-green">
<span class="ov-value">{{ overall.passed or 0 }}</span>
<span class="ov-label">Passed</span>
</div>
<div class="overview-card ov-red">
<span class="ov-value">{{ overall.failed or 0 }}</span>
<span class="ov-label">Failed</span>
</div>
<div class="overview-card ov-blue">
<span class="ov-value">{{ overall.running or 0 }}</span>
<span class="ov-label">Running</span>
</div>
<div class="overview-card ov-gray">
<span class="ov-value">{{ overall.cancelled or 0 }}</span>
<span class="ov-label">Cancelled</span>
</div>
{% if overall.total and overall.total > 0 %}
<div class="overview-card ov-green">
<span class="ov-value">{{ "%.0f" | format(100 * (overall.passed or 0) / overall.total) }}%</span>
<span class="ov-label">Pass Rate</span>
</div>
{% endif %}
</div>
<div class="stats-grid">
<!-- Failure rate by model -->
<div class="stats-section">
<h2 class="section-title">Results by Drive Model</h2>
{% if by_model %}
<div class="table-wrap" style="max-height:none">
<table>
<thead>
<tr>
<th>Model</th>
<th style="text-align:right">Total</th>
<th style="text-align:right">Passed</th>
<th style="text-align:right">Failed</th>
<th style="text-align:right">Pass Rate</th>
<th style="min-width:120px">Rate Bar</th>
</tr>
</thead>
<tbody>
{% for m in by_model %}
<tr>
<td style="font-weight:500;color:var(--text-strong)">{{ m.model }}</td>
<td class="mono text-muted" style="text-align:right">{{ m.total }}</td>
<td class="mono" style="text-align:right;color:var(--green)">{{ m.passed }}</td>
<td class="mono" style="text-align:right;color:{% if m.failed > 0 %}var(--red){% else %}var(--text-muted){% endif %}">{{ m.failed }}</td>
<td class="mono" style="text-align:right;font-weight:600;color:{% if (m.pass_rate or 0) >= 90 %}var(--green){% elif (m.pass_rate or 0) >= 70 %}var(--yellow){% else %}var(--red){% endif %}">
{{ m.pass_rate or 0 }}%
</td>
<td>
<div class="rate-bar-wrap">
<div class="rate-bar-fill rate-pass" style="width:{{ m.pass_rate or 0 }}%"></div>
<div class="rate-bar-fill rate-fail" style="width:{{ 100 - (m.pass_rate or 0) }}%"></div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state" style="border:1px solid var(--border);border-radius:8px;padding:32px">
No completed burn-in jobs yet.
</div>
{% endif %}
</div>
<!-- Activity last 14 days -->
<div class="stats-section">
<h2 class="section-title">Activity — Last 14 Days</h2>
{% if by_day %}
<div class="table-wrap" style="max-height:none">
<table>
<thead>
<tr>
<th>Date</th>
<th style="text-align:right">Total</th>
<th style="text-align:right">Passed</th>
<th style="text-align:right">Failed</th>
</tr>
</thead>
<tbody>
{% for d in by_day %}
<tr>
<td class="mono text-muted">{{ d.day }}</td>
<td class="mono" style="text-align:right;color:var(--text-strong)">{{ d.total }}</td>
<td class="mono" style="text-align:right;color:var(--green)">{{ d.passed }}</td>
<td class="mono" style="text-align:right;color:{% if d.failed > 0 %}var(--red){% else %}var(--text-muted){% endif %}">{{ d.failed }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state" style="border:1px solid var(--border);border-radius:8px;padding:32px">
No activity in the last 14 days.
</div>
{% endif %}
</div>
</div>
<div class="stats-grid" style="margin-top:24px">
<!-- Average duration by drive size -->
<div class="stats-section">
<h2 class="section-title">Avg. Test Duration by Drive Size</h2>
{% if by_size %}
<div class="table-wrap" style="max-height:none">
<table>
<thead>
<tr>
<th>Size</th>
<th style="text-align:right">Jobs</th>
<th style="text-align:right">Avg Duration</th>
</tr>
</thead>
<tbody>
{% for s in by_size %}
<tr>
<td style="font-weight:500;color:var(--text-strong)">{{ s.size_tb }} TB</td>
<td class="mono text-muted" style="text-align:right">{{ s.total }}</td>
<td class="mono" style="text-align:right;color:var(--text-strong)">{{ s.avg_hours }}h</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state" style="border:1px solid var(--border);border-radius:8px;padding:32px">No completed jobs yet.</div>
{% endif %}
</div>
<!-- Failure breakdown by stage -->
<div class="stats-section">
<h2 class="section-title">Failures by Stage</h2>
{% if by_failure_stage %}
<div class="table-wrap" style="max-height:none">
<table>
<thead>
<tr>
<th>Stage</th>
<th style="text-align:right">Count</th>
</tr>
</thead>
<tbody>
{% for f in by_failure_stage %}
<tr>
<td style="font-weight:500;color:var(--red)">{{ f.failed_stage | replace('_',' ') | title }}</td>
<td class="mono" style="text-align:right;color:var(--red)">{{ f.count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state" style="border:1px solid var(--border);border-radius:8px;padding:32px">No failures recorded.</div>
{% endif %}
</div>
</div>
{% endblock %}