diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 47ed804b..22e88d3a 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -161,7 +161,7 @@ CHECKTEMP(){ for R in ${PW_TEMPIND_RANGE[@]}; do [ "${mysql_conn}" != "" ] && OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL $(expr ${R} + 1) MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${R} - 6) MINUTE) ORDER BY date ASC LIMIT 1")) if [ "${OLD_temp_f[1]}" != "" ]; then - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; (${OLD_temp_f[1]}+${PW_TEMPIND_DIFF})/1" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; (${OLD_temp_f[1]}+${PW_TEMPIND_DIFF})/1" | tr -d $'\r' | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc) < ${temp_f}") -eq 1 ]; then echo -en "${idsCL[White]}\u23F9 " elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then echo -en "${idsCL[LightRed]}\u25B2 " @@ -260,7 +260,7 @@ CHECKTEMP(){ OLD_date=${OLD_temp_f[3]} OLD_time=${OLD_temp_f[4]} if [ "${OLD_temp_f}" != "" ]; then - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc) < ${temp_f}") -eq 1 ]; then lclr="${idsCL[White]}" lico="\u23F9" elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then @@ -326,7 +326,7 @@ CHECKTEMP(){ OLD_date=${OLD_temp_h[3]} OLD_time=${OLD_temp_h[4]} if [ "${OLD_temp_h}" != "" ]; then - if [ $(bc -l <<< "${temp_h} < $(echo "scale=2; ${OLD_temp_h}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_h}-${PW_TEMPIND_DIFF}" | bc) < ${temp_h}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_h} < $(echo "scale=2; ${OLD_temp_h}+${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_h}-${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc) < ${temp_h}") -eq 1 ]; then lclr="${idsCL[White]}" lico="\u23F9" elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_h}+(${PW_TEMPIND_DIFF}*2)") < ${temp_h}") -eq 1 ]; then @@ -450,9 +450,9 @@ CHECKTEMP(){ # if [ "${TTYPE}" != "fans" ] || ([ "${TTYPE}" == "fans" ] && ([[ "${sensorname}" = *"Exhaust"* ]] || ([ "${SENSOR}" == "iDS-vMS-Host6" ] && [[ "${sensorname}" = *"Inlet"* ]]))); then if [ "${TTYPE}" != "fans" ] || ([ "${TTYPE}" == "fans" ] && ([[ "${sensorname}" = *"Exhaust"* ]] || [[ "${sensorname}" = *"Inlet"* ]])); then temp_warn=$(snmpwalk -v 1 -c public -t 2 ${vHOSTiDRACIP} .1.3.6.1.4.1.674.10892.5.4.700.20.1.11.1.${t} -O vq | sed -e 's/"//g') - temp_warn=`echo "scale=1; ${temp_warn}/10" | bc`; temp_warn=`echo $(bc <<< "scale=2; ((${temp_warn}*(9/5))+32)/1") | awk '{print int($1+0.5)}'` + temp_warn=`echo "scale=1; ${temp_warn}/10" | tr -d $'\r' | bc`; temp_warn=`echo $(bc <<< "scale=2; ((${temp_warn}*(9/5))+32)/1") | awk '{print int($1+0.5)}'` temp_crit=$(snmpwalk -v 1 -c public -t 2 ${vHOSTiDRACIP} .1.3.6.1.4.1.674.10892.5.4.700.20.1.10.1.${t} -O vq | sed -e 's/"//g') - temp_crit=`echo "scale=1; ${temp_crit}/10" | bc`; temp_crit=`echo $(bc <<< "scale=2; ((${temp_crit}*(9/5))+32)/1") | awk '{print int($1+0.5)}'` + temp_crit=`echo "scale=1; ${temp_crit}/10" | tr -d $'\r' | bc`; temp_crit=`echo $(bc <<< "scale=2; ((${temp_crit}*(9/5))+32)/1") | awk '{print int($1+0.5)}'` c=0; spc=''; spc1=`expr ${cw} - ${#sensorname} - 1`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done IFS=: read -r temp_f temp_h <<< $(CHECKTEMPSENSOR ${SENSOR}); unset IFS @@ -484,7 +484,7 @@ CHECKTEMP(){ [ "${mysql_conn}" != "" ] && OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND entity=${entityid[1]} AND date >= DATE_SUB(NOW(), INTERVAL $(expr ${R} + 1) MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${R} - 6) MINUTE) ORDER BY date ASC LIMIT 1")) [[ "${IP}" == "10.6.1"* ]] && OLD_temp_f=${OLD_temp_f[0]} || OLD_temp_f=${OLD_temp_f[1]} if [ "${OLD_temp_f}" != "" ]; then - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc) < ${temp_f}") -eq 1 ]; then echo -en "${idsCL[White]}\u23F9 " elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then echo -en "${idsCL[LightRed]}\u25B2 " @@ -570,7 +570,7 @@ CHECKTEMP(){ fi if [ "${OLD_temp_f}" != "" ]; then - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | tr -d $'\r' | bc) < ${temp_f}") -eq 1 ]; then lclr="${idsCL[White]}" lico="\u23F9" elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then @@ -746,7 +746,7 @@ CHECKTEMPSENSOR(){ elif [ "${PW_SENSOR_TYPE[${1}]}" == "esxi" ]; then temp_c=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${1}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.6.1.${t} -O vq | sed -e 's/"//g') - temp_c=`echo "scale=1; ${temp_c}/10" | bc` + temp_c=`echo "scale=1; ${temp_c}/10" | tr -d $'\r' | bc` elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then if [ "${1}" == "Powerwall-CPU-Usage" ]; then @@ -767,10 +767,10 @@ CHECKTEMPSENSOR(){ if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then if [ "${1}" == "ServerRoomTH" ]; then - temp_f=`echo "scale=2; ((${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev})/1" | bc` + temp_f=`echo "scale=2; ((${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev})/1" | tr -d $'\r' | bc` else if [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then - temp_f=$(echo "scale=2; $temp_c/1" | bc -l) + temp_f=$(echo "scale=2; $temp_c/1" | tr -d $'\r' | bc -l) elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ] && [[ "${1}" = *"FAN"* ]]; then temp_f=${temp_c} elif [ "${temp_f}" == "" ]; then @@ -915,7 +915,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ [ ! -f ${logtemp} ] && touch ${logtemp} [ -f ${PW_TMPFOLDER}/ztemprun.${SENSORa}.done ] && rm -f ${PW_TMPFOLDER}/ztemprun.${SENSORa}.done - [ $(expr `date +%s` - $(stat -c %Y ${logtemp})) -ge $(echo "scale=0; ${PW_LOG_INTERVAL_NORMAL}*60" | bc) ] && relog=1 || relog=0 + [ $(expr `date +%s` - $(stat -c %Y ${logtemp})) -ge $(echo "scale=0; ${PW_LOG_INTERVAL_NORMAL}*60" | tr -d $'\r' | bc) ] && relog=1 || relog=0 if [ ! -f ${PW_TMPFOLDER}/${SENSORa}.disable ] && ([ "${PW_SENSOR_TYPE[${SENSORa}]}" == "lacrosse" ] || [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esphome" ] || ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]) || ([ "${PW_HOST_ADDRESSES[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_HOST_ADDRESSES[${SENSORa}]})" != "false" ])); then # if ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]); then @@ -954,7 +954,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ fi fi if [ "${vHOSTFAN}" != "" ]; then - # FanSpeed=`echo "scale=2; ${vHOSTFAN}/21200" | bc`; FanSpeed=$(ROUND_NUMBER `echo "scale=0; ${FanSpeed}*100" | bc | sed -e 's/.00//g'` 0) + # FanSpeed=`echo "scale=2; ${vHOSTFAN}/21200" | tr -d $'\r' | bc`; FanSpeed=$(ROUND_NUMBER `echo "scale=0; ${FanSpeed}*100" | tr -d $'\r' | bc | sed -e 's/.00//g'` 0) if [ "$(echo ${vHOSTFAN} | awk '/ / {print $4}' | sed -e 's/%//g')" == "RPM" ]; then FanSpeed=$(echo ${vHOSTFAN} | awk '/ / {print $9}' | sed -e 's/%//g') else @@ -1034,13 +1034,13 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then temp_c=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.6.1.${t} -O vq | sed -e 's/"//g') - temp_c=`echo "scale=1; ${temp_c}/10" | bc` + temp_c=`echo "scale=1; ${temp_c}/10" | tr -d $'\r' | bc` temp_warn=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.11.1.${t} -O vq | sed -e 's/"//g') - temp_warn=`echo "scale=1; ${temp_warn}/10" | bc` - temp_warn=$(echo "scale=2; ${temp_warn}*1.8 + 32" | bc) + temp_warn=`echo "scale=1; ${temp_warn}/10" | tr -d $'\r' | bc` + temp_warn=$(echo "scale=2; ${temp_warn}*1.8 + 32" | tr -d $'\r' | bc) temp_crit=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.10.1.${t} -O vq | sed -e 's/"//g') - temp_crit=`echo "scale=1; ${temp_crit}/10" | bc` - temp_crit=$(echo "scale=2; ${temp_crit}*1.8 + 32" | bc) + temp_crit=`echo "scale=1; ${temp_crit}/10" | tr -d $'\r' | bc` + temp_crit=$(echo "scale=2; ${temp_crit}*1.8 + 32" | tr -d $'\r' | bc) temp_crit_sys=${temp_crit} temp_h='' vSENSOR=${SENSOR} @@ -1057,7 +1057,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "ds18b20" ]; then if ! temp_c=$(${SSHCMD} root@${PW_REMOTE_SENSORS[${SENSORa}]} cat /sys/devices/w1_bus_master1/${PW_SENSOR_DEVICEID[${SENSORa}]}/w1_slave | tail -n1 | cut -d "=" -f2) ; then TIMEOUT=1; fi - [ "${temp_c}" != "" ] && temp_c=$(echo "scale=2; ${temp_c}/1000" | bc) + [ "${temp_c}" != "" ] && temp_c=$(echo "scale=2; ${temp_c}/1000" | tr -d $'\r' | bc) temp_h='' else @@ -1094,10 +1094,10 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ fi if [ "${SENSOR}" == "ServerRoomTH" ]; then - temp_f=`echo "scale=2; (${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev}" | bc` + temp_f=`echo "scale=2; (${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev}" | tr -d $'\r' | bc` else if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ]; then - temp_f=$(echo "scale=2; $temp_c/1" | bc -l) + temp_f=$(echo "scale=2; $temp_c/1" | tr -d $'\r' | bc -l) elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then temp_f=${temp_c} elif [ "${temp_f}" == "" ]; then @@ -1238,8 +1238,8 @@ Previous Temp: ${last_temp}${GAUGESH}" echo ${last_temp} >| ${PW_TMPFOLDER}/.lasttemp/${SENSOR} fi 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` + temp_diff=`echo "scale=2; ${last_temp}-${temp_f}" | tr -d $'\r' | bc` + [ $(bc -l <<< "${temp_diff} < 0") -eq 1 ] && temp_diff=`echo "scale=2; ${temp_diff}*-1" | tr -d $'\r' | bc` if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then # [[ "${SENSOR}" = *"${PW_SHUTDOWN_SENSORS}"* ]] && touch ${PW_TMPFOLDER}/temp.warn @@ -1316,9 +1316,9 @@ Previous Temp: ${last_temp}${GAUGESH}" [ -f ${PW_TMPFOLDER}/.lastinsert/${SENSOR} ] && lastinsert=$(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastinsert/${SENSOR})) || lastinsert=100000 if [ $(ls ${PW_TMPFOLDER}/temp.* 2>/dev/null | wc -l) -gt 0 ] || [ "$(compgen -G "${PW_TMPFOLDER}/power.*.low")" != "" ]; then - wait=$(echo "scale=0; ${PW_MYSQL_LOG_INTERVAL_ABNORMAL}*60" | bc) + wait=$(echo "scale=0; ${PW_MYSQL_LOG_INTERVAL_ABNORMAL}*60" | tr -d $'\r' | bc) else - wait=$(echo "scale=0; ${PW_MYSQL_LOG_INTERVAL_NORMAL}*60" | bc) + wait=$(echo "scale=0; ${PW_MYSQL_LOG_INTERVAL_NORMAL}*60" | tr -d $'\r' | bc) fi if [ "${mysql_conn}" != "" ] && [ "${PW_SENSOR_ID[${SENSORa}]}" != "" ] && [ ${lastinsert} -ge ${wait} ] && [ "${temp_f}" != "32.00" ] && [ "${temp_f}" != "32" ] && [ "${temp_f}" != "35.60" ]; then @@ -1355,7 +1355,7 @@ Previous Temp: ${last_temp}${GAUGESH}" [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ] && touch ${PW_TMPFOLDER}/${SENSOR}.down if [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.reading ]; then touch ${PW_TMPFOLDER}/${SENSOR}-error.reading - elif [ ! -f ${PW_TMPFOLDER}/${SENSOR}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | bc) ])); then + elif [ ! -f ${PW_TMPFOLDER}/${SENSOR}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | tr -d $'\r' | bc) ])); then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSOR} Sensor - ERROR reading sensor data" >> ${logtemp} if [ ${PW_ENABLE_RENOTIFY} -eq 1 ] || [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ]; then SENDNOTICE "${SENSOR_DESC} Sensor ERROR" "ERROR reading sensor data" 1 @@ -1411,7 +1411,7 @@ Previous Temp: ${last_temp}${GAUGESH}" # if [ "${temp_f}" != "" ] && (( $(bc <<< "${temp_f} >= 2") )) && [ -f ${PW_TMPFOLDER}/.serverroomtemp ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.serverroomtemp)) -lt 30 ]; then # [ ! -f ${PW_TMPFOLDER}/.log.sr.difference ] && touch ${PW_TMPFOLDER}/.log.sr.difference # temp_difference=$(bc <<< "scale=2; $(cat ${PW_TMPFOLDER}/.serverroomtemp)-${temp_f}") - # # (( $(bc <<<"${temp_difference} < 0") )) && temp_difference=`echo "scale=2; ${temp_difference} * -1" | bc` + # # (( $(bc <<<"${temp_difference} < 0") )) && temp_difference=`echo "scale=2; ${temp_difference} * -1" | tr -d $'\r' | bc` # echo "$(date "+%Y-%m-%d %H:%M:%S")~${temp_difference}" >> ${PW_TMPFOLDER}/.log.sr.difference # # echo "[$(date +'%Y-%m-%d %H:%M:%S')] ${temp_f} - $(cat ${PW_TMPFOLDER}/.serverroomtemp) = ${temp_difference}" # rm -f ${PW_TMPFOLDER}/.serverroomtemp @@ -1438,7 +1438,7 @@ Previous Temp: ${last_temp}${GAUGESH}" RUN=$(curl -m 8 -s -H "Authorization: Bearer ${PW_ESPHOME_API}" -H "Content-Type: application/json" -d '{"entity_id": "switch.smart_15em_plug_in_2_socket"}' ${PW_HOMEASSISTANT_URL}/api/services/switch/turn_on) # fi - elif [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] || ([ -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | bc) ]); then + elif [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] || ([ -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSOR}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | tr -d $'\r' | bc) ]); then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSOR} Sensor - ERROR reading sensor data" >> ${logtemp} if [ ${PW_ENABLE_RENOTIFY} -eq 1 ] || [ ! -f ${PW_TMPFOLDER}/${SENSOR}-error.sent ]; then SENDNOTICE "${SENSOR_DESC} Sensor ERROR" "ERROR reading sensor data" 1 @@ -1479,7 +1479,7 @@ Previous Temp: ${last_temp}${GAUGESH}" [ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ] && touch ${PW_TMPFOLDER}/${SENSORa}.down if [ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.reading ]; then touch ${PW_TMPFOLDER}/${SENSORa}-error.reading - elif [ ! -f ${PW_TMPFOLDER}/${SENSORa}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | bc) ])); then + elif [ ! -f ${PW_TMPFOLDER}/${SENSORa}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | tr -d $'\r' | bc) ])); then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSORa} Sensor - ERROR reading sensor data" >> ${logtemp} if [ ${PW_ENABLE_RENOTIFY} -eq 1 ] || [ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ]; then SENDNOTICE "${SENSOR_DESC} Sensor ERROR" "ERROR reading sensor data" 1 @@ -1694,7 +1694,7 @@ SENDTEMP(){ elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "ds18b20" ]; then if ! temp_c=$(${SSHCMD} root@${PW_REMOTE_SENSORS[${SENSORa}]} cat /sys/devices/w1_bus_master1/${PW_SENSOR_DEVICEID[${SENSORa}]}/w1_slave | tail -n1 | cut -d "=" -f2) ; then TIMEOUT=1; fi - [ "${temp_c}" != "" ] && temp_c=$(echo "scale=2; ${temp_c}/1000" | bc) + [ "${temp_c}" != "" ] && temp_c=$(echo "scale=2; ${temp_c}/1000" | tr -d $'\r' | bc) else temp_c='' @@ -1716,10 +1716,10 @@ SENDTEMP(){ c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR_DESC}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then if [ "${SENSOR}" == "ServerRoomTH" ]; then - temp_f=`echo "scale=2; (${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev}" | bc` + temp_f=`echo "scale=2; (${temp_c}*(9/5))+32+${PW_ServerRoomTH_Dev}" | tr -d $'\r' | bc` else if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ]; then - temp_f=$(echo "scale=2; $temp_c/1" | bc -l) + temp_f=$(echo "scale=2; $temp_c/1" | tr -d $'\r' | bc -l) elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then temp_f=${temp_c} else @@ -1795,11 +1795,11 @@ SERVERROOM_TEMP_DIFFERENCE(){ [[ "${tempdiff}" = *"~"* ]] && tempdiff=${tempdiff#*~} if [ $(bc -l <<< "${tempdiff} <= 15") -eq 1 ]; then - # (( $(bc <<<"${tempdiff} < 0") )) && tempdiff_tmp1=`echo "scale=2; ${tempdiff} * -1" | bc` || tempdiff_tmp1=${tempdiff} - # (( $(bc <<<"${largest_tempdiff} < 0") )) && tempdiff_tmp2=`echo "scale=2; ${largest_tempdiff} * -1" | bc` || tempdiff_tmp2=${largest_tempdiff} + # (( $(bc <<<"${tempdiff} < 0") )) && tempdiff_tmp1=`echo "scale=2; ${tempdiff} * -1" | tr -d $'\r' | bc` || tempdiff_tmp1=${tempdiff} + # (( $(bc <<<"${largest_tempdiff} < 0") )) && tempdiff_tmp2=`echo "scale=2; ${largest_tempdiff} * -1" | tr -d $'\r' | bc` || tempdiff_tmp2=${largest_tempdiff} # [ $(bc -l <<< "${tempdiff_tmp1} >= ${tempdiff_tmp2}") -eq 1 ] && largest_tempdiff=${tempdiff} - # (( $(bc <<<"${tempdiff} < 0") )) && tempdiff_tmp1=`echo "scale=2; ${tempdiff} * -1" | bc` || tempdiff_tmp1=${tempdiff} + # (( $(bc <<<"${tempdiff} < 0") )) && tempdiff_tmp1=`echo "scale=2; ${tempdiff} * -1" | tr -d $'\r' | bc` || tempdiff_tmp1=${tempdiff} # [ $(bc -l <<< "${tempdiff_tmp1} >= ${largest_tempdiff}") -eq 1 ] && largest_tempdiff=${tempdiff_tmp1} # [ $(bc -l <<< "${tempdiff} >= ${largest_tempdiff}") -eq 1 ] && largest_tempdiff=${tempdiff} @@ -1814,9 +1814,9 @@ SERVERROOM_TEMP_DIFFERENCE(){ # largest_tempdiff=`IDS_NUMBER_FORMAT ${largest_tempdiff} 2 yes` # [ ${scansfound} -eq 0 ] && average=0 || average=$(bc <<< "scale=2; ${tempdiff_total}/${scansfound}") - [ ${scansfound} -eq 0 ] && average=0 || average=$(ROUND_NUMBER $(echo "scale=4; ${tempdiff_total}/${scansfound}" | bc -l) 2) + [ ${scansfound} -eq 0 ] && average=0 || average=$(ROUND_NUMBER $(echo "scale=4; ${tempdiff_total}/${scansfound}" | tr -d $'\r' | bc -l) 2) # [ ${scansfound_large} -eq 0 ] && average_large=0 || average_large=$(bc <<< "scale=2; ${tempdiff_large_total}/${scansfound_large}") - [ ${scansfound_large} -eq 0 ] && average_large=0 || average_large=$(ROUND_NUMBER $(echo "scale=4; ${tempdiff_large_total}/${scansfound_large}" | bc -l) 2) + [ ${scansfound_large} -eq 0 ] && average_large=0 || average_large=$(ROUND_NUMBER $(echo "scale=4; ${tempdiff_large_total}/${scansfound_large}" | tr -d $'\r' | bc -l) 2) # if [ $(bc -l <<< "${average} < 1") -eq 1 ]; then [ "${average}" = "0" ] && average="0.0" || average="0${average}"; fi average=`IDS_NUMBER_FORMAT ${average} 2 yes` @@ -1896,16 +1896,16 @@ GET_TUYA_TEMP(){ TEMP=-1 if [ "$(echo "${INFO}" | grep '"108":')" != "" ]; then TEMP=$(echo "${INFO}" | grep '"6":' | cut -d' ' -f 4 | sed 's/,//g') - TEMP=$(ROUND_NUMBER $(echo "scale=1; ${TEMP}/10" | bc -l) 1) + TEMP=$(ROUND_NUMBER $(echo "scale=1; ${TEMP}/10" | tr -d $'\r' | bc -l) 1) HUM=$(echo "${INFO}" | grep '"20":' | cut -d' ' -f 4 | sed 's/,//g') # elif [ "$(echo "${INFO}" | grep '"6":')" != "" ]; then # AMP=$(echo "${INFO}" | grep '"4":' | cut -d' ' -f 4 | sed 's/,//g') - # AMP=$(ROUND_NUMBER $(echo "scale=3; ${AMP}/1000" | bc -l) 2) + # AMP=$(ROUND_NUMBER $(echo "scale=3; ${AMP}/1000" | tr -d $'\r' | bc -l) 2) # WATT=$(echo "${INFO}" | grep '"5":' | cut -d' ' -f 4 | sed 's/,//g') - # WATT=$(echo "scale=1; ${WATT}/10" | bc -l) + # WATT=$(echo "scale=1; ${WATT}/10" | tr -d $'\r' | bc -l) # VOLT=$(echo "${INFO}" | grep '"6":' | cut -d' ' -f 4 | sed 's/,//g') - # VOLT=$(echo "scale=1; ${VOLT}/10" | bc -l) + # VOLT=$(echo "scale=1; ${VOLT}/10" | tr -d $'\r' | bc -l) fi [ "${TEMP}" != "-1" ] && echo "${TEMP}:${HUM}" || echo "0:0" fi