Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,19 @@ smart-state: ## Collect SMART health from THIS host's disks (needs root) and ren
./scripts/collect-smart-state.sh; \
fi

.PHONY: smart-state-sensitive
smart-state-sensitive: ## Collect SMART health from trinity's own disks (needs root), without the baselines
@# trinity's half of `smart-state`, run by homelab-smart-state-sensitive.timer.
@# The collector alone: the baseline table is rendered once, on the
@# monitoring host, and SmartDriveBadSectors joins it on(host, slot), so a
@# second copy from here would break the join for every drive.
@#
@# No SKIP for a missing smartctl or a missing root here, unlike
@# `smart-state`: this target exists for the timer, which runs as root, and
@# a host built without smartmontools should fail the job and page
@# ScheduledJobFailed rather than report a clean run that read nothing.
./scripts/collect-smart-state.sh

.PHONY: gateway-state
gateway-state: ## Collect the firewall's view of its uplinks, DDNS record and GUI certificate (#353, #604, #857)
@# Two measurements per family: what pfSense reports, and whether traffic of
Expand Down
12 changes: 12 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ roadmap as it read that day, and the *Done* entries keep the shape they had
there. `check_docs.py` does not check this file, for the reason its module
docstring gives: it is a record, not a claim about now.

## 2026-11-21

- **`trinity` reads SMART from its own disks.** It was the one host with a
checkout and Alloy that collected none, so a failing NVMe under the password
vault, or a failing photo disk, would have shown first as I/O errors. A new
sensitive-profile timer, `homelab-smart-state-sensitive`, runs the existing
collector as root daily at 08:30. It goes through a new make target,
`smart-state-sensitive`, and not `smart-state`, so the baseline table that
`SmartDriveBadSectors` joins stays rendered on the monitoring host alone.
The build runbook's step 4 now installs `smartmontools`. Found by the trinity
audit of 2026-11-13, which the repo had neither recorded nor decided.

## 2026-11-20

- **`trinity` subscribes to the UPS, and the shutdown window is widened to
Expand Down
16 changes: 15 additions & 1 deletion docs/runbooks/build-the-sensitive-tier-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ One block, pasted on `trinity`. It asks for your `sudo` password once:

```bash
sudo apt-get update
sudo apt-get install -y ca-certificates curl git make age tpm2-tools
sudo apt-get install -y ca-certificates curl git make age tpm2-tools smartmontools
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo tee /etc/apt/keyrings/docker.asc > /dev/null
Expand Down Expand Up @@ -691,6 +691,20 @@ both kinds here and checks `oracle`'s copies against their MANIFESTs
the installer primes it too. `verify-backups-sensitive.prom` must read exit
code `0`.

And `smart-state-sensitive`, daily at 08:30, which reads SMART from the NVMe
and the photo disk as root. It needs `smartmontools` from step 4. The
installer primes it, so read what it found straight away:

```bash
cat /var/lib/node_exporter/textfile_collector/smart-state-sensitive.prom
grep -E '^homelab_smart_(devices|healthy)' /var/lib/node_exporter/textfile_collector/smart-state-trinity.prom
```

The job's exit code must be `0`, and `homelab_smart_healthy` must carry a row
for `nvme0n1` and one for the photo disk. A USB disk whose bridge does not
pass SMART through is left out with a warning in
`journalctl -u homelab-smart-state-sensitive`, not counted as healthy.

## 13. Before the first real photo, document or vault item

These five are the gate on the data, not on the containers, and each is
Expand Down
15 changes: 13 additions & 2 deletions docs/runbooks/schedule-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ checkout ([#404](https://github.com/Gerrrt/HomeLab/issues/404) step 9):
| `backup-library` | `make backup-library` | daily 05:15 | 2 days |
| `converge-sensitive` | `make converge` with `STACK=sensitive` | hourly at :25 | 3 hours |
| `verify-backups-sensitive` | `make verify-backups` with `STACK=sensitive` | daily 06:30 | 2 days |
| `smart-state-sensitive` | `make smart-state-sensitive`, as **root** | daily 08:30 | 2 days |
| `household-copy` | **you**, `make household-copy DEST=…` | no timer | 90 days |
| `household-proof` | **you** and the holder, `make household-proof CODE=…` | no timer | 1 year |

Expand All @@ -766,6 +767,16 @@ MANIFEST. That is where `oracle`'s copies are verified, without a key on
`oracle`. It stops nothing, and it shares the `backups` lock so a prune never
deletes a set it is reading.

`smart-state-sensitive` is the monitoring host's local `smart-state` for
`trinity`'s own disks: the boot NVMe and the USB photo disk at `/srv/immich`.
It runs as root for the same reason, and writes `smart-state-trinity.prom`,
which `SmartStateStale` and the drive rules read like any other host's. It is
not `make smart-state`, because that target also renders the baseline table
that `SmartDriveBadSectors` joins `on(host, slot)`, and a second copy from
`trinity` would put two series on every key. `make smart-state-sensitive` runs
the collector alone, and has no `SKIP`: a `trinity` without `smartmontools`
fails the job and pages `ScheduledJobFailed`.

`converge-sensitive` is the monitoring host's `converge` for the tier
([#533](https://github.com/Gerrrt/HomeLab/issues/533)). It shares the
`backups` lock too, so it never runs `make up` under a quiesced tier. **Before
Expand All @@ -780,12 +791,12 @@ make install-timers PROFILE=sensitive
```

That writes a `homelab-jobs.prom` on `trinity` that declares only these
six. `household-copy` and `household-proof` are the household's copy
seven. `household-copy` and `household-proof` are the household's copy
([ADR-0073](../adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md),
[`carry-the-household-copy.md`](carry-the-household-copy.md)). They have no
timer, and `HouseholdCopyStale` reads them. The alert rules join on the job name alone, so a name may appear in only
one table, and `--check` enforces that. The installer primes `backup-library`,
`converge-sensitive` and `verify-backups-sensitive`, which stop nothing, and not `backup-sensitive`, which stops the tier. `make check-timers` checks both
`converge-sensitive`, `verify-backups-sensitive` and `smart-state-sensitive`, which stop nothing, and not `backup-sensitive`, which stops the tier. `make check-timers` checks both
profiles, and `make validate` on `trinity` fails until the backup and converge timers are
installed.

Expand Down
8 changes: 6 additions & 2 deletions scripts/install-timers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ JOBS=(
# what keeps the alert joins one-to-one across hosts, so it must not reuse a
# name from JOBS — check 8 below asserts that. And the nightly re-verification
# of both kinds of set, here and on oracle (#856): verify-backups-sensitive,
# two days for the same reason as the backups it re-reads. There is no
# age-key proof row here either (ADR-0120).
# two days for the same reason as the backups it re-reads. And the daily SMART
# read of trinity's own disks, smart-state-sensitive, two days like the
# estate's smart-state; its unit says why it is not `make smart-state`. There
# is no age-key proof row here either (ADR-0120).
#
# The units under systemd/sensitive/ carry @DEPLOY_ROOT@, @RUN_USER@,
# @RUN_GROUP@ and @RUN_HOME@ rather than a name, because the build runbook
Expand All @@ -184,6 +186,7 @@ SENSITIVE_JOBS=(
"backup-library homelab-backup-library 172800 backup-library"
"converge-sensitive homelab-converge-sensitive 10800 converge"
"verify-backups-sensitive homelab-verify-backups-sensitive 172800 verify-backups"
"smart-state-sensitive homelab-smart-state-sensitive 172800 smart-state-sensitive"
"household-copy - 7776000 household-copy"
"household-proof - 31536000 household-proof"
)
Expand Down Expand Up @@ -694,6 +697,7 @@ if [[ "${PROFILE}" == sensitive ]]; then
info "backup-library was primed: it stops nothing, and oracle now holds a set"
info "converge-sensitive was primed: it applied nothing if HOMELAB_CONVERGE_APPLY=0 was set first"
info "verify-backups-sensitive was primed: it re-read every set here and asked oracle to hash its copies"
info "smart-state-sensitive was primed: smart-state-trinity.prom holds this host's disks"
info "backup-sensitive was NOT primed: it stops the tier. Run it when you can watch:"
info " sudo systemctl start homelab-backup-sensitive.service"
exit 0
Expand Down
1 change: 1 addition & 0 deletions systemd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ instead.
| `homelab-backup-sensitive` | daily 04:30 | Quiesces the tier and archives its volumes |
| `homelab-backup-library` | daily 05:15 | Archives Immich's library and copies it to `oracle` |
| `homelab-verify-backups-sensitive` | daily 06:30 | Proves every volume and library set still decrypts, and `oracle`'s copies still hash to their MANIFESTs |
| `homelab-smart-state-sensitive` | daily 08:30 | Reads SMART from `trinity`'s NVMe and photo disk, as root |

## On agent hosts

Expand Down
62 changes: 62 additions & 0 deletions systemd/sensitive/homelab-smart-state-sensitive.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SMART health for trinity's own disks: the boot NVMe that holds the tier, and
# the USB disk at /srv/immich that holds the photographs (ADR-0064).
#
# The monitoring host's homelab-smart-state.service, run on the other host with
# a checkout, and that unit explains every directive below; this one states
# only what differs. Before it, trinity was the one Alloy host with a checkout
# that read no SMART at all: a failing NVMe under the password vault would have
# said so first as I/O errors.
#
# NOT `make smart-state`. That target also renders smart-baselines.prom, and
# SmartDriveBadSectors joins it `on(host, slot)` from the one copy the
# monitoring host serves (scripts/render-smart-baselines.sh). A second copy
# from here would put two series on every key and break the join for the whole
# estate. `make smart-state-sensitive` runs the collector alone.
#
# ROOT, for the estate unit's reason: smartctl's ATA and NVMe pass-through
# ioctls need raw device access, and no group substitutes. Nothing here runs as
# @RUN_USER@, so the unit reads that user's checkout and writes one directory.
#
# ITS LOCK LIVES IN THE TEXTFILE DIRECTORY. run-scheduled.sh opens
# ${HOMELAB_LOCK_DIR:-/run/lock}/homelab-<job>.lock before it runs anything, and
# ProtectSystem=strict leaves every path read-only but /dev, /proc, /sys and
# the ReadWritePaths below, /run/lock included. This job shares no lock with
# any other, so its own lock file can sit in the one directory it may write;
# node_exporter reads only *.prom there. Narrower than opening /run/lock, which
# holds other programs' locks.
#
# THE HOUSEHOLD DRIVE IS READ WHILE IT IS PLUGGED IN, and that is fine. It is
# attached here between copies (ADR-0073) and leaves with the holder; its
# series stop when it does, and no rule reads a drive's absence.
[Unit]
Description=HomeLab: collect SMART health for trinity's disks
Documentation=file://@DEPLOY_ROOT@/docs/runbooks/schedule-maintenance.md

[Service]
Type=oneshot
User=root
Group=root
WorkingDirectory=@DEPLOY_ROOT@
EnvironmentFile=-/etc/default/homelab-timers
Environment=HOMELAB_LOCK_DIR=/var/lib/node_exporter/textfile_collector
ExecStart=@DEPLOY_ROOT@/scripts/run-scheduled.sh --job smart-state-sensitive -- /usr/bin/make -C @DEPLOY_ROOT@ smart-state-sensitive
TimeoutStartSec=300
Restart=no
Nice=10
NoNewPrivileges=true
RestrictSUIDSGID=true
LockPersonality=true
RestrictRealtime=true
PrivateTmp=true
ProtectHome=read-only
ProtectSystem=strict
ReadWritePaths=/var/lib/node_exporter/textfile_collector
Comment thread
Gerrrt marked this conversation as resolved.
Resolved
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
PrivateNetwork=true
StandardOutput=journal
StandardError=journal
SyslogIdentifier=homelab-smart-state-sensitive

# No [Install] section: the timer enables this.
18 changes: 18 additions & 0 deletions systemd/sensitive/homelab-smart-state-sensitive.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=HomeLab: daily SMART collection on trinity
Documentation=file://@DEPLOY_ROOT@/docs/runbooks/schedule-maintenance.md

[Timer]
Unit=homelab-smart-state-sensitive.service
# 08:30, the estate's SMART time, so "every host's SMART is from this morning"
# stays true. Clear of the night's backups and their verification, which are
# done by 06:30 and hold the `backups` lock this does not take.
OnCalendar=*-*-* 08:30:00
RandomizedDelaySec=900
# True: a missed morning is collected at the next boot, so a gap in the series
# means "stopped reporting" and not "was off at 08:30".
Persistent=true
AccuracySec=1m

[Install]
WantedBy=timers.target