This commit is contained in:
2023-12-11 15:50:37 -06:00
parent 552bd90054
commit 7b1d7a2f29

View File

@@ -8,7 +8,7 @@ source /opt/idssys/defaults/default.inc
source /opt/idssys/powerwall/defaults.inc
source ${PW_FOLDER}/settings.conf
# TEST=true
TEST=true
shopt -s lastpipe
@@ -370,14 +370,14 @@ CHECKTEMP_SERVICE(){
Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Back to NORMAL ${GAUGE} - Previous ${GAUGE}: ${last_temp[${SENSOR}]}${GAUGESH}" >> ${logtemp}
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - ${SENSOR} - Back to NORMAL ${GAUGE}" >> ${PW_LOGFILE}
# [ "$(compgen -G "${PW_TMPFOLDER}/shutdown.*")" != "" ] && rm -f ${PW_TMPFOLDER}/shutdown.*
# [ "$(compgen -G "${PW_TMPFOLDER}/power.*.off")" != "" ] && rm -f ${PW_TMPFOLDER}/power.*.off
elif [ "${last_temp[${SENSOR}]}" == "1" ]; then
# SENDNOTICE "${SENSOR} TEMP NORMAL" "Service Startup
# NORMAL TEMP: ${temp_f}${GAUGESH}"
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Service Startup - NORMAL ${GAUGE}" >> ${logtemp}
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - ${SENSOR} - Service Startup" >> ${PW_LOGFILE}
# [ "$(compgen -G "${PW_TMPFOLDER}/shutdown.*")" != "" ] && rm -f ${PW_TMPFOLDER}/shutdown.*
# [ "$(compgen -G "${PW_TMPFOLDER}/power.*.off")" != "" ] && rm -f ${PW_TMPFOLDER}/power.*.off
elif [ "${relog}" == "1" ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Normal ${GAUGE}" >> ${logtemp}
@@ -871,11 +871,15 @@ BATT VOLTAGE: ${BATTVOLT}'volts"
echo "($(date +'%Y-%m-%d %H:%M:%S')) - Input: ${INPUTACV}'volts - 'Check Power' Service Startup - Normal voltage detected" >> ${PW_LOGPOWER}
fi
fi
if [ ! -f ${PW_TMPFOLDER}/power.ac.good ]; then
if [ ! -f ${PW_TMPFOLDER}/power.ac.good ]; then
if [ -f ${PW_TMPFOLDER}/power.sys.off ]
fi
rm -f ${PW_TMPFOLDER}/power.ac.*
touch ${PW_TMPFOLDER}/power.ac.good
fi
# UPDATE APC-PDU LINE TO LINE VOLTAGE
CURRENT_VOLTAGE=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.1.15.0 | sed 's/.*: //')
SET_VOLTAGE=`echo "scale=2; $(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_UPS_IP} iso.3.6.1.4.1.850.1.1.3.1.3.3.2.1.2.1.1 | sed 's/.*: //')/10" | bc | awk '{print int($1+0.5)}'`
@@ -888,7 +892,7 @@ BATT VOLTAGE: ${BATTVOLT}'volts"
SENDNOTICE "POWER ALERT - POWER OFF/LOW!!" "Power off or low voltage detected
VOLTAGE: ${INPUTACV}'volts
BATT VOLTAGE: ${BATTVOLT}'volts" 1
rm -f ${PW_TMPFOLDER}/power.ac.good
rm -f ${PW_TMPFOLDER}/power.ac.good
touch ${PW_TMPFOLDER}/power.ac.low
fi
if [ ! -f ${PW_TMPFOLDER}/power.ac.conserve ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.ac.low)) -ge 120 ]; then
@@ -1236,12 +1240,12 @@ SHUTDOWN_CRIT(){
fi
}
SHUTDOWN_OFFSITE(){
if [ ! -f ${PW_TMPFOLDER}/shutdown.offsite ]; then
if [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
SENDNOTICE "OFFSITE SHUTDOWN - POWER OFF/LOW!!" "Shutting down offsite host(s)" 1
for offsite_host in "${PW_OFFSITEHOSTS[@]}"; do
SHUTDOWN_SERVER ${offsite_host} &
done
touch ${PW_TMPFOLDER}/shutdown.offsite
touch ${PW_TMPFOLDER}/power.offsite.off
fi
}
@@ -1661,8 +1665,8 @@ SHUTDOWN_SERVERS(){
fi
elif [ "${1^^}" == "OFFSITE" ]; then
if [ ! -f ${PW_TMPFOLDER}/shutdown.offsite ]; then
touch ${PW_TMPFOLDER}/shutdown.offsite
if [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
touch ${PW_TMPFOLDER}/power.offsite.off
if [ "${2}" != "maintenance" ]; then
MSG="Disabling CLS in vCenter"
@@ -1971,7 +1975,14 @@ HOSTMGMT(){
fi
elif [ "${MODE}" == "power" ]; then
HOSTPOWER ${HOST} ${POWER}
if [ "${HOST^^}" == "ALL" ] || [ "${HOST^^}" == "MAINSITE" ] || [ "${HOST^^}" == "OFFSITE" ] || [ "${HOST^^}" == "MAIN" ] || [ "${HOST^^}" == "SYS" ]; then
var=PW_${HOST^^}HOSTS[@]; v=1
for vhost in "${!var}"; do
HOSTPOWER ${vhost} ${POWER}
done
else
HOSTPOWER ${HOST} ${POWER}
fi
fi
echo
}