fixing a typo in EPICS2SMS.sh

This commit is contained in:
2025-12-12 19:25:52 +01:00
parent ac1f9648c1
commit 62249261a2
+12 -12
View File
@@ -3,14 +3,14 @@
# --- configuration ---------------------------------------------------------
# PV_NAME="X12SA-FE-VMMG-0010:PLC_RELAY-D" # a PV with states "ON"/"OFF"
PV_NAME="AGEBD-PARAMS:INJECTION-RATE" # a PV with numerical value + units
PHONE_NUMBER="0041793083005" # the phone number(s), space separated
EMAIL="andreas.menzel@psi.ch" # the email address(es), space separated
POLL_INTERVAL=5 # seconds between polls while Running
ERROR_INTERVAL=60 # seconds between polls while NOT Running
PV_NAME="AGEBD-PARAMS:INJECTION-RATE" # a PV with numerical value + units
PHONE_NUMBER="0041793083005" # the phone number(s), space separated
EMAIL="andreas.menzel@psi.ch" # the email address(es), space separated
POLL_INTERVAL=5 # seconds between polls while Running
ERROR_INTERVAL=60 # seconds between polls while NOT Running
send_sms() {
local numbers="$1 $2" # to combine PHONE_NUMBER and EMAIL
local numbers="$1 $2" # to combine PHONE_NUMBER and EMAIL
local message="$3"
local email_hdr=""
@@ -32,19 +32,19 @@ send_sms() {
printf "%s" "$email_hdr"
printf "\n"
printf "%s\n" "$message_with_date"
# } | cat # for testing
} | /usr/sbin/sendmail -t # for production
# } | cat # for testing
} | /usr/sbin/sendmail -t # for production
}
# --- main loop ------------------------------------------------------------
alert_sent=0 # 0 = no alert sent for current outage, 1 = already sent
alert_sent=0 # 0 = no alert sent for current outage, 1 = already sent
echo "[$(date)] Starting EPICS monitor for PV '$PV_NAME' ..."
while true; do
# Get PV value as a plain string; adjust flags if needed (-S for string)
# caget "$PV_NAME" # only for debugging
# caget "$PV_NAME" # only for debugging
value=$(caget -noname -nounit "$PV_NAME" 2>/dev/null)
status=$?
@@ -54,8 +54,8 @@ while true; do
value="UNAVAILABLE"
fi
# if [[ "$value" == "\"ON\"" ]]; then # for a PV with states "ON"/"OFF"
if awk "BEGIN { exit !($value > 0) }"; then # to check whether value is smaller than zero
# if [[ "$value" == "\"ON\"" ]]; then # for a PV with states "ON"/"OFF"
if awk "BEGIN { exit !($value < 0) }"; then # to check whether value is smaller than zero
# System is OK again
if [[ $alert_sent -eq 1 ]]; then
echo "[$(date)] PV '$PV_NAME' back to Running."