From 59d0eb9f6a9f5908aeca77343f3a81a4c6081a54 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 11 Dec 2023 16:49:13 -0600 Subject: [PATCH] update --- defaults.inc | 2 +- powerwall.sh | 112 ++++++++++++++++++++++++++------------------------- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/defaults.inc b/defaults.inc index 44aed720..e8913b74 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,5 +1,5 @@ -VERS='2.4.17-12112023' +VERS='2.4.18-12112023' noheader=' update service dailytemp ' hc_cw=60 diff --git a/powerwall.sh b/powerwall.sh index 2e0c0c2b..0eed9be9 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -312,59 +312,8 @@ CHECKTEMP_SERVICE(){ echo ${PW_THRESHOLDS[${SENSOR}]} | cut -d',' -f 3 | read temp_crit_sys fi - [ ! "${last_temp[${SENSOR}]}" ] && last_temp[${SENSOR}]=${temp_f} - temp_diff=`echo "scale=2; ${last_temp[${SENSOR}]}-${temp_f}" | bc` - [ $(bc -l <<< "${temp_diff} < 0") -eq 1 ] && temp_diff=`echo "scale=2; ${temp_diff}*-1" | bc` - - if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then - touch ${PW_TMPFOLDER}/temp.warn - if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then - SENDNOTICE "${SENSOR} ${GAUGE} WARNING" "WARNING ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 - last_temp[${SENSOR}]=${temp_f} - echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - WARNING ${GAUGE} - (Difference of ${temp_diff}')" >> ${logtemp} - # iDS-vMS-Offsite Fan Issue Workaround - if [ "${PW_HOST_IDRACS[${SENSORa}]}" == "10.2.1.21" ] && [ ${FanSpeed} -ne 80 ]; then - SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} SERVER WARM" "Setting fan speeds to 80%25" 1 - ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" raw 0x30 0x30 0x01 0x00 >/dev/null 2>&1 - ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" raw 0x30 0x30 0x02 0xff 0x50 >/dev/null 2>&1 - fi - fi - - elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit_sys}") -eq 1 ]; then - touch ${PW_TMPFOLDER}/temp.crit - if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then - SENDNOTICE "${SENSOR} ${GAUGE} CRITICAL" "CRITICAL ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 - echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - CRITICAL - (Difference of ${temp_diff}${GAUGESH})" >> ${logtemp} - echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSOR} - ${temp_f}${GAUGESH} - CRITICAL ${GAUGE} - (Difference of ${temp_diff}')" >> ${PW_LOGFILE} - last_temp[${SENSOR}]=${temp_f} - - if [ "${SENSOR}" == "ServerRoomTH" ] && [ ! -f touch ${PW_TMPFOLDER}/temp.crit ]; then - touch ${PW_TMPFOLDER}/temp.critsys - SHUTDOWN_MAIN ${SENSOR} & - echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Shutting down MAIN servers" >> ${logtemp} - - # elif [ ! -f ${PW_TMPFOLDER}/power.${SENSORa}.off ]; then - # SENDNOTICE "${SENSORa} TEMP CRITICAL" "Host system and VMs shutting down!!" 1 - # SHUTDOWN_SERVER ${SENSORa} & - # touch ${PW_TMPFOLDER}/power.${SENSORa}.off - - fi - fi - elif [ $(bc -l <<< "${temp_f} >= ${temp_crit_sys}") -eq 1 ]; then - if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then - SENDNOTICE "${SENSOR} TEMP CRITICAL" "SYSTEM CRITICAL ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 - echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - SYSTEM CRITICAL - (Difference of ${temp_diff})" >> ${logtemp} - echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - ${SENSOR} - CRITICAL ${GAUGE} SYSTEM - (Difference of ${temp_diff}')" >> ${PW_LOGFILE} - last_temp[${SENSOR}]=${temp_f} - if [ ! -f touch ${PW_TMPFOLDER}/temp.critsys ]; then - touch ${PW_TMPFOLDER}/temp.critsys - [ "${SENSOR}" == "ServerRoomTH" ] && SHUTDOWN_SYS ${SENSOR} TEMP & - SHUTDOWN_CRIT ${SENSOR} & - echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Sending system shutdown signals, if applicable. Check main Powerwall Logs" >> ${logtemp} - fi - fi - else + if [ $(bc -l <<< "${temp_f} < ${temp_warn}") -eq 1 ]; then if [ $(bc -l <<< "${last_temp[${SENSOR}]} > 1") -eq 1 ]; then SENDNOTICE "${SENSOR} BACK TO NORMAL" "NORMAL TEMP: ${temp_f}${GAUGESH} Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}" @@ -402,8 +351,62 @@ Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}" fi fi fi - fi + + else + [ ! "${last_temp[${SENSOR}]}" ] && last_temp[${SENSOR}]=${temp_f} + temp_diff=`echo "scale=2; ${last_temp[${SENSOR}]}-${temp_f}" | bc` + [ $(bc -l <<< "${temp_diff} < 0") -eq 1 ] && temp_diff=`echo "scale=2; ${temp_diff}*-1" | bc` + + if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then + touch ${PW_TMPFOLDER}/temp.warn + if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then + SENDNOTICE "${SENSOR} ${GAUGE} WARNING" "WARNING ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 + last_temp[${SENSOR}]=${temp_f} + echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - WARNING ${GAUGE} - (Difference of ${temp_diff}')" >> ${logtemp} + + # iDS-vMS-Offsite Fan Issue Workaround + if [ "${PW_HOST_IDRACS[${SENSORa}]}" == "10.2.1.21" ] && [ ${FanSpeed} -ne 80 ]; then + SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} SERVER WARM" "Setting fan speeds to 80%25" 1 + ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" raw 0x30 0x30 0x01 0x00 >/dev/null 2>&1 + ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" raw 0x30 0x30 0x02 0xff 0x50 >/dev/null 2>&1 + fi + fi + elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit_sys}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then + SENDNOTICE "${SENSOR} ${GAUGE} CRITICAL" "CRITICAL ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 + echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - CRITICAL - (Difference of ${temp_diff}${GAUGESH})" >> ${logtemp} + echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSOR} - ${temp_f}${GAUGESH} - CRITICAL ${GAUGE} - (Difference of ${temp_diff}')" >> ${PW_LOGFILE} + last_temp[${SENSOR}]=${temp_f} + + if [ "${SENSOR}" == "ServerRoomTH" ] && [ ! -f touch ${PW_TMPFOLDER}/temp.crit ]; then + touch ${PW_TMPFOLDER}/temp.crit + SHUTDOWN_MAIN ${SENSOR} & + echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Shutting down MAIN servers" >> ${logtemp} + + # elif [ ! -f ${PW_TMPFOLDER}/power.${SENSORa}.off ]; then + # SENDNOTICE "${SENSORa} TEMP CRITICAL" "Host system and VMs shutting down!!" 1 + # SHUTDOWN_SERVER ${SENSORa} & + # touch ${PW_TMPFOLDER}/power.${SENSORa}.off + + fi + fi + elif [ $(bc -l <<< "${temp_f} >= ${temp_crit_sys}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_diff} > 1") -eq 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then + SENDNOTICE "${SENSOR} TEMP CRITICAL" "SYSTEM CRITICAL ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1 + echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - SYSTEM CRITICAL - (Difference of ${temp_diff})" >> ${logtemp} + echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - ${SENSOR} - CRITICAL ${GAUGE} SYSTEM - (Difference of ${temp_diff}')" >> ${PW_LOGFILE} + last_temp[${SENSOR}]=${temp_f} + if [ ! -f touch ${PW_TMPFOLDER}/temp.critsys ]; then + touch ${PW_TMPFOLDER}/temp.critsys + [ "${SENSOR}" == "ServerRoomTH" ] && SHUTDOWN_SYS ${SENSOR} TEMP & + SHUTDOWN_CRIT ${SENSOR} & + echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Sending system shutdown signals, if applicable. Check main Powerwall Logs" >> ${logtemp} + fi + fi + fi + fi + [ -f ${PW_TMPFOLDER}/${SENSOR}.insert ] && lastinsert=$(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}.insert)) || lastinsert=100000 if [ "$(compgen -G "${PW_TMPFOLDER}/temp.*")" != "" ] || [ "$(compgen -G "${PW_TMPFOLDER}/power.ac.*")" != "" ] || [ "$(compgen -G "${PW_TMPFOLDER}/power.dc.*")" != "" ]; then wait=60 @@ -869,10 +872,11 @@ VOLTAGE: ${INPUTACV}'volts BATT VOLTAGE: ${BATTVOLT}'volts" echo "($(date +'%Y-%m-%d %H:%M:%S')) - Input: ${INPUTACV}'volts - 'Check Power' Service Startup - Normal voltage detected" >> ${PW_LOGFILE} echo "($(date +'%Y-%m-%d %H:%M:%S')) - Input: ${INPUTACV}'volts - 'Check Power' Service Startup - Normal voltage detected" >> ${PW_LOGPOWER} + rm -f ${PW_TMPFOLDER}/power.ac.start fi fi if [ ! -f ${PW_TMPFOLDER}/power.ac.good ]; then - + if [ -f ${PW_TMPFOLDER}/power.sys.off ] || [ -f ${PW_TMPFOLDER}/power.main.off ] || [ -f ${PW_TMPFOLDER}/power.ac.conserve ]; then SENDNOTICE "HOSTS POWER" "Power restored! Will wait 3'mins before turning host(s) back on" touch ${PW_TMPFOLDER}/.power.restored