update
This commit is contained in:
108
inc/temp.inc.sh
108
inc/temp.inc.sh
@@ -122,7 +122,7 @@ CHECKTEMPSENSOR(){
|
||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
|
||||
INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${SENSOR}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq)
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') 2 yes`
|
||||
temp_probe_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
# temp_probe_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then
|
||||
if [[ "${1}" = *"CPU"* ]]; then
|
||||
@@ -211,42 +211,42 @@ CHECKTEMPSENSOR(){
|
||||
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
||||
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn_disp}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit_disp}${GAUGESH}=>${idsCL[Default]} ]"
|
||||
|
||||
if [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
|
||||
temp_probe_f=$(bc <<< "scale=2; ${temp_probe_c}*1.8+32")
|
||||
tmp="${spct}${temp_probe_f}"
|
||||
c=0; spc=''; spc1=`expr 10 - ${#tmp}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
|
||||
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
||||
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${1}-Probe ${idsST[Reset]}${spc}${idsCL[Default]}: "
|
||||
if [ "${average}" != "" ]; then
|
||||
average=$(AVERAGETEMP ${PW_SENSOR_ID["${1}-Probe"]} ${avgdays})
|
||||
c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ ${c} = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
|
||||
if [ "${average}" == "" ]; then
|
||||
averagedisp="${idsCL[Green]}"
|
||||
elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
|
||||
averagedisp="${idsCL[Yellow]}${average}"
|
||||
elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
|
||||
averagedisp="${idsCL[LightRed]}${average}"
|
||||
else
|
||||
averagedisp="${idsCL[Green]}${average}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $(bc -l <<< "${temp_probe_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe_f} < ${temp_crit}") -eq 1 ]; then
|
||||
lclr="${idsCL[Yellow]}"
|
||||
lmd="WARNING "
|
||||
elif [ $(bc -l <<< "${temp_probe_f} >= ${temp_crit}") -eq 1 ]; then
|
||||
lclr="${idsCL[LightRed]}"
|
||||
lmd="CRITICAL"
|
||||
else
|
||||
lclr="${idsCL[Green]}"
|
||||
lmd="Normal "
|
||||
fi
|
||||
echo -en "${lclr}Normal ${spct}${temp_probe_f}${GAUGESH}"
|
||||
[ "${average}" != "" ] && echo -en " /${spca}${averagedisp}${GAUGESH}"
|
||||
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]"
|
||||
|
||||
fi
|
||||
# if [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
|
||||
# temp_probe_f=$(bc <<< "scale=2; ${temp_probe_c}*1.8+32")
|
||||
# tmp="${spct}${temp_probe_f}"
|
||||
# c=0; spc=''; spc1=`expr 10 - ${#tmp}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
# [ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
|
||||
# [ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
||||
# echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${1}-Probe ${idsST[Reset]}${spc}${idsCL[Default]}: "
|
||||
# if [ "${average}" != "" ]; then
|
||||
# average=$(AVERAGETEMP ${PW_SENSOR_ID["${1}-Probe"]} ${avgdays})
|
||||
# c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ ${c} = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
|
||||
# if [ "${average}" == "" ]; then
|
||||
# averagedisp="${idsCL[Green]}"
|
||||
# elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
|
||||
# averagedisp="${idsCL[Yellow]}${average}"
|
||||
# elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
|
||||
# averagedisp="${idsCL[LightRed]}${average}"
|
||||
# else
|
||||
# averagedisp="${idsCL[Green]}${average}"
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# if [ $(bc -l <<< "${temp_probe_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe_f} < ${temp_crit}") -eq 1 ]; then
|
||||
# lclr="${idsCL[Yellow]}"
|
||||
# lmd="WARNING "
|
||||
# elif [ $(bc -l <<< "${temp_probe_f} >= ${temp_crit}") -eq 1 ]; then
|
||||
# lclr="${idsCL[LightRed]}"
|
||||
# lmd="CRITICAL"
|
||||
# else
|
||||
# lclr="${idsCL[Green]}"
|
||||
# lmd="Normal "
|
||||
# fi
|
||||
# echo -en "${lclr}Normal ${spct}${temp_probe_f}${GAUGESH}"
|
||||
# [ "${average}" != "" ] && echo -en " /${spca}${averagedisp}${GAUGESH}"
|
||||
# echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]"
|
||||
#
|
||||
# fi
|
||||
else
|
||||
echo -e "${idsCL[Yellow]}Sensor Offline${idsCL[Default]}"
|
||||
fi
|
||||
@@ -342,7 +342,7 @@ CHECKTEMP_SERVICE(){
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
|
||||
INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${SENSOR}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq)
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') 2 yes`
|
||||
temp_probe_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
# temp_probe_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
temp_h=$(echo ${INFO} | jq -r '.device0 .obs[].humidity')
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
|
||||
@@ -544,7 +544,7 @@ Previous Temp: ${last_temp[${SENSOR//-/}]}${GAUGESH}"
|
||||
wait=$(echo "scale=0; ${PW_MYSQL_LOG_INTERVAL_NORMAL}*60" | bc)
|
||||
fi
|
||||
|
||||
[ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ] && temp_probe_f=$(bc <<< "scale=2; ${temp_probe_c}*1.8+32")
|
||||
# [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ] && temp_probe_f=$(bc <<< "scale=2; ${temp_probe_c}*1.8+32")
|
||||
|
||||
if [ "${PW_SENSOR_ID[${SENSORa}]}" != "" ] && [ ${lastinsert} -ge ${wait} ]; then
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
||||
@@ -567,25 +567,25 @@ Previous Temp: ${last_temp[${SENSOR//-/}]}${GAUGESH}"
|
||||
QRY="USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`) VALUES ('${PW_SENSOR_ID[${SENSORa}]}','$(date +'%Y-%m-%d %H:%M:%S')','${temp_f}')"
|
||||
fi
|
||||
${mysql_conn} -e "${QRY}"
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
|
||||
${mysql_conn} -e "USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`) VALUES ('${PW_SENSOR_ID["${SENSORa}-Probe"]}','$(date +'%Y-%m-%d %H:%M:%S')','${temp_probe_f}')"
|
||||
fi
|
||||
# if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
|
||||
# ${mysql_conn} -e "USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`) VALUES ('${PW_SENSOR_ID["${SENSORa}-Probe"]}','$(date +'%Y-%m-%d %H:%M:%S')','${temp_probe_f}')"
|
||||
# fi
|
||||
touch ${PW_TMPFOLDER}/${SENSOR}.insert
|
||||
fi
|
||||
|
||||
#### LOGGING OF SERVERROOM SENSOR DIFFERENCE
|
||||
if [ "${SENSOR}" == "ServerRoomLA" ]; then
|
||||
if [ ! -f ${PW_TMPFOLDER}/.log.sr.difference ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.log.sr.difference)) -ge 300 ]; then
|
||||
if [ "${temp_probe_f}" != "" ] && [ "${ServerRoomTH}" != "" ]; then
|
||||
[ ! -f ${PW_TMPFOLDER}/.log.sr.difference ] && touch ${PW_TMPFOLDER}/.log.sr.difference
|
||||
temp_difference=$(bc <<< "scale=2; ${ServerRoomTH}-${temp_probe_f}")
|
||||
# (( $(bc <<<"${temp_difference} < 0") )) && temp_difference=`echo "scale=2; ${temp_difference} * -1" | bc`
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S")~${temp_difference}" >> ${PW_TMPFOLDER}/.log.sr.difference
|
||||
fi
|
||||
fi
|
||||
elif [ "${SENSOR}" == "ServerRoomTH" ]; then
|
||||
ServerRoomTH=${temp_f}
|
||||
fi
|
||||
# if [ "${SENSOR}" == "ServerRoomLA" ]; then
|
||||
# if [ ! -f ${PW_TMPFOLDER}/.log.sr.difference ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.log.sr.difference)) -ge 300 ]; then
|
||||
# if [ "${temp_probe_f}" != "" ] && [ "${ServerRoomTH}" != "" ]; then
|
||||
# [ ! -f ${PW_TMPFOLDER}/.log.sr.difference ] && touch ${PW_TMPFOLDER}/.log.sr.difference
|
||||
# temp_difference=$(bc <<< "scale=2; ${ServerRoomTH}-${temp_probe_f}")
|
||||
# # (( $(bc <<<"${temp_difference} < 0") )) && temp_difference=`echo "scale=2; ${temp_difference} * -1" | bc`
|
||||
# echo "$(date "+%Y-%m-%d %H:%M:%S")~${temp_difference}" >> ${PW_TMPFOLDER}/.log.sr.difference
|
||||
# fi
|
||||
# fi
|
||||
# elif [ "${SENSOR}" == "ServerRoomTH" ]; then
|
||||
# ServerRoomTH=${temp_f}
|
||||
# fi
|
||||
###################
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user