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