Commit Graph

2 Commits

Author SHA1 Message Date
tommy 250fea8679 ups-quarterly-test: sync tracked copy to live + fix false-alarm bugs
The tracked copy was a stale pre-refactor version (no sequential-test
safety, no textfile metric). Replace with the current script plus fixes
for the UPSBatteryTestFailed false alarm:

- Poll ups.test.result until terminal ("passed"/"failed") instead of a
  single racy read — CyberPower updates the string slower than the OL
  transition, which recorded 0 despite a passing test.
- to_gauge matches *passed* substring, not exact "Done and passed".
- Fix cron OR-logic: setting both DOM (1-7) and DOW (0) made cron run on
  EITHER (daily Jul 1-7 + Sundays). Script now self-guards to day<=7;
  cron fires every Sunday of the quarter months.
- Externalize NUT_PASS to /etc/ups-quarterly-test.env (root:600) so the
  password is no longer embedded in the repo. Deploy via ups-fix.sh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 18:31:46 -05:00
tommy 38fa22d444 monitoring: add quarterly UPS self-test script (Phase 4B)
ups-quarterly-test.sh:
  - Runs test.battery.start.quick on cyberpower1 then cyberpower2
  - 120s wait between tests (allow recharge)
  - Logs pass/fail to syslog via logger -t ups-quarterly-test
  - Password stored in single-quoted variable to prevent shell expansion
  - Deployed on beast (/usr/local/bin/), cron: first Sunday of Jan/Apr/Jul/Oct 02:00

Manual run 2026-05-06:
  cyberpower1: Done and passed (charge 97% post-test, recharged normally)
  cyberpower2: Done and passed (charge 100%)

Grafana alerts (in grafana.db):
  cfl8lrs1mxnnka  UPS Battery Charge Low (<80%) — break-tested pending ✓
  afl8lrs4mbaioa  UPS On Battery (power outage) — break-tested fired ✓

Note: nut_battery_test_result not exposed by nut-exporter v1.2.1.
Pass/fail tracked via syslog only for now. Adding to Phase 5 if exporter
gains test-result metric support.
2026-05-06 06:05:50 -05:00