- run now counts rules skipped because their check produced no number (or the line was unparseable) and reports both counts, so an all-skipped pass no longer reads as 'evaluated 0 rule(s)'. - preinstall.sh installs lm-sensors — the sensor example rules in event.env need it; howto troubleshooting notes to check 'sensors -u' output for the real *_input key before adding a rule.
3.1 KiB
How-To: pos system event-trigger
State-based threshold monitors: each line of event.env is an independent rule;
when a rule's check crosses its threshold you get one alert (plus one recovery
message when it clears). Alerts go through lib/notify.sh — Telegram by
default, NOTIFY_PLATFORM for more.
pos system event-trigger config # interactive rule editor
pos system event-trigger list # rules + live check values
pos system event-trigger enable 5m # evaluate every 5 minutes via systemd
pos system event-trigger status # timer + rule count
pos system event-trigger disable # stop monitoring
pos system event-trigger run --dry-run # preview what would fire
Rule format
One rule per line in ~/.config/linux_post_install/event.env (chmod 600):
["<message>" if ] <check-command> <op> <threshold>
| Part | Meaning |
|---|---|
"<message>" if |
Optional custom alert text (quote-stripped); without it the message is auto-composed |
<check-command> |
Any shell command; its first numeric output is the value (pipes/args fine) |
<op> |
> < >= <= == != |
<threshold> |
Number with optional unit suffix — 60c, 80%, 10g all work |
The operator is detected as the rightmost op threshold pair in the line, so
check commands containing their own >/< (redirection, awk) don't confuse it.
Examples:
# event.env
"CPU too hot" if sensors -u | grep -m1 temp1_input | awk '{print $2}' > 60c
"Disk nearly full" if df -P / | awk 'NR==2{print $5+0}' > 80%
"Load high" if uptime | sed 's/.*load average: //; s/,.*//' >= 4
Behavior:
- The check runs on every pass. Non-numeric/empty output, or an unparseable
line → the rule is skipped with a warning (other rules still run). The
runsummary reports how many rules evaluated and how many were skipped. sensorsrules needlm-sensorsinstalled (preinstall.shinstalls it; verify withsensors -ubefore adding a rule — sensor names differ by chip, checksensors -uoutput for the real*_inputkey).- Alerts fire once when the condition turns true, and once more when it recovers — a hot CPU for two hours is one message, not twenty.
- State is tracked per rule in
~/.local/share/linux_post_install/eventer/state/(keyed by a hash of the rule line — editing a rule resets its state).
Scheduling
enable [interval] installs a systemd user timer (pos-event-trigger.timer
- oneshot
.servicethat runspos system event-trigger run). Intervals:5m 10m 15m 30m 45m hourly 2h 6h 12h daily weekly, or a rawOnCalendar=…. Requires a reachable user systemd manager; runsudo loginctl enable-linger $USERonce so timers fire without login (the tool tries this and warns if it can't).
Alerting
run sends via lib/notify.sh notify_send, which delivers to every platform in
NOTIFY_PLATFORM (default telegram; comma-separated = fan out). Adding a
Matrix/Synapse sender later needs no changes here — see DOC/DEV.md → Alerting.
Related
- Reference: DOC/POS.md → system
- Notifications: communication /
lib/notify.sh