From 8aed7538159fdd80531cc8efb6064e7800bdd68e Mon Sep 17 00:00:00 2001 From: menzel Date: Wed, 15 Jul 2026 11:16:03 +0200 Subject: [PATCH] epics2sms: send a brief startup notification listing monitored PVs On startup, send one message to all recipients summarising each active monitor (PV/threshold text, poll and alarm intervals, averaging window, message cap) so recipients can confirm the monitor is running and what it watches. Best-effort: a send failure does not stop monitoring. Co-Authored-By: Claude Opus 4.8 (1M context) --- EPICS2SMS.sh | 15 +++++++++++++++ README.md | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/EPICS2SMS.sh b/EPICS2SMS.sh index 8b442f8..f94f879 100755 --- a/EPICS2SMS.sh +++ b/EPICS2SMS.sh @@ -202,6 +202,7 @@ fi # --- launch monitors -------------------------------------------------------- pids=() +summaries=() cleaned=0 cleanup() { @@ -240,6 +241,8 @@ for entry in "${MONITORS[@]}"; do monitor_loop "$pv" "$dir" "$thresh" "$poll" "$apoll" "$n_avg" "$n_msg" "$text" & pids+=("$!") + # Brief per-monitor line for the startup notification. + summaries+=("$text (poll ${poll}s/alarm ${apoll}s, avg ${n_avg}, max ${n_msg} msg)") done if (( ${#pids[@]} == 0 )); then @@ -247,5 +250,17 @@ if (( ${#pids[@]} == 0 )); then exit 2 fi +# Send a brief startup notification so recipients know the monitor is running +# and what it watches. Best-effort: a failure here must not stop monitoring. +startup_body="EPICS2SMS started $(date '+%F %T') on $(hostname -s), ${#pids[@]} monitor(s):" +for line in "${summaries[@]}"; do + startup_body+=$'\n'"- $line" +done +if send_alert "$startup_body" "EPICS2SMS started"; then + log "startup notification sent" +else + log "WARNING: startup notification failed to send" +fi + log "started ${#pids[@]} monitor(s); polling..." wait diff --git a/README.md b/README.md index 7b333ac..7259cc5 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,11 @@ MONITORS=( ) ``` +On startup, the script sends **one brief notification** to all recipients +listing the monitors it is watching (PV, threshold, timing) so you can confirm +it is running. This is best-effort: if it fails to send, monitoring still +starts. + Behaviour of one monitor: - polls the PV every `poll_s` seconds while normal, every `alarm_poll_s` while