This commit is contained in:
2023-11-05 21:08:26 -06:00
parent d7fe65b0d8
commit 3e212c3077
2 changed files with 20 additions and 8 deletions

View File

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

View File

@@ -24,7 +24,7 @@ if [ "$TEST" = "true" ]; then
fi
SENDNOTICE2(){
SENDNOTICE(){
TITLE=${1}
MESSAGE="${2}
@@ -46,7 +46,10 @@ $(date)"
}
PWO_START(){
SENDNOTICE2 "OFFSITE POWER MONITOR" "Service starting"
SENDNOTICE "OFFSITE POWER MONITOR" "Service starting
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
while true; do
upsinfo=$(upsc CP1500PFCLCD)
if [ "$(echo "${upsinfo}" | grep 'input.voltage:' | sed 's/.*: //')" != "" ]; then
@@ -59,7 +62,8 @@ PWO_START(){
if [ -f ${PW_TMPFOLDER}/power.offsite.ac.low ]; then
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.
SENDNOTICE "OFFSITE POWER" "Power restored! Will wait 5mins before turning host(s) back on.
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
fi
@@ -72,7 +76,10 @@ VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
elif [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.restored)) -gt $(echo "scale=2; ${WAIT_TO_POWER_SERVERS}*60" | bc) ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${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"
SENDNOTICE "OFFSITE HOST POWER" "Powering offsite host(s) back on after power outage
BATT CAPACITY: ${OFFSITE_BATT_CAP}'(percent)
BATT RUNTIME: ${OFFSITE_BATT_RUNTIME}'Mins"
[ "$TEST" != "true" ] && 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
@@ -84,7 +91,8 @@ VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
else
if [ ! -f ${PW_TMPFOLDER}/power.offsite.ac.low ] || [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.ac.low)) -gt 240 ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Battery - Powering LOW/OFF!" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE POWER - POWER OFF/LOW!!" "Power off or low voltage detected
SENDNOTICE "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
@@ -92,7 +100,10 @@ BATT RUNTIME: ${OFFSITE_BATT_RUNTIME}'Mins" 1
if [ ${OFFSITE_BATT_CAP%.*} -lt ${SHUTDOWNSERVERS_AT_LOAD} ] && [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Battery - Powering Down Hosts!" >> ${PW_LOGFILE}
SENDNOTICE2 "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage" 1
SENDNOTICE "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage
BATT CAPACITY: ${OFFSITE_BATT_CAP}'(percent)
BATT RUNTIME: ${OFFSITE_BATT_RUNTIME}'Mins" 1
touch ${PW_TMPFOLDER}/power.offsite.off
[ "$TEST" != "true" ] && ssh root@10.2.1.11 /vmfs/volumes/652c94ef-ee49895b-365d-00109b3fea40/.SCRIPTS/esxi-shutdown2.sh &
fi
@@ -100,7 +111,8 @@ BATT RUNTIME: ${OFFSITE_BATT_RUNTIME}'Mins" 1
fi
else
SENDNOTICE2 "NUT DRIVER FAILURE" "Restarting NUT service"
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Battery - Restarting NUT service" >> ${PW_LOGFILE}
SENDNOTICE "NUT DRIVER FAILURE" "Restarting NUT service"
/usr/local/etc/rc.d/nut.sh restart
sleep 10s
fi