From 32daa5547f01d252a70150d3f1adae5229df51bf Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Wed, 14 Oct 2026 18:51:39 +0200 Subject: [PATCH] Prepare per-SSD dashboard throughput IOPS and busy-time telemetry --- collect_hardware.py | 52 ++++++++++++++++++- dashboard-ui.js | 4 ++ docs/TEST_INDEX.md | 1 + .../ssd-dashboard-2026-10-14/README.md | 41 +++++++++++++++ .../ssd-dashboard-2026-10-14/results.json | 13 +++++ .../README.md | 4 ++ test_disk_io.py | 33 ++++++++++++ 7 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 docs/experiments/ssd-dashboard-2026-10-14/README.md create mode 100644 docs/experiments/ssd-dashboard-2026-10-14/results.json create mode 100644 test_disk_io.py diff --git a/collect_hardware.py b/collect_hardware.py index c9137a9..9af2fbf 100644 --- a/collect_hardware.py +++ b/collect_hardware.py @@ -5,11 +5,58 @@ import time import subprocess import os import shutil +import re from pathlib import Path PROC = Path(os.environ.get('DECK_HOST_PROC', '/proc')) DATA_DISK = Path(os.environ.get('DECK_HOST_DATA_DISK', '/var/lib/deck')) _network_previous = None +SYS = Path(os.environ.get('DECK_HOST_SYS', '/sys')) +_disk_previous = None + + +def disk_sample(): + """Whole physical SSDs only: no partition/mapper double counting.""" + devices = {} + for line in read(PROC/'diskstats').splitlines(): + parts = line.split() + if len(parts) < 14: + continue + name = parts[2] + if not re.fullmatch(r'(?:nvme\d+n\d+|sd[a-z]+)', name): + continue + device = SYS/'class/block'/name + if (device/'partition').exists() or read(device/'queue/rotational') != '0': + continue + try: + stats = [int(x) for x in parts[3:14]] + if any(x < 0 for x in stats): + continue + except ValueError: + continue + devices[name] = dict(name=name, model=read(device/'device/model')[:128] or name, + counters=[stats[0], stats[2], stats[4], stats[6], stats[9]], + in_flight=stats[8]) + return devices + + +def disk_rates(current, previous, now): + rows = [] + elapsed = now-previous[0] if previous else 0 + for name, device in sorted(current.items()): + row = {k: device[k] for k in ('name', 'model', 'in_flight')} + row.update(read_bytes_per_second=None, write_bytes_per_second=None, + read_iops=None, write_iops=None, busy_percent=None) + old = previous[1].get(name) if previous else None + if elapsed > 0 and old: + delta = [a-b for a,b in zip(device['counters'], old['counters'])] + if all(x >= 0 for x in delta): + row.update(read_bytes_per_second=round(delta[1]*512/elapsed, 1), + write_bytes_per_second=round(delta[3]*512/elapsed, 1), + read_iops=round(delta[0]/elapsed, 1), write_iops=round(delta[2]/elapsed, 1), + busy_percent=round(min(100, delta[4]/(elapsed*10)), 1)) + rows.append(row) + return rows def read(path): @@ -32,7 +79,7 @@ def ticks(): def collect(): - global _network_previous + global _network_previous, _disk_previous errors = [] cpu = {'name': None, 'percent': None, 'temperature_c': None} try: @@ -81,6 +128,9 @@ def collect(): disk=shutil.disk_usage(DATA_DISK) disk_data=dict(total=disk.total,used=disk.used,free=disk.free) except OSError:disk_data={} + disk_now=time.monotonic();disk_current=disk_sample() + disk_data['io']=disk_rates(disk_current, _disk_previous, disk_now) + _disk_previous=(disk_now, disk_current) rx=tx=interfaces=0 # A bind-mounted /proc/net is a self/net symlink and would show the # container namespace. PID 1 in the host proc mount has the host network. diff --git a/dashboard-ui.js b/dashboard-ui.js index 24e452b..bfd8046 100644 --- a/dashboard-ui.js +++ b/dashboard-ui.js @@ -26,6 +26,7 @@ root.innerHTML=`
Modell
–
–
CPU
–
–
System-RAM
–
–
+
SSD · Lesen und Schreiben
Messung wird geladen …
Host-I/O · Aktivzeit ist keine Prozentangabe der maximalen SSD-Geschwindigkeit.
Inferenz · Live
Generierung
–
Token pro Sekunde
@@ -218,6 +219,9 @@ async function refreshSummary(){ $('activeChats').textContent=q.active_chats??'–';$('routerUptime').textContent=dur(rt.uptime_seconds); $('switching').textContent=rt.switching||'nein'; const disk=c.disk_data||{};$('dataDisk').textContent=pct(disk.total?100*disk.used/disk.total:null); + const ioRate=n=>n==null?'–':`${(Number(n)/1048576).toLocaleString('de-DE',{maximumFractionDigits:1})} MiB/s`; + const iops=n=>n==null?'–':Number(n).toLocaleString('de-DE',{maximumFractionDigits:1}); + $('ssdIO').innerHTML=(disk.io||[]).map(s=>`
${esc(s.model)} · ${esc(s.name)}Lesen ${esc(ioRate(s.read_bytes_per_second))} · Schreiben ${esc(ioRate(s.write_bytes_per_second))}IOPS L/S: ${esc(iops(s.read_iops))} / ${esc(iops(s.write_iops))} · Aktivzeit ${esc(pct(s.busy_percent))} · laufende I/Os ${esc(s.in_flight)}
`).join('')||'
Keine SSD-I/O-Messwerte verfügbar.
'; $('processes').innerHTML=(d.gpu_processes||[]).map(p=>`${esc((d.gpus||[]).find(g=>g.uuid===p.gpu_uuid)?.index)}${esc(p.name)}${esc(p.pid)}${esc(p.memory_mib)} MiB`).join('')||'Keine Compute-Prozesse gemeldet'; const runtime=[['Modell-Datei',lr.model_file],['PID',lr.pid],['Kontext',lr.context_size?Number(lr.context_size).toLocaleString('de-DE'):'–'],['Batch / µBatch',`${lr.batch_size??'–'} / ${lr.ubatch_size??'–'}`],['Parallel',lr.parallel],['Threads',`${lr.threads??'–'} / ${lr.threads_batch??'–'}`],['Geräte',lr.device],['Tensor-Split',lr.tensor_split],['KV-Cache',`${lr.cache_k??'–'} / ${lr.cache_v??'–'}`],['Flash Attention',lr.flash_attention==null?'–':lr.flash_attention?'an':'aus'],['Prompt-Cache',lr.prompt_cache==null?'–':lr.prompt_cache?'an':'aus'],['MTP Draft',lr.mtp_draft_tokens]]; $('runtime').innerHTML=runtime.map(([k,v])=>metric(v,k)).join(''); diff --git a/docs/TEST_INDEX.md b/docs/TEST_INDEX.md index 4b9c852..0bc1c67 100644 --- a/docs/TEST_INDEX.md +++ b/docs/TEST_INDEX.md @@ -59,3 +59,4 @@ Vorherige Backupprüfung: [Befund und Grenzen](maintenance/2026-10-14-documentat | [WireGuard DHCP startup race — 2026-10-13](experiments/wireguard-boot-fix-2026-10-13/README.md) | 1 | | [WireGuard configuration replacement verification](experiments/wireguard-config-replacement-2026-10-13/README.md) | 1 | +Neu ergänzt: [SSD-I/O-Dashboard, vorbereitet und live vermessen](experiments/ssd-dashboard-2026-10-14/README.md). diff --git a/docs/experiments/ssd-dashboard-2026-10-14/README.md b/docs/experiments/ssd-dashboard-2026-10-14/README.md new file mode 100644 index 0000000..af353a7 --- /dev/null +++ b/docs/experiments/ssd-dashboard-2026-10-14/README.md @@ -0,0 +1,41 @@ +# SSD-I/O im Dashboard — 14. Oktober 2026 + +Vorbereitetes App-Update, noch nicht aktiviert. Image: +`athena-deck-standalone:ssd-io-20261014`, Basis +`athena-deck-standalone:strata-0.1.44.1-20261014`. Der separate Build kopiert +collect_hardware.py, dashboard-ui.js und die bereits geprüfte Backupkorrektur. +Aktivierung benötigt einen regulären Deck-Neustart; laufende Coding-Aufgaben +werden nicht unterbrochen. Freigabe offen. Keine Profil-/Token-/Mountänderung. + +Die neue Karte unter CPU/System-RAM und vor GPUs zeigt je ganzer physischer SSD: +Gerätename/Modell, Lesen/Schreiben in MiB/s, Lese-/Schreib-IOPS, Aktivzeit und +aktuell laufende I/Os. Linux /proc/diskstats-Deltas, 512 Bytes pro gezähltem +Sektor; /sys liefert nur Modellname und Rotationskennzeichen. Keine Seriennummern, +SMART-Zugangsdaten oder Dateiinhalte. Keine neuen Pakete, Schreibtests oder Benchmarks. +Partitionen, Mapper und rotierende Laufwerke ausgeschlossen, damit keine +Doppelzählung entsteht. Null-/Reset-/Neu-Geräte-Messungen werden als unbekannt +statt als erfundene Nullraten angezeigt. Aktivzeit ist keine Prozentangabe der +maximal erreichbaren SSD-Bandbreite; NVMe-Parallelität begrenzt ihre Aussagekraft. +Alle Hostprozesse zählen, nicht nur Strata. Keine getrennte Disk-Historie ergänzt. + +Im derzeitigen lokalen Hardwarecollector wird der letzte Messstand im Prozess +gehalten. Bei einem jedes Mal neu gestarteten SSH-Collector ist zunächst kein +vorheriger Stand verfügbar; Raten bleiben dann unbekannt. Native Standardbetrieb +und Athenas lokale Messung nutzen den fortlaufenden Collector. + +Zehn Tests bestanden: test_disk_io, test_dashboard_data, test_dashboard_history. +JavaScript-Syntaxprüfung bestanden. Isolierte echte Probe im laufenden Container: +Samsung SSD 980 PRO 1TB/nvme0n1 etwa 262799284 B/s Lesen, 3636.7 Lese-IOPS, +15.0 Prozent Aktivzeit; WD Blue SN580 1TB/nvme1n1 etwa 238624332 B/s Lesen, +1820.6 Lese-IOPS, 15.6 Prozent Aktivzeit. Momentaufnahme während Backupprüfung, +kein SSD-Leistungsbenchmark. Kein Deck-Prozess dabei verändert. + +Daten gehen über das bestehende cpu.disk_data-Objekt in /api/v1/dashboard; +keine neuen API-Berechtigungen oder Endpunkte. Der normale Installer führt +collect_hardware.py/dashboard-ui.js/backup.py bereits explizit im App-Rezept. +Native Debian-Installation benötigt lesbare procfs/sysfs. Beim heutigen +Containerbetrieb /host/proc readonly und sichtbare Host-Sysfs-Geräte erhalten. +Restore aus aktuellem Git stellt die Anzeige wieder bereit; weder Messstände +noch laufende I/Os sind dauerhafter Sicherungszustand. Frischer Restore offen. + +Quelle: https://docs.kernel.org/admin-guide/iostats.html diff --git a/docs/experiments/ssd-dashboard-2026-10-14/results.json b/docs/experiments/ssd-dashboard-2026-10-14/results.json new file mode 100644 index 0000000..1e641e9 --- /dev/null +++ b/docs/experiments/ssd-dashboard-2026-10-14/results.json @@ -0,0 +1,13 @@ +{ + "tests": 10, + "tests_passed": true, + "javascript_syntax": "passed", + "image": "athena-deck-standalone:ssd-io-20261014", + "activated": false, + "restart_authorization": "pending", + "devices": [ + "Samsung SSD 980 PRO 1TB", + "WD Blue SN580 1TB" + ], + "live_probe": true +} diff --git a/docs/maintenance/2026-10-14-documentation-restore-audit/README.md b/docs/maintenance/2026-10-14-documentation-restore-audit/README.md index bb37d82..9faef85 100644 --- a/docs/maintenance/2026-10-14-documentation-restore-audit/README.md +++ b/docs/maintenance/2026-10-14-documentation-restore-audit/README.md @@ -1,5 +1,9 @@ # Dokumentationsabgleich und Backup-/Restore-Trockenprüfung — 14. Oktober 2026 +**Später am selben Tag behoben:** [Qwen-Voice-Backupkorrektur](../2026-10-14-qwen-voice-backup-fix/README.md). +Neue Generation 20261014-181754 vollständig verifiziert. Der folgende Fehlerbefund +ist der historische Stand vor der Reparatur. + ## Ergebnis 59 lokale Tests bestanden, 85 Python-Dateien des Backup-/Deploymentpfads syntaktisch diff --git a/test_disk_io.py b/test_disk_io.py new file mode 100644 index 0000000..e38154d --- /dev/null +++ b/test_disk_io.py @@ -0,0 +1,33 @@ +import tempfile,unittest +from pathlib import Path +from unittest.mock import patch +import collect_hardware as h + +class DiskIOTests(unittest.TestCase): + def test_only_whole_ssds_and_linux_512_byte_sectors(self): + with tempfile.TemporaryDirectory() as d: + root=Path(d);proc=root/'proc';sys=root/'sys';proc.mkdir() + for name,rot in [('nvme0n1','0'),('sda','0'),('sdb','1'),('nvme0n1p1','0'),('dm-0','0')]: + dev=sys/'class/block'/name;(dev/'queue').mkdir(parents=True);(dev/'queue/rotational').write_text(rot) + (dev/'device').mkdir();(dev/'device/model').write_text('SSD test') + (sys/'class/block/nvme0n1p1/partition').write_text('1') + (proc/'diskstats').write_text('\n'.join('259 0 '+name+' 10 0 100 0 20 0 200 0 2 300 0' for name in ['nvme0n1','nvme0n1p1','sda','sdb','dm-0'])) + with patch.object(h,'PROC',proc),patch.object(h,'SYS',sys):sample=h.disk_sample() + self.assertEqual(set(sample),{'nvme0n1','sda'}) + newer={n:{**v,'counters':[20,120,40,240,800]} for n,v in sample.items()} + row=h.disk_rates(newer,(10,sample),12)[0] + self.assertEqual(row['read_bytes_per_second'],5120);self.assertEqual(row['write_bytes_per_second'],10240) + self.assertEqual(row['read_iops'],5);self.assertEqual(row['write_iops'],10);self.assertEqual(row['busy_percent'],25) + def test_first_sample_reset_and_new_device_are_unknown_not_zero(self): + s={'sda':dict(name='sda',model='SSD',in_flight=0,counters=[10]*5)} + self.assertIsNone(h.disk_rates(s,None,1)[0]['read_iops']) + self.assertIsNone(h.disk_rates(s,(1,{'sda':{**s['sda'],'counters':[20]*5}}),2)[0]['read_iops']) + self.assertIsNone(h.disk_rates(s,(1,{}),2)[0]['read_iops']) + self.assertIsNone(h.disk_rates(s,(2,s),2)[0]['read_iops']) + def test_idle_zero_and_busy_time_clamped(self): + s={'sda':dict(name='sda',model='SSD',in_flight=0,counters=[10]*5)} + self.assertEqual(h.disk_rates(s,(1,s),2)[0]['read_iops'],0) + newer={'sda':{**s['sda'],'counters':[10,10,10,10,5010]}} + self.assertEqual(h.disk_rates(newer,(1,s),2)[0]['busy_percent'],100) + +if __name__=='__main__':unittest.main()