From 3e212c307703d9e18e195f507a2be7fd39df38f2 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 5 Nov 2023 21:08:26 -0600 Subject: [PATCH] update --- defaults.inc | 2 +- offsite-power-check.sh | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/defaults.inc b/defaults.inc index d6a88611..f37e9c21 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,5 +1,5 @@ -VERS='2.3.180-11052023' +VERS='2.3.190-11052023' noheader=' update service dailytemp ' diff --git a/offsite-power-check.sh b/offsite-power-check.sh index 6cbbfe03..66b03e41 100755 --- a/offsite-power-check.sh +++ b/offsite-power-check.sh @@ -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