epics2sms: only send RESOLVED if an alarm message was sent this episode
Guard the recovery notification on msg_count > 0, so a brief excursion that never produced an alarm message (e.g. recovered before any send, or all sends failed) does not emit a lone RESOLVED. Recovery is still logged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+9
-6
@@ -183,12 +183,15 @@ monitor_loop() {
|
||||
else
|
||||
if (( in_alarm )); then
|
||||
mlog "$tag" "recovered to normal (avg=$avg) after $msg_count message(s)"
|
||||
# Recovery notification: sent once, immediately (not throttled/capped).
|
||||
body="RESOLVED: $text - now avg=$avg (last=$value) $(date '+%F %T')"
|
||||
if send_alert "$body" "EPICS resolved"; then
|
||||
mlog "$tag" "resolve notification sent"
|
||||
else
|
||||
mlog "$tag" "ERROR: resolve notification failed to send"
|
||||
# Recovery notification: only if we actually alerted during this
|
||||
# episode; sent once, immediately (not throttled/capped).
|
||||
if (( msg_count > 0 )); then
|
||||
body="RESOLVED: $text - now avg=$avg (last=$value) $(date '+%F %T')"
|
||||
if send_alert "$body" "EPICS resolved"; then
|
||||
mlog "$tag" "resolve notification sent"
|
||||
else
|
||||
mlog "$tag" "ERROR: resolve notification failed to send"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
in_alarm=0
|
||||
|
||||
@@ -63,8 +63,9 @@ Behaviour of one monitor:
|
||||
- while the average is in alarm, sends the first message immediately, then up
|
||||
to `n_msg` messages total, spaced at least `msg_delay_s` apart, then stays
|
||||
silent
|
||||
- once the average returns to normal, it sends **one** recovery ("RESOLVED")
|
||||
message and resets the message counter
|
||||
- once the average returns to normal, it resets the message counter and — if
|
||||
at least one alarm message was sent this episode — sends **one** recovery
|
||||
("RESOLVED") message
|
||||
- unreadable / non-numeric reads are logged and skipped (they do not enter the
|
||||
average and never trigger an alarm)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user