13fffb5775
Starter rules for CPU (pinned coretemp chip), load, memory, disk space, SMART/NVMe health, network, and top processes. All verified to parse and evaluate via the event-trigger parser; howto references the template.
55 lines
3.4 KiB
Plaintext
55 lines
3.4 KiB
Plaintext
# eventer rules template — copy/paste into ~/.config/linux_post_install/event.env
|
|
# (or add each line via: pos system event-trigger config).
|
|
#
|
|
# One independent rule per line. Grammar:
|
|
#
|
|
# "<message>" if <check-command> <op> <threshold>
|
|
# <check-command> <op> <threshold> (no message → auto-composed)
|
|
#
|
|
# <message> optional quoted alert text (quote-stripped)
|
|
# <check-command> any shell command; first numeric output is the value
|
|
# <op> > < >= <= == !=
|
|
# <threshold> number with optional unit suffix: 60c, 80%, 10g
|
|
#
|
|
# Rules alert once on false→true (plus one recovery message on true→false)
|
|
# via lib/notify.sh — Telegram by default. State is tracked per rule in
|
|
# ~/.local/share/linux_post_install/eventer/state/ (keyed by rule-line hash).
|
|
#
|
|
# Verify each check on your machine first (adjust device names):
|
|
# sensors -u coretemp-isa-0000 | awk '/Package id 0:/{f=1} f && /temp1_input:/{print $2; exit}'
|
|
# smartctl -A /dev/sda | awk '/Temperature_Celsius/{print $10}'
|
|
# nvme smart-log /dev/nvme0
|
|
# vnstat -d 1
|
|
#
|
|
# ── CPU (lm-sensors) ──────────────────────────────────────────────
|
|
"CPU too hot" if sensors -u coretemp-isa-0000 | awk '/Package id 0:/{f=1} f && /temp1_input:/{print $2; exit}' > 60c
|
|
"CPU hot warning" if sensors -u coretemp-isa-0000 | awk '/Package id 0:/{f=1} f && /temp1_input:/{print $2; exit}' > 55c
|
|
"Load high" if uptime | sed 's/.*load average: //' | awk -F'[, ]+' '{print $1}' > 4
|
|
|
|
# ── Memory (procps, always present) ───────────────────────────────
|
|
"RAM high" if free -m | awk '/^Mem:/{print int($3/$2*100)}' > 90%
|
|
"Swap in use" if free -m | awk '/^Swap:/{print $3+0}' > 1000
|
|
|
|
# ── Disk space ───────────────────────────────────────────────────
|
|
"Disk / nearly full" if df -P / | awk 'NR==2{print $5+0}' > 80%
|
|
"Disk /srv full" if df -P /srv | awk 'NR==2{print $5+0}' > 85%
|
|
|
|
# ── Disk health (smartmontools) ──────────────────────────────────
|
|
"Disk sda SMART fail" if smartctl -H /dev/sda | grep -q PASSED && echo 0 || echo 1 == 1
|
|
"SDA hot" if smartctl -A /dev/sda | awk '/Temperature_Celsius/{print $10}' > 50c
|
|
|
|
# ── NVMe (nvme-cli) ──────────────────────────────────────────────
|
|
"NVMe hot" if nvme smart-log /dev/nvme0 | awk '/^temperature/{print $3}' > 65c
|
|
"NVMe wear-out" if nvme smart-log /dev/nvme0 | awk '/percentage used/{print $NF+0}' > 80%
|
|
|
|
# ── Network (vnstat needs ~1 day of collected data) ──────────────
|
|
"Big traffic day" if vnstat -d 1 | awk '/today/{print $10+0}' > 20000
|
|
"Link eth0 down" if ethtool eth0 | grep -q 'Link detected: yes' && echo 0 || echo 1 == 1
|
|
|
|
# ── Processes ────────────────────────────────────────────────────
|
|
"Top CPU 80%" if top -bn1 | awk 'NR==8{print $9+0}' > 80%
|
|
"Top MEM 90%" if top -bn1 | awk 'NR==8{print $10+0}' > 90%
|
|
|
|
# Manage rules interactively: pos system event-trigger config
|
|
# Schedule the timer: pos system event-trigger enable 5m
|