add docs for ups

This commit is contained in:
Alex Tau 2026-01-18 15:33:56 +03:00
parent 6c8ae03b6a
commit 5cd3f47d65
4 changed files with 134 additions and 1 deletions

View file

@ -36,12 +36,13 @@ List of enabled check sets\. Each check set is a module which checks something a
- ram alerts when RAM usage is above threshold
- temp alerts when temperature readings are above thresholds
- net alerts when network usage is above threshold
- ups alerts on UPS events
- vulnix periodically scans system for known CVEs, alerts if any are found (NixOS only)
*Type:*
list of (one of “self”, “remind”, “cpu”, “ram”, “temp”, “net”, “vulnix”)
list of (one of “self”, “remind”, “cpu”, “ram”, “temp”, “net”, “ups”, “vulnix”)
@ -635,6 +636,48 @@ null or (positive integer or floating point number, meaning >0)
## services\.lego-monitoring\.checks\.ups\.upsToCheck
List of UPSs to monitor, in ` upsc `-compatible format\. If null, all UPSs connected to localhost are checked\.
*Type:*
null or (list of string)
*Default:*
` null `
*Declared by:*
- [modules/options\.nix](../modules/options.nix)
## services\.lego-monitoring\.checks\.ups\.upsmonGroup
Group to allow to send UPS status updates\. This should usually include the user upsmon runs as\.
*Type:*
string
*Default:*
` config.power.ups.upsmon.user `
*Declared by:*
- [modules/options\.nix](../modules/options.nix)
## services\.lego-monitoring\.checks\.vulnix\.whitelist

85
docs/ups.md Normal file
View file

@ -0,0 +1,85 @@
# UPS monitoring
Both steps require configuring upsmon at least to the point of outputting UPS updates to upsmon's logs.
## NixOS
NOTIFYCMD is set automatically. Make sure to set NOTIFYFLAGs to include EXEC for events that are to be reported.
The following snippet enables all events to be reported to wall, system's log and lego-monitoring:
```nix
{
power.ups.upsmon.settings.NOTIFYFLAG = (map (ntype: [ntype "SYSLOG+WALL+EXEC"]) [
"ONLINE"
"ONBATT"
"LOWBATT"
"FSD"
"COMMOK"
"COMMBAD"
"SHUTDOWN"
"SHUTDOWN_HOSTSYNC"
"REPLBATT"
"NOCOMM"
"NOPARENT"
"CAL"
"NOTCAL"
"OFF"
"NOTOFF"
"BYPASS"
"NOTBYPASS"
"ECO"
"NOTECO"
"ALARM"
"NOTALARM"
"OVER"
"NOTOVER"
"TRIM"
"NOTTRIM"
"BOOST"
"NOTBOOST"
"OTHER"
"NOTOTHER"
"SUSPEND_STARTING"
"SUSPEND_FINISHED"
]);
}
```
## Non-NixOS
* NOTIFYCMD should be set to `/opt/lego-monitoring/.venv/bin/write-ups-status`.
* As above, NOTIFYFLAGs should include EXEC. Example for all events:
```
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN_HOSTSYNC SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
NOTIFYFLAG CAL SYSLOG+WALL+EXEC
NOTIFYFLAG NOTCAL SYSLOG+WALL+EXEC
NOTIFYFLAG OFF SYSLOG+WALL+EXEC
NOTIFYFLAG NOTOFF SYSLOG+WALL+EXEC
NOTIFYFLAG BYPASS SYSLOG+WALL+EXEC
NOTIFYFLAG NOTBYPASS SYSLOG+WALL+EXEC
NOTIFYFLAG ECO SYSLOG+WALL+EXEC
NOTIFYFLAG NOTECO SYSLOG+WALL+EXEC
NOTIFYFLAG ALARM SYSLOG+WALL+EXEC
NOTIFYFLAG NOTALARM SYSLOG+WALL+EXEC
NOTIFYFLAG OVER SYSLOG+WALL+EXEC
NOTIFYFLAG NOTOVER SYSLOG+WALL+EXEC
NOTIFYFLAG TRIM SYSLOG+WALL+EXEC
NOTIFYFLAG NOTTRIM SYSLOG+WALL+EXEC
NOTIFYFLAG BOOST SYSLOG+WALL+EXEC
NOTIFYFLAG NOTBOOST SYSLOG+WALL+EXEC
NOTIFYFLAG OTHER SYSLOG+WALL+EXEC
NOTIFYFLAG NOTOTHER SYSLOG+WALL+EXEC
NOTIFYFLAG SUSPEND_STARTING SYSLOG+WALL+EXEC
NOTIFYFLAG SUSPEND_FINISHED SYSLOG+WALL+EXEC
```