Update temp.inc.sh
This commit is contained in:
@@ -269,10 +269,12 @@ AVERAGETEMP(){
|
||||
|
||||
CHECKTEMP_SERVICE(){
|
||||
cw=20
|
||||
declare -gA last_temp
|
||||
runEvery=15 #SECONDS
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - 'Check Temp' Service Startup" >> ${PW_LOGFILE}
|
||||
SENDTEMPS "TEMP Service Startup" &
|
||||
[ -d ${PW_TMPFOLDER}/.lasttemp ] && rm -Rf ${PW_TMPFOLDER}/.lasttemp
|
||||
mkdir ${PW_TMPFOLDER}/.lasttemp
|
||||
|
||||
while true; do
|
||||
start=$(date +%s)
|
||||
source ${PW_FOLDER}/defaults.inc
|
||||
@@ -286,7 +288,6 @@ CHECKTEMP_SERVICE(){
|
||||
# fi
|
||||
SENSORS_CHECKED=()
|
||||
for SENSORa in ${PW_SENSOR_ORD[@]}; do
|
||||
[ "${last_temp[${SENSORa//-/}]}" == "" ] && last_temp[${SENSORa//-/}]=0
|
||||
CHECKTEMP_SERVICE_RUNSENSOR ${SENSORa} &
|
||||
SENSORS_CHECKED+=(${SENSORa})
|
||||
done
|
||||
@@ -310,7 +311,6 @@ CHECKTEMP_SERVICE(){
|
||||
done # &
|
||||
}
|
||||
CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
declare -gA last_temp
|
||||
SENSORa=${1}
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSORa}
|
||||
[ ! -f ${logtemp} ] && touch ${logtemp}
|
||||
@@ -402,7 +402,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
|
||||
fi
|
||||
|
||||
echo "HERE: ${SENSOR} = ${last_temp[${SENSOR//-/}]}"
|
||||
[ ! -f ${PW_TMPFOLDER}/.lasttemp/${SENSOR} ] && echo 0 > ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
last_temp=$(cat ${PW_TMPFOLDER}/.lasttemp/${SENSOR})
|
||||
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR}
|
||||
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
|
||||
@@ -451,7 +452,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
(( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}"
|
||||
fi
|
||||
|
||||
# echo "HERE: [${SENSOR//-/}] - ${last_temp[${SENSOR//-/}]} - ${temp_c} - ${temp_f} - ${temp_warn} - ${temp_crit} - ${temp_crit_sys}"
|
||||
echo "HERE: [${SENSOR//-/}] - ${last_temp} - ${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
|
||||
@@ -473,14 +474,14 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
fi
|
||||
|
||||
if (( $(bc <<< "${temp_f} < ${temp_warn}") )); then
|
||||
if (( $(bc <<< "${last_temp[${SENSOR//-/}]} >= 1") )); then
|
||||
if (( $(bc <<< "${last_temp} >= 1") )); then
|
||||
[ -f ${PW_TMPFOLDER}/${SENSORa}.down ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}.down)) -ge 1800 ] && SENDNOTICE "${SENSOR} BACK TO NORMAL" "NORMAL TEMP: ${temp_f}${GAUGESH}
|
||||
Previous Temp: ${last_temp[${SENSOR//-/}]}${GAUGESH}"
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Back to NORMAL ${GAUGE} - Previous ${GAUGE}: ${last_temp[${SENSOR//-/}]}${GAUGESH}" >> ${logtemp}
|
||||
Previous Temp: ${last_temp}${GAUGESH}"
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - Back to NORMAL ${GAUGE} - Previous ${GAUGE}: ${last_temp}${GAUGESH}" >> ${logtemp}
|
||||
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//-/}]}" == "0" ]; then
|
||||
elif [ "${last_temp}" == "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}
|
||||
@@ -494,7 +495,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
|
||||
([ "${SENSOR}" == "ServerRoomTH" ] || [[ "${SENSOR}" = *"ServerRoomLA"* ]]) && rm -f ${PW_TMPFOLDER}/temp.*
|
||||
rm -f ${PW_TMPFOLDER}/power.${SENSORa}.*
|
||||
last_temp[${SENSOR//-/}]=1
|
||||
last_temp=1
|
||||
echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
|
||||
# iDS-vMS-Offsite Fan Issue Workaround
|
||||
if [ "${PW_HOST_IDRACS[${SENSORa}]}" == "10.2.1.21" ] && [ "${FanSpeed}" != "" ]; then
|
||||
@@ -510,8 +512,11 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
|
||||
else
|
||||
|
||||
([ ! "${last_temp[${SENSOR//-/}]}" ] || (( $(bc <<< "${last_temp[${SENSOR//-/}]} < 2") ))) && last_temp[${SENSOR//-/}]=${temp_f}
|
||||
temp_diff=`echo "scale=2; ${last_temp[${SENSOR//-/}]}-${temp_f}" | bc`
|
||||
if ([ ! "${last_temp}" ] || (( $(bc <<< "${last_temp} < 2") ))); then
|
||||
last_temp=${temp_f}
|
||||
echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
fi
|
||||
temp_diff=`echo "scale=2; ${last_temp}-${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
|
||||
@@ -519,7 +524,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
([ "${SENSOR}" == "ServerRoomTH" ] || [[ "${SENSOR}" = *"ServerRoomLA"* ]]) && touch ${PW_TMPFOLDER}/temp.warn
|
||||
if (( $(bc <<< "${temp_diff} >= 1") )); then
|
||||
SENDNOTICE "${SENSOR} ${GAUGE} WARNING" "WARNING ${GAUGE}: ${temp_f}${GAUGESH} - (Difference of ${temp_diff}')" 1
|
||||
last_temp[${SENSOR//-/}]=${temp_f}
|
||||
last_temp=${temp_f}
|
||||
echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${temp_f}${GAUGESH} - WARNING ${GAUGE} - (Difference of ${temp_diff}')" >> ${logtemp}
|
||||
|
||||
fi
|
||||
@@ -538,7 +544,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
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}
|
||||
last_temp=${temp_f}
|
||||
echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
|
||||
if ([ "${SENSOR}" == "ServerRoomTH" ] || [[ "${SENSOR}" = *"ServerRoomLA"* ]]) && [ ! -f touch ${PW_TMPFOLDER}/temp.crit ]; then
|
||||
touch ${PW_TMPFOLDER}/temp.crit
|
||||
@@ -557,7 +564,8 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
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}
|
||||
last_temp=${temp_f}
|
||||
echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR}
|
||||
if ([ "${SENSOR}" == "ServerRoomTH" ] || [[ "${SENSOR}" = *"ServerRoomLA"* ]]) && [ ! -f ${PW_TMPFOLDER}/temp.critsys ]; then
|
||||
touch ${PW_TMPFOLDER}/temp.critsys
|
||||
SHUTDOWN_SYS ${SENSOR} TEMP &
|
||||
|
||||
Reference in New Issue
Block a user