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