This commit is contained in:
2023-11-05 18:47:14 -06:00
parent d46663efae
commit 7f78e0d7fa
2 changed files with 14 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
VERS='2.3.170-11052023'
VERS='2.3.180-11052023'
noheader=' update service dailytemp '

View File

@@ -43,33 +43,36 @@ START(){
if [ ${OFFSITE_VOLTIN%.*} -gt 105 ]; then
if [ -f ${PW_TMPFOLDER}/power.offsite.ac.low ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - Offsite Back to Normal Voltage" >> ${PW_LOGPOWER}
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - OFFSITE POWER NOMINAL AGAIN" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE POWER NOMINAL AGAIN" "Normal voltage detected
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
if [ -f ${PW_TMPFOLDER}/power.offsite.off ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Battery - Offsite Power Restored" >> ${PW_LOGPOWER}
SENDNOTICE2 "OFFSITE POWER" "Power restored! Will wait 5mins before turning host(s) back on.
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
fi
rm -f ${PW_TMPFOLDER}/power.offsite.ac.*
fi
if [ -f ${PW_TMPFOLDER}/power.offsite.off ]; then
if [ ! -f ${PW_TMPFOLDER}/power.offsite.restored ]; then
touch ${PW_TMPFOLDER}/power.offsite.restored
elif [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.restored)) -gt 30 ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_BATT_CAP}% Battery - Powering Hosts Back on After Power Outage!" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE HOST POWER" "Powering offsite host(s) back on after power was restored"
ipmitool -I lanplus -H 10.2.1.21 -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power on
elif [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.restored)) -gt 300 ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_BATT_CAP}% Battery - Powering Hosts ON After Power Outage" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE HOST POWER" "Powering offsite host(s) back on after power outage"
ipmitool -I lanplus -H 10.2.1.21 -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power on &
rm -f ${PW_TMPFOLDER}/power.offsite.*
fi
fi
[ $(expr `date +%s` - $(stat -f %m ${PW_LOGPOWER})) -gt 300 ] && echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Batt - Normal" >> ${PW_LOGPOWER}
else
if [ ! -f ${PW_TMPFOLDER}/power.offsite.ac.low ] || [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.ac.low)) -gt 240 ]; then
SENDNOTICE2 "OFFSITE POWER ALERT - POWER OFF/LOW!!" "Power off or low voltage detected
SENDNOTICE2 "OFFSITE POWER - POWER OFF/LOW!!" "Power off or low voltage detected
BATT CAPACITY: ${OFFSITE_BATT_CAP}'(percent)
BATT RUNTIME: ${OFFSITE_BATT_RUNTIME}'Mins" 1
touch ${PW_TMPFOLDER}/power.offsite.ac.low
fi
if [ ${OFFSITE_BATT_CAP%.*} -lt 99 ] && [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
if [ ${OFFSITE_BATT_CAP%.*} -lt 70 ] && [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_BATT_CAP}% Battery - Powering Down Hosts!" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage" 1
touch ${PW_TMPFOLDER}/power.offsite.off