Update temp.inc.sh

This commit is contained in:
2023-12-14 22:12:23 -06:00
parent 793cfc9436
commit 2abd0b8607

View File

@@ -109,8 +109,7 @@ CHECKTEMPSENSOR(){
elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${1}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq)
temp_c=$(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp')
temp_probe=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp')
echo "$temp_c - $temp_probe"
temp_probe_c=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp')
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then
temp_c=$(vcgencmd measure_temp)
@@ -174,15 +173,16 @@ CHECKTEMPSENSOR(){
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]"
if [ "${1}" == "ServerRoomLA" ]; then
if [ $(bc -l <<< "${temp_probe} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe} < ${temp_crit}") -eq 1 ]; then
echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_probe}${GAUGESH}${idsCL[Default]}"
elif [ $(bc -l <<< "${temp_probe} >= ${temp_crit}") -eq 1 ]; then
echo -en "${idsCL[LightRed]}CRITICAL${spct}${temp_probe}${GAUGESH}${idsCL[Default]}"
temp_probe_f=$(bc <<< "scale=1; ${temp_probe_c}*1.8+32")
if [ $(bc -l <<< "${temp_probe_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe_f} < ${temp_crit}") -eq 1 ]; then
echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_probe_f}${GAUGESH}${idsCL[Default]}"
elif [ $(bc -l <<< "${temp_probe_f} >= ${temp_crit}") -eq 1 ]; then
echo -en "${idsCL[LightRed]}CRITICAL${spct}${temp_probe_f}${GAUGESH}${idsCL[Default]}"
else
echo -en "${idsCL[Green]}Normal ${spct}${temp_probe}${GAUGESH}${idsCL[Default]}"
echo -en "${idsCL[Green]}Normal ${spct}${temp_probe_f}${GAUGESH}${idsCL[Default]}"
fi
tmp="${spct}${temp_probe}"
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=' '
@@ -272,7 +272,7 @@ CHECKTEMP_SERVICE(){
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${1}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq)
temp_c=$(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp')
temp_probe=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp')
temp_probe_c=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp')
temp_h=$(echo ${INFO} | jq -r '.device0 .obs[].humidity')
@@ -281,7 +281,7 @@ CHECKTEMP_SERVICE(){
IFS=$'~'; read -rd '' -a INFO <<<"${INFO}"; unset IFS; declare -A DEVICE_INFO
for DINFOtmp in "${INFO[@]}"; do key=${DINFOtmp%%:*}; val=${DINFOtmp##*:}; val=${val//[$'\t\r\n ']}; DEVICE_INFO[${key}]=${val}; done
temp_c=${DEVICE_INFO['ambient_temp']}
temp_probe=${DEVICE_INFO['probe_temp']}
temp_probe_c=${DEVICE_INFO['probe_temp']}
temp_h=${DEVICE_INFO['humidity']}
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
@@ -470,7 +470,7 @@ Previous Temp: ${last_temp[${SENSOR//-/}]}${GAUGESH}"
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}')"
${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_c}')"
fi
touch ${PW_TMPFOLDER}/${SENSOR}.insert
fi