Update temp.inc.sh
This commit is contained in:
@@ -662,29 +662,46 @@ SENDTEMP(){
|
||||
# fi
|
||||
|
||||
for SENSOR in "${SENSORS_CHECK[@]}"; do
|
||||
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "mqtt" ]; then
|
||||
mqtt_message=`${mqtt_conn} -t tele/${SENSOR}/SENSOR -C 1`
|
||||
temp_c=$(echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1)
|
||||
if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then
|
||||
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
|
||||
echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then
|
||||
temp_c=$(vcgencmd measure_temp)
|
||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||
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)
|
||||
if [[ "${1}" = *"-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
|
||||
temp_c=$(vcgencmd measure_temp)
|
||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||
elif [[ "${1}" = *"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)
|
||||
if [ "${temp_c}" != "" ]; then
|
||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "remotesystem" ]; then
|
||||
temp_c=$(ssh root@${PW_REMOTE_SENSORS[${SENSOR}]} vcgencmd measure_temp)
|
||||
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=$(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`
|
||||
vSENSOR=${SENSOR}
|
||||
SENSOR="${SENSORa}-${vSENSOR// /_}"
|
||||
((t++))
|
||||
elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
|
||||
if [ "${1}" == "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")
|
||||
fi
|
||||
else
|
||||
temp_c=''
|
||||
|
||||
fi
|
||||
|
||||
if [ "${1}" != "" ]; then
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
||||
average1=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 1 ${vSENSOR// /_})
|
||||
@@ -704,6 +721,7 @@ SENDTEMP(){
|
||||
echo -e "${SENSOR}${spc}No Data"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
[ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ] && echo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user