Update temp.inc.sh
This commit is contained in:
@@ -109,8 +109,7 @@ CHECKTEMPSENSOR(){
|
|||||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
|
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)
|
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_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')
|
||||||
echo "$temp_c - $temp_probe"
|
|
||||||
|
|
||||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then
|
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then
|
||||||
temp_c=$(vcgencmd measure_temp)
|
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]} ]"
|
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]"
|
||||||
|
|
||||||
if [ "${1}" == "ServerRoomLA" ]; then
|
if [ "${1}" == "ServerRoomLA" ]; then
|
||||||
if [ $(bc -l <<< "${temp_probe} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe} < ${temp_crit}") -eq 1 ]; then
|
temp_probe_f=$(bc <<< "scale=1; ${temp_probe_c}*1.8+32")
|
||||||
echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_probe}${GAUGESH}${idsCL[Default]}"
|
if [ $(bc -l <<< "${temp_probe_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe_f} < ${temp_crit}") -eq 1 ]; then
|
||||||
elif [ $(bc -l <<< "${temp_probe} >= ${temp_crit}") -eq 1 ]; then
|
echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_probe_f}${GAUGESH}${idsCL[Default]}"
|
||||||
echo -en "${idsCL[LightRed]}CRITICAL${spct}${temp_probe}${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
|
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
|
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
|
c=0; spc=''; spc1=`expr 10 - ${#tmp}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||||
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
|
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
|
||||||
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
||||||
@@ -272,7 +272,7 @@ CHECKTEMP_SERVICE(){
|
|||||||
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
|
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)
|
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_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')
|
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
|
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
|
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_c=${DEVICE_INFO['ambient_temp']}
|
||||||
temp_probe=${DEVICE_INFO['probe_temp']}
|
temp_probe_c=${DEVICE_INFO['probe_temp']}
|
||||||
temp_h=${DEVICE_INFO['humidity']}
|
temp_h=${DEVICE_INFO['humidity']}
|
||||||
|
|
||||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
|
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
|
||||||
@@ -470,7 +470,7 @@ Previous Temp: ${last_temp[${SENSOR//-/}]}${GAUGESH}"
|
|||||||
fi
|
fi
|
||||||
${mysql_conn} -e "${QRY}"
|
${mysql_conn} -e "${QRY}"
|
||||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then
|
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
|
fi
|
||||||
touch ${PW_TMPFOLDER}/${SENSOR}.insert
|
touch ${PW_TMPFOLDER}/${SENSOR}.insert
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user