#!/bin/sh # script to check chilled water temperature status and send out sms messages # log file location logdir=MAINPROGROOT/log # sms script and number directory DISPATCH=MAINPROGROOT/scripts/dispatchsms.sh smsdir=MAINPROGROOT/sms # Temperature switch tresholds for set/reset waring in multiples of 1/100 C WARNTEMP=850 RETURNTEMP=800 # warning file. This file gets created when the chilled water warning state # has been reached. It contains the number of calls it has been checked. warningfile=$smsdir/chillwarning # read latest temperature at monitoring location (AHU1 and AHU2) b=($(tail -n 1 $logdir/heat_AHU2.log)) b1=($(tail -n 1 $logdir/heat_AHU1.log)) temptimes100=$(echo ${b1[6]} |sed -e "s%\.%%") if [ $temptimes100 -gt $WARNTEMP ]; then if [ -e $warningfile ]; then # we have a warning file already. increase its visit count lst=$(cat $warningfile); lst=$(($lst+1)) echo $lst >$warningfile # Send a reminder every 15 minutes if situation persists if (( $(($lst%15)) == 0 )); then $DISPATCH "AHU WARNING REMINDER\nSituation persists for $lst minutes.\nCHWS at ${b1[6]}C\nCHWR at ${b1[5]}C\nAHU1 power ${b1[4]}kW\nAHU2 power ${b[4]}kW" fi else # This is a fresh warning. Create a warning file and send an SMS echo "0" >$warningfile $DISPATCH "CQT AHU WARNING:\nChilled water supply temp exceeds 8.5C.\nCHWS at ${b1[6]}C\nCHWR at ${b1[5]}C\nAHU1 power ${b1[4]}kW\nAHU2 power ${b[4]}kW" fi elif [ $temptimes100 -lt $RETURNTEMP ]; then if [ -e $warningfile ]; then # We have recovered. remove warning file, send ack sms rm -f $warningfile $DISPATCH "CQT AHU chilled water back to normal.\nCHWS at ${b1[6]}C\nCHWR at ${b1[5]}C\nAHU1 power ${b1[4]}kW\nAHU2 power ${b[4]}kW" fi fi