Commit Graph

45 Commits

Author SHA1 Message Date
5032c58f7d host_sensors: read extra hwmon chips (dell_smm) as env sensors
Boxes without IPMI (Dell workstations like dev-linux) expose CPU/ambient/
SODIMM/board temps via the BIOS SMM interface (dell_smm hwmon). Add
read_hwmon_env(): labelled temps from chips in HOST_HWMON_CHIPS (default
'dell_smm') as env sensors, named '<chip> <label>' with index suffix for
repeated labels. Merged into the host-poller env sweep. No-op on hosts without
the configured chips.
2026-06-16 19:46:39 +00:00
4c68bff964 Add k8s DaemonSet design for RKE2 nodes (Model A, per-node self-contained)
Design artifact (NOT applied). Per-node pod = host-poller + redis + web sharing
pod localhost; only host-poller privileged with hostPath /dev+/sys. No SAS
poller (no enclosures). MQTT_NODE_ID from spec.nodeName; MQTT creds via VSO
VaultStaticSecret reading secret/home_assistant (mqtt_user/pass -> MQTT_USERNAME/
PASSWORD). nodeSelector jbod-monitor=enabled to pin to pascal/currie/fermi.
2026-06-16 19:41:51 +00:00
514502e045 host_sensors: filter IPMI margin sensors; coretemp per-core CPU fallback
- skip IPMI '*Margin' sensors (thermal margin / distance-to-throttle reads in
  degrees C but is not an absolute temperature, e.g. robin's P1 Therm Margin)
- coretemp: when a CPU has no 'Package id' sensor (older Xeons like robin's
  X3430), fall back to the hottest Core as the CPU temp
2026-06-16 19:05:10 +00:00
ea045433e5 Split host-poller into separate env (IPMI/CPU) and drive (SMART) loops
Two concurrent loops in one process sharing the lock + hardware gate (IPMI and
SMART never run concurrently) but on separate schedules: env every
HOST_ENV_INTERVAL (60s, responsive inlet/CPU) and drives every
HOST_DRIVE_INTERVAL (300s, gentle SMART). Each loop has its own heartbeat
(env_meta/drive_meta) + restart-storm guard.
2026-06-16 18:50:16 +00:00
822829aae4 host-poller: poll chassis sensors every 60s (inlet temp 1/min) 2026-06-16 18:45:33 +00:00
1839e9d5f2 Add host-poller: chassis IPMI/iDRAC + CPU + on-metal drive temps
New third producer container (host-poller) owning the server chassis
subsystem, separate from the SAS-shelf poller:
- services/host_sensors.py: in-band IPMI (ipmitool sdr) for Inlet/Exhaust/etc.
  + CPU package temps from coretemp hwmon
- host_poller.py: own single-instance lock + heartbeat (host_poll keys),
  restart-storm guard, paced; writes jbod:host_sensors + jbod:host_drives
- move host/on-metal drive collection off the SAS poller to host-poller
  (reads jbod:zfs_map for annotation)
- store: generalized lock/meta with a key param; host_sensors + host-poll keys
- mqtt_publisher: publish env/CPU/host-drive temps as entities on the hub
  device (JBOD Monitor)
- Dockerfile host-poller target (ipmitool+smartmontools); compose.infra adds
  host-poller; build.sh gains host-poller/all
2026-06-16 18:27:56 +00:00
44a7824425 Name the MQTT hub device (fix HA 'Unnamed Device')
Enclosure entities set via_device to a parent hub id that nothing defined,
so Home Assistant showed an 'Unnamed Device'. Publish a hub connectivity
binary_sensor ('Status', online/offline from the LWT topic) that defines the
parent device with a proper name, so the per-enclosure devices nest cleanly
under 'JBOD Monitor (<node>)'.
2026-06-16 17:21:16 +00:00
226f73851c Fix critical lock-expiry window found in Codex second pass
- poller.py: start lock_refresher() IMMEDIATELY after acquiring the lock,
  before the startup jitter and restart-storm deferral. Those sleeps can
  together exceed LOCK_TTL (restart defer is up to POLL_SWEEP_INTERVAL), so
  with the refresher started afterward the lock could expire mid-deferral and
  a second poller could begin sweeping concurrently — the exact hardware-storm
  risk this design prevents.
- hwgate.py: clamp POLL_CONCURRENCY to 1 unless POLL_ALLOW_UNSAFE_CONCURRENCY
  is set (fragile SAS hardware; >1 can drop expanders). Warn either way.
- build.sh: keep backward-compatible — a non-target first arg is treated as
  the commit message (./build.sh "msg" still works), known targets select
  web|poller|all.
2026-06-16 16:26:36 +00:00
7878e17e55 Harden poller from Codex review: close residual storm/robustness gaps
Adversarial review (gpt-5.5) of the new architecture surfaced real gaps:

Hardware-safety / storm prevention:
- Restart-storm guard: on startup, defer the first sweep if a sweep ran
  < POLL_SWEEP_INTERVAL ago (persisted in Redis), so deploy-cycling can no
  longer trigger back-to-back full hardware sweeps (poller.py).
- Centralize pacing in the hardware gate: POLL_DRIVE_GAP is now held after
  EVERY hardware op (SMART, SES, host, MegaRAID, ledctl), not just the
  enclosure-drive loop (hwgate.py); removed the now-redundant per-loop sleeps.
- Single-instance lock made atomic (Lua compare-and-set / compare-and-expire)
  and the refresher is now fatal on any error + has a done-callback, so a
  dropped lock can never leave two pollers sweeping concurrently (store.py,
  poller.py).
- Warn loudly when POLL_CONCURRENCY > 1.

Correctness:
- Heartbeat now actually writes: cache_set omits EX when ttl<=0 (Redis
  rejects EX 0), so poller meta/last_sweep_ts persists — this also enables
  the restart-storm guard and the poller_fresh health flag (cache.py).
- Web image runs a single uvicorn worker so the MQTT publisher is a true
  singleton (two workers shared a client_id and flapped the broker) (Dockerfile).
- LED enqueue catches Redis errors -> API returns 503, not 500 (store.py).

Deploy independence:
- build.sh takes a target (web|poller|all) so web iterations never rebuild
  or repush the poller image.

Nits: drop dead SMART_CACHE_TTL constant.
2026-06-16 15:58:43 +00:00
cccc2bc004 Split deploy into independent poller and web stacks
Decouple the privileged hardware poller from web iterations so a web
redeploy can never recreate/restart the poller (the backplane-touching
container). Two images from one Dockerfile via build targets:

- jbod-poller: privileged producer, ships smartmontools/sg3-utils/ledmon,
  Redis-only deps (~197MB)
- jbod-web: unprivileged read-only consumer (REST/UI/MQTT), no hardware
  tools, no /dev (~147MB)

Two compose projects sharing Redis over host networking:
- compose.infra.yml (jbod-infra): poller + redis — stable substrate
- compose.web.yml   (jbod-web):   app — 'up -d --build' touches only app

build.sh builds/pushes both images; split requirements-{poller,web}.txt;
dropped the combined docker-compose.yml; .dockerignore excludes tmp/ (keeps
the venv and the mqtt.env creds out of the build context).
2026-06-16 15:23:42 +00:00
0f829e0380 Split into dedicated hardware poller + read-only consumers
Rearchitect so a single poller process is the sole owner of all SAS/SMART/
SES hardware I/O, serialized behind one gate and paced, writing results to
Redis. The API/web and MQTT publisher become pure Redis readers — they no
longer issue any subprocess and can restart freely without touching the bus.

This addresses backplane/expander stress from concurrent + restart-triggered
SMART/SES storms (the prior model re-ran a hardware sweep on every container
start, and polled sg_ses 0x02+0x07 every 60s; 0x07 errored on the IOM6/
Xyratex expanders).

- poller.py: paced sweep (inventory, SMART per-drive w/ gap, SES 0x02, ZFS,
  host/MegaRAID), startup jitter, single-instance Redis lock, LED-queue worker
- services/hwgate.py: global serialization semaphore (POLL_CONCURRENCY=1)
- services/store.py: Redis as the only producer<->consumer interface + LED queue
- services/health.py: shared drive-health classifier (fixes overview double-count)
- gate smartctl/sg_ses/zpool/ledctl; drop sg_ses 0x07 from the hot path
- routers + temps read-only from the store; main.py drops the in-process poller
- compose: 3 services (privileged poller + unprivileged app + redis) w/ pacing knobs
2026-06-16 15:12:34 +00:00
7a50d1261f Treat sg_ses '<empty>' element descriptor as no name
Some enclosures (Xyratex/NetApp shelves) leave SES element descriptor
strings blank; sg_ses prints the literal '<empty>'. Skip it so temp
sensors fall back to a generic 'Temp N' label instead of '<empty>'.
2026-06-16 05:05:58 +00:00
d41e3838d5 Add per-enclosure temperature metrics + Home Assistant MQTT publisher
- enclosure: fetch SES element descriptor page (0x07) and label temp/fan/
  psu/voltage elements with human-readable names
- temps service + /api/temps: per-enclosure hotspot (max across SES sensors
  and housed drive temps) plus named SES sensor list
- mqtt_publisher: paho-mqtt with HA discovery (device per enclosure, hotspot
  + per-sensor entities), LWT availability, opt-in via MQTT_HOST
- secrets: OpenBao KV v2 reader; MQTT creds sourced from secret/home_assistant
  with env fallback
- compose/requirements/README updated
2026-06-16 04:45:32 +00:00
50dd2a631e Filter dead temp sensors from SES health and recompute overall status
Xyratex HB-1235 enclosures have non-functional temperature sensor
slots that report Unrecoverable/Unknown at 0°C. The SES header
rolls these into UNRECOV=1, causing a false CRITICAL flag. Now we
skip dead sensors (0°C + non-OK status) and derive overall_status
from the actual parsed elements instead of the raw header counts.
2026-03-16 22:19:58 +00:00
3185acbb24 Skip secondary IOM enclosures with no device-linked slots
Dual-IOM shelves (e.g. NetApp DS2246 with two IOM6 modules) create
two sysfs enclosure entries. The secondary path reports populated
slots via SES but the kernel only links block devices through the
primary path. Filter these out during discovery to avoid showing
ghost enclosures with no drive data.
2026-03-16 22:12:48 +00:00
1b7412c80d Fix UnboundLocalError when no enclosures present 2026-03-07 23:02:34 +00:00
842f733638 Add tree-line connector for RAID child drives in host drives card 2026-03-07 19:07:14 +00:00
b11c1bdf98 Replace in-memory TTL cache with Redis 2026-03-07 18:45:15 +00:00
0112875894 Add enclosure health details (PSUs, fans, temps, voltages) via SES
Parse sg_ses --page=0x02 output to surface enclosure-level health data
including power supply status, fan RPMs, temperature sensors, and voltage
rails. Failed/critical components are reflected in the overview totals
and shown as status pills in the enclosure card header with an expandable
detail panel.
2026-03-07 06:03:26 +00:00
8ea8fdef08 Hide health status on RAID virtual disks in host drives section 2026-03-07 05:36:55 +00:00
1dd40a1181 Enumerate physical drives behind RAID via smartctl megaraid passthrough 2026-03-07 05:32:08 +00:00
98e435674c Fix smart_supported: treat null smart_support as unsupported 2026-03-07 05:21:41 +00:00
9ee701c749 Fix smart_supported detection for RAID controllers without SMART 2026-03-07 05:19:21 +00:00
798308d2bf Add host drives section for non-enclosure drives 2026-03-07 05:16:30 +00:00
927a5ccf3a Add ledctl locate/off LED controls to drive detail modal 2026-03-07 04:57:35 +00:00
51e6b49830 Make table view full-width and add fixed column layout 2026-03-07 04:48:34 +00:00
a25ce4ae21 Add ZFS drive state (ONLINE/FAULTED/DEGRADED) to UI 2026-03-07 04:44:31 +00:00
cea4db53fd Resolve multipath dm devices to underlying sd devices for ZFS pool map 2026-03-07 04:34:44 +00:00
3280d66888 Fix vdev parsing: use leading whitespace count instead of tab count 2026-03-07 04:20:42 +00:00
3ef7061aa5 Add ZFS vdev exposure in API and frontend 2026-03-07 04:14:14 +00:00
10de5563b2 Use nsenter with pid:host to run zpool in host mount namespace 2026-03-07 04:04:15 +00:00
034219c75e Set LD_LIBRARY_PATH only for zpool subprocess, not globally 2026-03-07 03:48:46 +00:00
4c033981c1 Fix ZFS pool detection: bind-mount host zpool binary and libs 2026-03-07 03:46:56 +00:00
861f9279c4 Implement full JBOD monitor frontend from design JSX
- Dark/light theme toggle, grid/table view toggle
- Expanded DriveHealthSummary with wwn, firmware, capacity, SMART
  counters, and computed health_status field
- Drive detail modal with identity, WWN, ZFS membership, SMART health
- 30s auto-refresh
2026-03-07 03:41:35 +00:00
284943c185 Fix SCSI firmware field name (scsi_revision) 2026-03-07 03:31:22 +00:00
4a2cbcaaec Fix SCSI/SAS drive identity fields (model, wwn, firmware) 2026-03-07 03:29:32 +00:00
78556bbfee Fix SPA serving conflicting with API routes 2026-03-07 03:23:45 +00:00
fdafb15b23 Sort slots numerically instead of lexicographically 2026-03-07 03:12:03 +00:00
8a8fbfbcf6 Use npm install instead of npm ci (no lockfile) 2026-03-07 03:06:26 +00:00
05448e7903 Remove zfsutils-linux from Dockerfile, bind-mount host ZFS tools
zfsutils-linux is not available in Debian Trixie. Instead, bind-mount
the host zpool/zfs binaries and shared libraries at runtime.
2026-03-07 03:05:41 +00:00
7beead8cae Add React frontend, ZFS pool mapping, and multi-stage Docker build
- Vite + React frontend with dark-themed dashboard, slot grid per
  enclosure, and SMART detail overlay
- ZFS pool membership via zpool status -P
- Multi-stage Dockerfile (Node build + Python runtime)
- Updated docker-compose with network_mode host and healthcheck
2026-03-07 03:04:23 +00:00
e2bd413041 Support 'array device' type for Xyratex enclosures 2026-03-07 02:35:13 +00:00
9b93eedbc8 Fix slot discovery for bare numeric sysfs directories 2026-03-07 02:33:12 +00:00
1157a5284f Add .gitignore and remove cached pyc files 2026-03-07 02:14:44 +00:00
9f918a3308 Initial commit: FastAPI JBOD monitor backend 2026-03-07 02:14:17 +00:00