feat: pos system event-trigger — state-based threshold monitors (eventer)

Each line of event.env is an independent rule: ["msg" if ] <check> <op> <thr>.
Check runs on every pass; first numeric output compared float-safe; op is the
rightmost 'op threshold' pair so checks with their own >/< parse fine. Alerts
once on false->true + one recovery message on true->false (no repeats while
the condition holds); per-rule state keyed by rule-line hash in
~/.local/share/linux_post_install/eventer/state/.

Subcommands: run (timer entrypoint), config (interactive add/remove/edit with
check-validation), list (rules + live values), enable [interval] (systemd
user timer pos-event-trigger.timer; 5m..weekly or OnCalendar; graceful without
a user manager, loginctl enable-linger attempt), disable, status. --dry-run
honors the DEV.md convention. Alerts via lib/notify.sh (Telegram default).

New: bin/pos-system-event-trigger, lib/eventer-lib.sh, config/event.env
template (no-clobber via postinstall), install.sh lib install, INTERACTIVE_CMDS
entry. Docs: POS.md system row, HOWTO.md index, howto/event-trigger.md.
make gen && make check green; functional tests cover trigger/recovery/no-repeat,
float+unit parsing, editor add/remove/edit + validation + dry-run, timer
enable/disable/status, dispatcher routing.
This commit is contained in:
Your Name
2026-08-09 17:09:59 +00:00
parent 2e57634877
commit 030ec0b456
12 changed files with 651 additions and 17 deletions
+21
View File
@@ -0,0 +1,21 @@
# eventer rules — evaluated by 'pos system event-trigger run' (systemd timer).
# Copied to ~/.config/linux_post_install/event.env on install (no clobber).
# One independent rule per line. Grammar:
#
# "<message>" if <check-command> <op> <threshold>
# <check-command> <op> <threshold> (no message → auto-composed)
#
# The check command is run; its first numeric output is compared against the
# threshold (float-safe, unit suffix on the threshold is fine: 60c, 80%, 10g).
# Operators: > < >= <= == !=
#
# Rules alert once on false→true (plus one recovery message when the
# condition clears) via lib/notify.sh — Telegram by default.
#
# Examples:
# "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
#
# Manage rules interactively: pos system event-trigger config
# Schedule the timer: pos system event-trigger enable 5m