From 24ac9d48d24795507a621ef8ca78db1b48877958 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 12 May 2023 21:34:50 -0500 Subject: [PATCH] update --- defaults.inc | 1 + powerwall.sh | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/defaults.inc b/defaults.inc index 8b669da5..eaefd255 100755 --- a/defaults.inc +++ b/defaults.inc @@ -15,6 +15,7 @@ min_battvolt_sys=47 FOLDER='/opt/idssys/powerwall' logfile=${FOLDER}/logfile +logacv=${FOLDER}/log-acv declare -A TEMP_THRESHOLDS TEMP_THRESHOLDS['ServerRoomTH']="83,88,95" diff --git a/powerwall.sh b/powerwall.sh index fd31fef3..bdcff3e7 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -138,39 +138,39 @@ CHECKACV_SERVICE(){ datetime=`date +'%Y-%m-%d %H:%M:%S'` if [ ${INPUTACV} -ge ${min_acvolt} ]; then if [ $voltstatus -eq 3 ]; then - echo "($datetime) back to normal voltage: ${INPUTACV}V" >> ${logfile} + echo "($datetime) back to normal voltage: ${INPUTACV}V" >> ${log-acv} echo -e "($datetime) Normal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "POWER NOMINAL AGAIN" $email_alert - echo "($datetime) alert sent" >> ${logfile} + echo "($datetime) alert sent" >> ${log-acv} battstatus=0 else - [ $VERBOSE = true ] && echo "($datetime) normal voltage: ${INPUTACV}V" >> ${logfile} + [ $VERBOSE = true ] && echo "($datetime) normal voltage: ${INPUTACV}V" >> ${log-acv} if [ $voltstatus -eq 0 ]; then echo -e "($datetime) Service Startup\nNormal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "Power Nominal" $email_alert - echo "($datetime) alert sent - service start" >> ${logfile} + echo "($datetime) alert sent - service start" >> ${log-acv} fi fi voltstatus=1 else - echo "($datetime) LOW voltage: ${INPUTACV}V" >> ${logfile} + echo "($datetime) LOW voltage: ${INPUTACV}V" >> ${log-acv} if [ $voltstatus -lt 3 ]; then echo -e "($datetime) Power off or low voltage detected\nVOLTAGE: ${INPUTACV}V\nBATT VOLTAGE: ${BATTVOLT}V" | mail -s "POWER ALERT - LOW POWER!!" $email_alert - echo "($datetime) alert sent" >> ${logfile} + echo "($datetime) alert sent" >> ${log-acv} last_battvolt=$BATTVOLT fi voltstatus=3 if [ ${BATTVOLT%.*} -lt ${min_battvolt} ] && [ ${BATTVOLT%.*} -gt ${min_battvolt_sys} ]; then - echo "($datetime) LOW BATTERY voltage: ${BATTVOLT}V" >> ${logfile} + echo "($datetime) LOW BATTERY voltage: ${BATTVOLT}V" >> ${log-acv} if [ $battstatus -lt 2 ]; then - echo "($datetime) Shutting down main servers..." >> ${logfile} + echo "($datetime) Shutting down main servers..." >> ${log-acv} echo -e "($datetime) Battery Voltage LOW: ${BATTVOLT}V\nShutting down main servers" | mail -s "BATT-VOLT LOW: SHUTDOWN SERVERS" $email_alert SHUTDOWN_SERVERS MAIN battstatus=2 fi elif [ ${BATTVOLT%.*} -le ${min_battvolt_sys} ]; then - echo "($datetime) SYSTEM LOW BATTERY voltage: ${BATTVOLT}V" >> ${logfile} + echo "($datetime) SYSTEM LOW BATTERY voltage: ${BATTVOLT}V" >> ${log-acv} if [ $battstatus -lt 3 ]; then - echo "($datetime) Shutting down all remaining servers..." >> ${logfile} + echo "($datetime) Shutting down all remaining servers..." >> ${log-acv} echo -e "($datetime) Battery Voltage REALLY LOW: ${BATTVOLT}V\nShutting down all servers" | mail -s "BATT-VOLT REALLY LOW: SHUTDOWN SERVERS" $email_alert SHUTDOWN_SERVERS SYS curl --data "cmd=PWRoff" http://10.10.0.61/cmd @@ -179,7 +179,7 @@ CHECKACV_SERVICE(){ fi else - [ $VERBOSE = true ] && echo "($datetime) Battery Voltage: ${BATTVOLT}V" >> ${logfile} + [ $VERBOSE = true ] && echo "($datetime) Battery Voltage: ${BATTVOLT}V" >> ${log-acv} battstatus=1