Update powerwall.sh
This commit is contained in:
16
powerwall.sh
16
powerwall.sh
@@ -305,8 +305,8 @@ CHECKTEMP_SERVICE(){
|
||||
|
||||
[ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ] && temp_f=$(echo "scale=2; $temp_c/1" | bc -l) || temp_f=$(echo "scale=2; ${temp_c}*1.8 + 32" | bc)
|
||||
[ "${SENSOR}" == "ServerRoomTH" ] && temp_f=`echo "scale=2; ${temp_f}+${PW_ServerRoomTH_Dev}" | bc`
|
||||
echo "HERE: [${SENSOR}] - ${temp_c} - ${temp_f} - ${temp_warn} - ${temp_crit} - ${temp_crit_sys}"
|
||||
[ ! "${temp_c}" ] || [ ! "${temp_f}" ] || [ ! "${temp_warn}" ] || [ ! "${temp_crit}" ] || [ ! "${temp_crit_sys}" ] && echo "VALUE NOT FOUND"
|
||||
# echo "HERE: [${SENSOR}] - ${temp_c} - ${temp_f} - ${temp_warn} - ${temp_crit} - ${temp_crit_sys}"
|
||||
# [ ! "${temp_c}" ] || [ ! "${temp_f}" ] || [ ! "${temp_warn}" ] || [ ! "${temp_crit}" ] || [ ! "${temp_crit_sys}" ] && echo "VALUE NOT FOUND"
|
||||
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" != "esxi" ]; then
|
||||
echo ${PW_THRESHOLDS[${SENSOR}]} | cut -d',' -f 1 | read temp_warn
|
||||
@@ -315,7 +315,7 @@ CHECKTEMP_SERVICE(){
|
||||
fi
|
||||
|
||||
|
||||
if [ $(bc -l <<< "${temp_f} < ${temp_warn}") -eq 1 ]; then
|
||||
if (( $(bc <<< "${temp_f} < ${temp_warn}") )); then
|
||||
if (( $(bc <<< "${last_temp[${SENSOR}]} > 1") )); then
|
||||
SENDNOTICE "${SENSOR} BACK TO NORMAL" "NORMAL TEMP: ${temp_f}${GAUGESH}
|
||||
Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
|
||||
@@ -323,7 +323,7 @@ Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - ${SENSOR} - Back to NORMAL ${GAUGE}" >> ${PW_LOGFILE}
|
||||
# [ "$(compgen -G "${PW_TMPFOLDER}/power.*.off")" != "" ] && rm -f ${PW_TMPFOLDER}/power.*.off
|
||||
|
||||
elif [ "${last_temp[${SENSOR}]}" == "1" ]; then
|
||||
elif (( $(bc <<< "${temp_diff} = 0") )); then
|
||||
# SENDNOTICE "${SENSOR} TEMP NORMAL" "Service Startup
|
||||
# NORMAL TEMP: ${temp_f}${GAUGESH}"
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Service Startup - NORMAL ${GAUGE}" >> ${logtemp}
|
||||
@@ -355,13 +355,13 @@ Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
|
||||
fi
|
||||
|
||||
else
|
||||
[ ! "${last_temp[${SENSOR}]}" ] && last_temp[${SENSOR}]=${temp_f}
|
||||
([ ! "${last_temp[${SENSOR}]}" ] || (( $(bc <<< "${last_temp[${SENSOR}]} < 2") ))) && 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
|
||||
if (( $(bc <<< "${temp_diff} > 1") )) || (( $(bc <<< "${temp_diff} = 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}
|
||||
@@ -375,7 +375,7 @@ Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
|
||||
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
|
||||
if (( $(bc <<< "${temp_diff} > 1") )) || (( $(bc <<< "${temp_diff} = 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}
|
||||
@@ -394,7 +394,7 @@ Previous Temp: ${last_temp[${SENSOR}]}${GAUGESH}"
|
||||
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
|
||||
if (( $(bc <<< "${temp_diff} > 1") )) || (( $(bc <<< "${temp_diff} = 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}
|
||||
|
||||
Reference in New Issue
Block a user