Skip to content

fix(morpheus): alert when NUT loses the UPS and the syslog leaves' expiry; true up the audit's docs - #1671

Merged
Gerrrt merged 2 commits into
mainfrom
gerrrt/morpheus-audit-followups
Nov 23, 2026
Merged

Gerrrt merged 2 commits into
mainfrom
gerrrt/morpheus-audit-followups

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

What changed

The repository side of the 2026-11-13 morpheus audit, apart from the two findings in #1503.

  • A Loki trend rule on NUT. NutUpsDataStaleFrequent, added to feat(observability): watch NUT's upsmon logs, so a disarmed shutdown pages #1673's loki/rules/nut.rules.yaml, warns when upsd marks the data stale more than 24 times in an hour, twice the worst sliding hour measured (12). A spell that lasts is that file's NutCommunicationsLost, so this PR's earlier NutUpsDataStaleSustained is dropped. Two behaviour tests in nut.test.yaml.
  • NUT's own state, every 15 minutes. A log rule needs the lines to arrive: Loki holds no upsmon or upsd line from morpheus for 2026-11-06, mid-way through the driver outage (docs(ups): record mjolnir's eight silent days, and fix §0.2's menu path #1656), and an upsd that is down logs nothing. New scripts/collect-nut-state.sh asks upsc mjolnir@127.0.0.1 ups.status on the firewall from make gateway-state, and NutUpsUnreadable (critical) fires after 30 minutes without a status. A diagnostic upsc prints before the status does not count against it. Self-test and promtool cases.
  • The syslog TLS leaves' expiry is collected and alerted. collect-cert-expiry.sh gains --file ENDPOINT=HOST=PATH, for a certificate that has no handshake to read (morpheus's client leaf; key files are refused). make gateway-state reads syslog-listener off its handshake and syslog-client from the pinned copy. SyslogTlsCertificateExpiringSoon warns at 30 days, and the two console rules now exclude syslog-* so their console-specific text never describes these. New promtool cases in cert-expiry.test.yaml.
  • network.md: the undeclared Hicks SSH pass into smaug is declared (ten, not nine), Skids has eight reservations including .24, and a new note lists the thirteen reservations morpheus pins in its ARP table.
  • hardware.md: no longer says nothing collects pfSense's release; check_versions.py does, from sysDescr.
  • Changelog: the audit, and where every finding stood on 2026-11-23.
  • Rule counts: 192 (166 + 26), merged with main's feat(ups): read the AP9335T rack-ambient probe on mjolnir's card #1672 and feat(observability): watch NUT's upsmon logs, so a disarmed shutdown pages #1673.

Why

The audit found these, and on 2026-11-23 none had moved. Over the fortnight to 2026-11-23, NUT's data went stale 1,363 times, never longer than 5.2 s and never more than 12 in a sliding hour, and nothing watched it: a long gap during a power cut leaves every NUT secondary blind. The syslog leaves (825 days, due 2029-01-09) had no expiry alert; the day they lapse, the firewall's logs just stop. The doc fixes make network.md and hardware.md true again.

Blast radius

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

make gateway-state gains two steps. One writes cert-expiry-syslog-tls.prom from the listener's handshake on 10.0.99.20:6514 and a public certificate file; if the listener is down it fails the job, and FirewallLogsStopped would be firing too. The other runs upsc on morpheus over the ssh the job already makes, read-only. NutUpsUnreadable is critical, so it pages: today NUT reads OL, so it starts quiet. The new Loki rule is quiet against live Loki today (4 in the last hour).

Verification

  • make validate passed before the merge with main (5 local skips: worktree-only timer and unit checks and the tmpfs offsite refusal; CI runs them). After the merge: lint, check_docs.py, the Loki behaviour tests (65/65 over 26 rules), collect-nut-state.sh --self-test and promtool on ups.test.yaml and cert-expiry.test.yaml pass
  • Deployed to the lab and confirmed working: deploys with the next converge after merge. Confirm cert-expiry-syslog-tls.prom appears with both endpoints checked 1, nut-state-morpheus.prom with homelab_nut_ups_readable 1, and that NutUpsDataStaleFrequent is loaded on the Loki ruler.
  • Docs updated: network.md, hardware.md, observability.md, generate-certificates.md, scripts/README.md, the changelog and the counts

The Loki expression was run against live Loki (4, under the threshold). collect-cert-expiry.sh --print with the new arguments reads both leaves (checked 1, 2029-01-09). collect-nut-state.sh --print against morpheus reads OL (readable 1). collect-nut-state.sh --self-test, collect-cert-expiry.sh --self-test, the Loki rule tests (65/65) and promtool test rules on cert-expiry.test.yaml and ups.test.yaml pass.

Refs #1503.

🤖 Generated with Claude Code

…piry; true up the audit's docs

The repository side of the 2026-11-13 morpheus audit, apart from the
firewall's own addresses and key-only sshd (#1503).

- loki/rules/ups.rules.yaml: NutUpsDataStaleSustained (a stale period two
  minutes long) and NutUpsDataStaleFrequent (over twenty in an hour). The
  fortnight to 2026-11-23 had 1,363 periods, none over 5.2 s, at most nine
  an hour. Five behaviour tests. Neither sees a gap that lasts days, as the
  2026-11-05 driver outage did, because syslogd folds repeats; so
  scripts/collect-nut-state.sh asks upsc on the firewall from make
  gateway-state, and NutUpsUnreadable pages after 30 minutes.
- collect-cert-expiry.sh --file, for a client certificate with no handshake
  to read. make gateway-state reads the syslog listener's leaf and
  morpheus's pinned client leaf; SyslogTlsCertificateExpiringSoon warns at
  30 days, and the console rules exclude syslog-*.
- network.md: the undeclared Hicks SSH pass into smaug (ten passes), Skids'
  eighth reservation at .24, and the thirteen static ARP reservations.
- hardware.md: check_versions.py does collect pfSense's release.
- Changelog: the audit, and where each finding stood on 2026-11-23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The alert logic can miss sustained outages after recent recoveries, while harmless diagnostics in successful UPS responses can cause false critical alerts.

2 open issues
What changed in this PR

This PR addresses monitoring and documentation findings from the morpheus audit, extending the existing observability stack while leaving firewall-access changes to #1503.

Changes:

  • Adds NUT log alerts and periodic UPS-status collection.
  • Adds syslog TLS certificate-expiry monitoring, including local certificate-file support.
  • Corrects audit documentation and updates alert counts to 186.
File Description
stacks/​observability/​README.md Updates Prometheus and Loki alert counts.
stacks/​observability/​prometheus/​tests/​ups.test.yaml Tests unreadable and healthy NUT states.
stacks/​observability/​prometheus/​tests/​cert-expiry.test.yaml Tests syslog expiry alerts and console-rule exclusions.
stacks/​observability/​prometheus/​rules/​ups.rules.yaml Adds the critical NUT readability alert.
stacks/​observability/​prometheus/​rules/​host.rules.yaml Separates syslog certificate alerts from console alerts.
stacks/​observability/​loki/​tests/​ups.test.yaml Adds five NUT log-rule scenarios.
stacks/​observability/​loki/​rules/​ups.rules.yaml Adds sustained and frequent stale-data alerts.
scripts/​self-tests.sh Documents the NUT collector’s self-test coverage.
scripts/​README.md Documents new collector capabilities.
scripts/​collect-nut-state.sh Collects UPS readability through SSH and upsc.
scripts/​collect-cert-expiry.sh Adds local certificate-file expiry collection.
README.md Updates overall and per-engine alert counts.
Makefile Adds syslog certificate and NUT collection to gateway-state.
docs/​security.md Updates the total alert count.
docs/​runbooks/​generate-certificates.md Documents syslog certificate monitoring and renewal.
docs/​runbooks/​deploy-stack.md Updates expected Prometheus rule counts.
docs/​observability.md Describes NUT monitoring and updates coverage counts.
docs/​network.md Records the SSH exception, reservations, and static ARP entries.
docs/​hardware.md Corrects the description of pfSense release collection.
docs/​changelog.md Records audit findings and their disposition.

Review effort: Balanced

Comment thread scripts/collect-nut-state.sh Resolved
@Gerrrt
Gerrrt enabled auto-merge (squash) November 23, 2026 15:06
… review points

main's #1673 added loki/rules/nut.rules.yaml, which covers a lasting loss
(NutCommunicationsLost) and a driver down (NutDriverNotConnected). So
NutUpsDataStaleSustained is dropped: it overlapped NutCommunicationsLost and
its start-minus-end count across a sliding window could hide an open spell
whose predecessor began before the window. NutUpsDataStaleFrequent moves into
nut.rules.yaml, at > 24 an hour: the worst sliding hour to 2026-11-23 was 12,
not the 9 an hour-aligned count gave.

collect-nut-state.sh now finds the status line wherever upsc prints it, so a
diagnostic such as "Init SSL without certificate database" before "OL" reads
as readable, with two new fixtures.

Counts: 192 rules, 166 Prometheus and 26 Loki; the Rules page lists 172.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt merged commit 8851ee7 into main Nov 23, 2026
11 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/morpheus-audit-followups branch November 23, 2026 17:30
@Gerrrt Gerrrt mentioned this pull request Nov 23, 2026
5 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants