Update temp.inc.sh

This commit is contained in:
2023-12-26 21:17:39 -06:00
parent 7b3ef36f52
commit 758887a833

View File

@@ -662,38 +662,38 @@ SENDTEMP(){
# fi
for SENSOR in "${SENSORS_CHECK[@]}"; do
if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "mqtt" ]; then
mqtt_message=`${mqtt_conn} -t tele/${SENSORa}/SENSOR -C 1`
echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "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)
if [[ "${1}" = *"-Probe" ]]; then
if [[ "${SENSORa}" = *"-Probe" ]]; then
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
else
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') 2 yes`
fi
elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then
if [[ "${1}" = *"CPU"* ]]; then
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
if [[ "${SENSORa}" = *"CPU"* ]]; then
temp_c=$(vcgencmd measure_temp)
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
elif [[ "${1}" = *"FAN"* ]]; then
elif [[ "${SENSORa}" = *"FAN"* ]]; then
temp_c=$(cat /sys/class/hwmon/hwmon2/fan1_input)
fi
elif [ "${PW_SENSOR_TYPE[${1}]}" == "remotesystem" ]; then
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "remotesystem" ]; then
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${SENSORa}]} vcgencmd measure_temp)
if [ "${temp_c}" != "" ]; then
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
temp_c=${temp_c%\'*}
temp_c=${temp_c#*=}
fi
elif [ "${PW_SENSOR_TYPE[${1}]}" == "esxi" ]; then
temp_c=${2}
temp_warn=`echo $(bc <<< "scale=2; (${3}*1.8+32)/1") | awk '{print int($1+0.5)}'`
temp_crit=`echo $(bc <<< "scale=2; (${4}*1.8+32)/1") | awk '{print int($1+0.5)}'`
# elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
# temp_c=${2}
# temp_warn=`echo $(bc <<< "scale=2; (${3}*1.8+32)/1") | awk '{print int($1+0.5)}'`
# temp_crit=`echo $(bc <<< "scale=2; (${4}*1.8+32)/1") | awk '{print int($1+0.5)}'`
elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
if [ "${1}" == "Powerwall-CPU-Usage" ]; then
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "cpu" ]; then
if [ "${SENSORa}" == "Powerwall-CPU-Usage" ]; then
temp_c=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g')
else
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "/opt/idssys/defaults/get-data.sh cpu-usage")