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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user