This commit is contained in:
2024-11-17 11:54:26 -06:00
parent de9efe0255
commit 6ed630c319
2 changed files with 54 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERS='2.8.6-11172024'
VERS='2.8.7-11172024'
noheader=' update service dailytemp confsync -r -report test '

View File

@@ -1,6 +1,6 @@
GET_HOST_FANSPEED(){
if [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]} ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})) -lt 600 ] && ([ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]}.set ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})) -lt $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]}.set)) ]); then
FanSpeed=$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})
if [ -f ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]} ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})) -lt 600 ] && ([ ! -f ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]}.set ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})) -lt $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]}.set)) ]); then
FanSpeed=$(cat ${PW_TMPFOLDER}/.lastfancheck/${PW_ESXI_HOST_NAMES[${1}]})
else
[[ "${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${1}]}]}" = "10.6."* ]] && ESXI_PASS=${PW_ESXI_PASS_KP} || ESXI_PASS=${PW_ESXI_PASS}
vHOSTFAN=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${PW_RACADM_ACCESS} racadm -r ${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${1}]}]} -u ${PW_ESXI_USER} -p "'${ESXI_PASS}'" getsensorinfo | grep "System Board Fan3" 2>&1)
@@ -396,9 +396,9 @@ CHECKTEMP(){
[ "${avgdays}" != "noavg" ] && fan_average=$(bc <<< "scale=0; $(ROUNDHALVES $(bc <<< "scale=3; $(AVERAGETEMP ${SENSOR} ${avgdays} FanSpeed)/10"))*10/1")
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR} Host Sensors ${idsST[Reset]}${idsCL[White]}[${vHOSTiDRACIP}]"
[ "${SENSOR}" == "iDS-vMS-Host6" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"${PW_HOST_IDRACS[iDS-vMS-Host6]}"* ]] && cSENSOR="iDS-vMS-Host7" || cSENSOR=${SENSOR}
if [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${cSENSOR}.gl ]; then
if [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.gl ]; then
FSC="${idsCL[LightGreen]}${idsST[Bold]}"
elif [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${cSENSOR}.set ]; then
elif [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.set ]; then
FSC="${idsCL[LightGreen]}"
else
FSC="${idsCL[LightYellow]}"
@@ -588,26 +588,26 @@ CHECKTEMP(){
if [ "${TTYPE}" == "fans" ]; then
if [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"${PW_HOST_IDRACS[${SENSOR}]}"* ]] && [[ "${sensorname}" = *"Exhaust"* ]]; then
if [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${cSENSOR}.gl ]; then
if [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.gl ]; then
FSC="${idsCL[LightGreen]}"
elif [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${cSENSOR}.set ]; then
elif [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.set ]; then
FSC="${idsCL[Green]}"
else
FSC="${idsCL[LightYellow]}"
fi
# echo -e " Goldilock Zone : ${idsCL[LightGreen]}${ESXI_DEFAULT_EXHAUST_MIN}°F (±${ESXI_FANSPEED_GL_ZONE}°F) ${idsCL[Default]}[ ${idsCL[Green]}${GL_LOW}°F${idsCL[Default]} <--> ${idsCL[LightYellow]}${GL_HIGH}°F${idsCL[Default]} ]"
echo -e " Goldilock Zone : ${idsCL[LightGreen]}${ESXI_DEFAULT_EXHAUST_MIN}°F (±${ESXI_FANSPEED_GL_ZONE}°F)"
echo -e " Last checked : ${idsCL[LightCyan]}$(date -r ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR} "+%m/%d @ %l:%M%p")${idsCL[Default]}"
echo -en " Last set : ${FSC}$(date -r ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set "+%m/%d @ %l:%M%p") "
if [ "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "uu" ]; then
echo -e " Last checked : ${idsCL[LightCyan]}$(date -r ${PW_TMPFOLDER}/.lastfancheck/${SENSOR} "+%m/%d @ %l:%M%p")${idsCL[Default]}"
echo -en " Last set : ${FSC}$(date -r ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set "+%m/%d @ %l:%M%p") "
if [ "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "uu" ]; then
echo -e "${idsCL[LightRed]}\u25B2 ${idsCL[Default]}"
elif [ "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "u" ]; then
elif [ "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "u" ]; then
echo -e "${idsCL[Magenta]}\u25B2 ${idsCL[Default]}"
elif [ "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "dd" ]; then
elif [ "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "dd" ]; then
echo -e "${idsCL[LightGreen]}\u25BC ${idsCL[Default]}"
elif [ "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "d" ]; then
elif [ "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "d" ]; then
echo -e "${idsCL[LightCyan]}\u25BC ${idsCL[Default]}"
elif [ "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "m" ]; then
elif [ "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSOR}.set | cut -d'~' -f 2)" == "m" ]; then
echo -e "${idsCL[LightCyan]}\u2720 ${idsCL[Default]}"
else
echo -e "${idsCL[Default]}"
@@ -813,7 +813,7 @@ CHECKTEMP_SERVICE(){
SCAN_THREADS=4
SENDTEMPS "TEMP Service Startup" &
[ ! -d ${PW_TMPFOLDER}/.local.lastfancheck ] && mkdir ${PW_TMPFOLDER}/.local.lastfancheck #|| rm -f ${PW_TMPFOLDER}/.local.lastfancheck/*.set
[ ! -d ${PW_TMPFOLDER}/.lastfancheck ] && mkdir ${PW_TMPFOLDER}/.lastfancheck
[ ! -d ${PW_TMPFOLDER}/.lastinsert ] && mkdir ${PW_TMPFOLDER}/.lastinsert
[ -d ${PW_TMPFOLDER}/.lasttemp ] && rm -Rf ${PW_TMPFOLDER}/.lasttemp
mkdir ${PW_TMPFOLDER}/.lasttemp
@@ -845,8 +845,8 @@ CHECKTEMP_SERVICE(){
if [ "${tsensor}" != "*" ]; then
rm -f ${sensor}
((s_count++))
if [ -f ${PW_TMPFOLDER}/${tsensor}.down ] && [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${tsensor}.set ] && [ "${PW_SENSOR_TYPE[${tsensor}]}" == "esxi" ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${tsensor}.set)) -ge 900 ]; then
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/${tsensor}*
if [ -f ${PW_TMPFOLDER}/${tsensor}.down ] && [ -f ${PW_TMPFOLDER}/.lastfancheck/${tsensor}.set ] && [ "${PW_SENSOR_TYPE[${tsensor}]}" == "esxi" ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${tsensor}.set)) -ge 900 ]; then
rm -f ${PW_TMPFOLDER}/.lastfancheck/${tsensor}*
fi
fi
@@ -896,7 +896,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
t=1
####### Grab Fan Speeds #######
# if [ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ] && ([ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa} ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa})) -ge 60 ]); then
# if [ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ] && ([ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa} ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa})) -ge 60 ]); then
if [ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ]; then
# vHOSTFAN=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.12.1.6.1.3 -O vq)
vHOSTFAN=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${PW_RACADM_ACCESS} racadm -r ${PW_HOST_IDRACS[${SENSORa}]} -u ${PW_ESXI_USER} -p "'${ESXI_PASS}'" getsensorinfo | grep "System Board Fan3" 2>&1)
@@ -908,7 +908,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
else
FanSpeed=$(echo ${vHOSTFAN} | awk '/ / {print $8}' | sed -e 's/%//g')
fi
echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}
echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}
else
FanSpeed=''
fi
@@ -1026,8 +1026,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
fi
rm -f ${PW_TMPFOLDER}/${SENSOR}*
fi
if [ "${SENSORa}" == "iDS-vMS-Host6" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"10.10.2.26"* ]] && [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host6.set ]; then
[ -f ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host7.set ] && nfs=$(cat ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host7.set | cut -d'~' -f 1) || nfs=35
if [ "${SENSORa}" == "iDS-vMS-Host6" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"10.10.2.26"* ]] && [ ! -f ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host6.set ]; then
[ -f ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host7.set ] && nfs=$(cat ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host7.set | cut -d'~' -f 1) || nfs=35
SET_ESXI_FANSPEED ${nfs} ${SENSORa} >/dev/null 2>&1 &
fi
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "cpu" ]; then
@@ -1061,9 +1061,9 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
##### ESXI FAN CONTROL #####
elif [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"${PW_HOST_IDRACS[${SENSORa}]}"* ]] && [[ "${vSENSOR}" = *"Exhaust"* ]] && [ "${FanSpeed}" != "" ]; then
if [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.chkset ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.chkset)) -ge 300 ]; then
if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.chkset ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.chkset)) -ge 300 ]; then
if [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
NEW_FanSpeed=$(GET_DEFAULT_FANSPEED ${SENSORa} ${FanSpeed})
SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FanSpeed Control" "Re-enabling Host Fan control to Powerwall. Setting fans back to defaults: ${NEW_FanSpeed}%"
ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${ESXI_PASS}" raw 0x30 0x30 0x01 0x00 >/dev/null 2>&1
@@ -1072,39 +1072,39 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
fi
### GOLDILOCK ZONE ###
if ((( $(bc <<< "${temp_f} >= ${GL_LOW}") )) && (( $(bc <<< "${temp_f} <= ${GL_HIGH}") ))) || [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
if [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl ] && [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set)) -ge 3600 ]; then
if ((( $(bc <<< "${temp_f} >= ${GL_LOW}") )) && (( $(bc <<< "${temp_f} <= ${GL_HIGH}") ))) || [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl ] && [ -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set)) -ge 3600 ]; then
# SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FAN CONTROL" "Goldilock Zone Found at ${FanSpeed}%"
echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl
[ "${SENSORa}" == "iDS-vMS-Host7" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"10.10.2.26"* ]] && [ ! -f ${PW_TMPFOLDER}/iDS-vMS-Host6.down ] && echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host6.gl
echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl
[ "${SENSORa}" == "iDS-vMS-Host7" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"10.10.2.26"* ]] && [ ! -f ${PW_TMPFOLDER}/iDS-vMS-Host6.down ] && echo "${FanSpeed}" >| ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host6.gl
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${FanSpeed}% - ${SENSORa} - Goldilock Zone Found (1HR)" >> ${logtemp}
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${FanSpeed}% - ${SENSORa} - Goldilock Zone Found (1HR)" >> ${PW_LOGFOLDER}/esxi-fanspeeds.log
elif [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl)) -ge 3600 ] && [ ${FanSpeed} -gt ${PW_ESXI_MIN_FANSPEED} ] && (( $(bc <<< "${temp_f} < ${ESXI_DEFAULT_EXHAUST_MIN}") )); then
SET_ESXI_FANSPEED $(expr $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - 5) ${SENSORa} 5 >/dev/null 2>&1 &
elif [ -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl)) -ge 3600 ] && [ ${FanSpeed} -gt ${PW_ESXI_MIN_FANSPEED} ] && (( $(bc <<< "${temp_f} < ${ESXI_DEFAULT_EXHAUST_MIN}") )); then
SET_ESXI_FANSPEED $(expr $(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - 5) ${SENSORa} 5 >/dev/null 2>&1 &
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${FanSpeed}% - ${SENSORa} - Goldilock zone, below min for another 1HR, reducing fans by 5" >> ${PW_LOGFOLDER}/esxi-fanspeeds.log
# elif [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl ] && [ ${FanSpeed} -gt ${PW_ESXI_MIN_FANSPEED} ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.gl)) -ge 10800 ]; then
# elif [ -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl ] && [ ${FanSpeed} -gt ${PW_ESXI_MIN_FANSPEED} ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.gl)) -ge 10800 ]; then
# SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FAN CONTROL" "DAAAMMMNN GOLDIE!!!! Decreasing by 5 - ${FanSpeed}% --> $(expr ${FanSpeed} - 5)%"
# echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${FanSpeed}% - ${SENSORa} - DAAAMMMNN GOLDIE!!!! Decreasing by 5 - ${FanSpeed}% --> $(expr ${FanSpeed} - 5)%" >> ${logtemp}
# echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${FanSpeed}% - ${SENSORa} - DAAAMMMNN GOLDIE!!!! Decreasing by 5 - ${FanSpeed}% --> $(expr ${FanSpeed} - 5)%" >> ${PW_LOGFOLDER}/esxi-fanspeeds.log
# SET_ESXI_FANSPEED $(expr $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - 5) ${SENSORa} 5 >/dev/null 2>&1 &
# SET_ESXI_FANSPEED $(expr $(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - 5) ${SENSORa} 5 >/dev/null 2>&1 &
elif [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
elif [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
NEW_FanSpeed=$(GET_DEFAULT_FANSPEED ${SENSORa} ${FanSpeed})
# SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FanSpeed Control" "GOLDILOCK: Defaulting FanSpeeds to ${NEW_FanSpeed}%"
SET_ESXI_FANSPEED ${NEW_FanSpeed} ${SENSORa} >/dev/null 2>&1 &
fi
### INCREASING ###
elif (( $(bc <<< "${temp_f} >= ${ESXI_DEFAULT_EXHAUST_MIN}") )); then
if [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
NEW_FanSpeed=$(expr $(GET_DEFAULT_FANSPEED ${SENSORa} ${FanSpeed}) + 5)
# SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FanSpeed Control" "INCREASE: Defaulting FanSpeeds to ${NEW_FanSpeed}%"
SET_ESXI_FANSPEED ${NEW_FanSpeed} ${SENSORa} 5 >/dev/null 2>&1 &
else
(( $(bc <<< "${temp_f} >= $(expr ${ESXI_DEFAULT_EXHAUST_MIN} + 5)") )) && FAN_INCREASE=10 || FAN_INCREASE=5
NEW_FanSpeed=$(expr $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) + ${FAN_INCREASE})
NEW_FanSpeed=$(expr $(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) + ${FAN_INCREASE})
if [ ${NEW_FanSpeed} -le $(expr ${PW_ESXI_MAX_FANSPEED} + 4) ] && [ ${FanSpeed} -ne ${PW_ESXI_MAX_FANSPEED} ]; then
[ ${NEW_FanSpeed} -gt ${PW_ESXI_MAX_FANSPEED} ] && NEW_FanSpeed=${PW_ESXI_MAX_FANSPEED}
[ ${NEW_FanSpeed} -ge 60 ] && SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} Exhaust Warm" "Increasing fans to ${NEW_FanSpeed}%"
@@ -1113,13 +1113,13 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
fi
### DECREASING ###
else
if [ ! -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
NEW_FanSpeed=$(expr $(GET_DEFAULT_FANSPEED ${SENSORa} ${FanSpeed}) - 5)
# SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FanSpeed Control" "DECREASE: Defaulting FanSpeeds to ${NEW_FanSpeed}%"
SET_ESXI_FANSPEED ${NEW_FanSpeed} ${SENSORa} 5 >/dev/null 2>&1 &
else
(( $(bc <<< "${temp_f} <= $(expr ${ESXI_DEFAULT_EXHAUST_MIN} - 5)") )) && FAN_DECREASE=10 || FAN_DECREASE=5
NEW_FanSpeed=$(expr $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - ${FAN_DECREASE})
NEW_FanSpeed=$(expr $(cat ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set | cut -d'~' -f 1) - ${FAN_DECREASE})
if [ ${NEW_FanSpeed} -ge $(expr ${PW_ESXI_MIN_FANSPEED} - 4) ] && [ ${FanSpeed} -ne ${PW_ESXI_MIN_FANSPEED} ]; then
[ ${NEW_FanSpeed} -lt ${PW_ESXI_MIN_FANSPEED} ] && NEW_FanSpeed=${PW_ESXI_MIN_FANSPEED}
[ ${NEW_FanSpeed} -ge 65 ] && SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} Exhaust Cooling" "Decreasing fans to ${NEW_FanSpeed}%"
@@ -1127,21 +1127,21 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
fi
fi
fi
if [ "${SENSORa}" == "iDS-vMS-Host7" ] && [ -f ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host6.set ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" != *"10.10.2.26"* ]]; then
if [ "${SENSORa}" == "iDS-vMS-Host7" ] && [ -f ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host6.set ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" != *"10.10.2.26"* ]]; then
SENDNOTICE "10.10.2.26 FanSpeed Control" "Resetting Fans back to being Host Controlled"
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host6*
rm -f ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host6*
ipmitool -I lanplus -H 10.10.2.26 -U ${PW_ESXI_USER} -P "${ESXI_PASS}" raw 0x30 0x30 0x01 0x01 >/dev/null 2>&1
fi
touch ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.chkset
touch ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.chkset
fi
elif [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" != *"${PW_HOST_IDRACS[${SENSORa}]}"* ]] && [[ "${vSENSOR}" = *"Exhaust"* ]]; then
if [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ]; then
if [ -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ]; then
SENDNOTICE "${PW_HOST_IDRACS[${SENSORa}]} FanSpeed Control" "Resetting Fans back to being Host Controlled"
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}*
rm -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}*
ipmitool -I lanplus -H ${PW_HOST_IDRACS[${SENSORa}]} -U ${PW_ESXI_USER} -P "${ESXI_PASS}" raw 0x30 0x30 0x01 0x01 >/dev/null 2>&1
if [ "${SENSORa}" == "iDS-vMS-Host7" ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" != *"10.10.2.26"* ]]; then
SENDNOTICE "10.10.2.26 FanSpeed Control" "Resetting Fans back to being Host Controlled"
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/iDS-vMS-Host6*
rm -f ${PW_TMPFOLDER}/.lastfancheck/iDS-vMS-Host6*
ipmitool -I lanplus -H 10.10.2.26 -U ${PW_ESXI_USER} -P "${ESXI_PASS}" raw 0x30 0x30 0x01 0x01 >/dev/null 2>&1
fi
@@ -1424,8 +1424,8 @@ Previous Temp: ${last_temp}${GAUGESH}"
SENDNOTICE "${SENSORa} Sensor ERROR" "ERROR reading sensor data" 1
touch ${PW_TMPFOLDER}/${SENSORa}-error.sent
fi
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ] && [ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set)) -ge 900 ]; then
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/${SENSORa}.set
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ] && [ -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set)) -ge 900 ]; then
rm -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set
fi
fi
fi
@@ -1448,7 +1448,7 @@ SET_ESXI_FANSPEED(){
fan=manual
elif [ "${SET_FanSpeed}" == "${ESXI_DEF_FANSPEED}" ]; then
MSG="Setting Fans back to defaults: ${SET_FanSpeed}%"
elif (( $(bc <<< "${SET_FanSpeed} < $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1)") )); then
elif (( $(bc <<< "${SET_FanSpeed} < $(cat ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1)") )); then
MSG="Decreasing fans to ${SET_FanSpeed}%"
else
MSG="Increasing fans to ${SET_FanSpeed}%"
@@ -1459,23 +1459,23 @@ SET_ESXI_FANSPEED(){
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${fan} - ${SET_HOST} - ${MSG}" >> ${PW_LOGFOLDER}/esxi-fanspeeds.log
if [ "${SET_fanchange}" == "manual" ]; then
echo "${SET_FanSpeed}~m" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set
echo "${SET_FanSpeed}~m" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set
elif [ "${SET_fanchange}" == "" ]; then
echo "${SET_FanSpeed}~" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set
echo "${SET_FanSpeed}~" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set
else
if [ $(bc -l <<< "${SET_FanSpeed} < $(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1)") -eq 1 ]; then
[ "${SET_fanchange}" == "10" ] && echo "${SET_FanSpeed}~dd" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set || echo "${SET_FanSpeed}~d" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set
elif [ $(bc -l <<< "$(cat ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1) < ${SET_FanSpeed}") -eq 1 ]; then
[ "${SET_fanchange}" == "10" ] && echo "${SET_FanSpeed}~uu" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set || echo "${SET_FanSpeed}~u" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set
if [ $(bc -l <<< "${SET_FanSpeed} < $(cat ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1)") -eq 1 ]; then
[ "${SET_fanchange}" == "10" ] && echo "${SET_FanSpeed}~dd" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set || echo "${SET_FanSpeed}~d" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set
elif [ $(bc -l <<< "$(cat ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set | cut -d'~' -f 1) < ${SET_FanSpeed}") -eq 1 ]; then
[ "${SET_fanchange}" == "10" ] && echo "${SET_FanSpeed}~uu" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set || echo "${SET_FanSpeed}~u" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set
else
echo "${SET_FanSpeed}~e" >| ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.set
echo "${SET_FanSpeed}~e" >| ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.set
fi
fi
[ "${SET_HOST}" == "iDS-vMS-Host7" ] && [ ! -f ${PW_TMPFOLDER}/iDS-vMS-Host6.down ] && [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"10.10.2.26"* ]] && SET_ESXI_FANSPEED ${SET_FanSpeed} iDS-vMS-Host6 ${SET_fanchange} >/dev/null 2>&1
[ -f ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.gl ] && rm -f ${PW_TMPFOLDER}/.local.lastfancheck/${SET_HOST}.gl
[ -f ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.gl ] && rm -f ${PW_TMPFOLDER}/.lastfancheck/${SET_HOST}.gl
fi
}
ESXI_FANSPEED_MGMT(){
@@ -1538,7 +1538,7 @@ ESXI_FANSPEED_MGMT(){
echo -en "${idsCL[Yellow]}Setting new FanSpeeds for ${PW_iDRACHOST_SHORTNAMES[${host}]} [${PW_HOST_ADDRESSES[${PW_iDRACHOST_SHORTNAMES[${host}]}]}]: "
if [ ! -f ${PW_TMPFOLDER}/${PW_iDRACHOST_SHORTNAMES[${host}]}.down ]; then
SET_ESXI_FANSPEED ${FANSPEED} ${PW_iDRACHOST_SHORTNAMES[${host}]} manual #>/dev/null 2>&1
rm -f ${PW_TMPFOLDER}/.local.lastfancheck/${PW_iDRACHOST_SHORTNAMES[${host}]}.gl
rm -f ${PW_TMPFOLDER}/.lastfancheck/${PW_iDRACHOST_SHORTNAMES[${host}]}.gl
echo -e "${idsCL[Green]}FanSpeed set to ${FANSPEED}${idsCL[Default]}"
else
echo -e "${idsCL[Yellow]}Skipping, host offline${idsCL[Default]}"