Update temp.inc.sh
This commit is contained in:
187
inc/temp.inc.sh
187
inc/temp.inc.sh
@@ -272,7 +272,7 @@ CHECKTEMP_SERVICE(){
|
||||
declare -A last_temp
|
||||
runEvery=10 #SECONDS
|
||||
echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - 'Check Temp' Service Startup" >> ${PW_LOGFILE}
|
||||
SENDTEMPS "TEMP Service Startup" &
|
||||
SENDTEMPS "TEMP Service Startup" ###&
|
||||
while true; do
|
||||
start=$(date +%s)
|
||||
source ${PW_FOLDER}/defaults.inc
|
||||
@@ -286,7 +286,7 @@ CHECKTEMP_SERVICE(){
|
||||
# fi
|
||||
SENSORS_CHECKED=()
|
||||
for SENSORa in ${PW_SENSOR_ORD[@]}; do
|
||||
CHECKTEMP_SERVICE_RUNSENSOR ${SENSORa} ###&
|
||||
CHECKTEMP_SERVICE_RUNSENSOR ${SENSORa} &
|
||||
SENSORS_CHECKED+=(${SENSORa})
|
||||
done
|
||||
s_count=0; completed=false; scanstart=$(date +%s)
|
||||
@@ -310,7 +310,6 @@ CHECKTEMP_SERVICE(){
|
||||
${PW_TMPFOLDER}/zservicerun.${SENSORa}.done
|
||||
}
|
||||
CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
echo "checking ${1}"
|
||||
SENSORa=${1}
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSORa}
|
||||
[ ! -f ${logtemp} ] && touch ${logtemp}
|
||||
@@ -642,112 +641,104 @@ SENDTEMP(){
|
||||
DIVIDER . . 40
|
||||
for SENSORa in ${PW_SENSOR_ORD[@]}; do
|
||||
([[ "${SENSORa}" = *"-Probe"* ]] || [[ "${SENSORa}" = *"-Usage"* ]]) && cw=25 || cw=30
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" != "esxi" ]; then
|
||||
# vHOST_TEMPNAMES=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.8 -O vq | sed -e 's/"//g' | sed -e 's/ Temp//g')
|
||||
# IFS=$'\n'
|
||||
# read -rd '' -a SENSORS_CHECK <<<"${vHOST_TEMPNAMES}"
|
||||
# unset IFS
|
||||
# t=1
|
||||
# else
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" != "esxi" ] && ([ "${PW_SENSOR_TYPE[${SENSORa}]}" == "lacrosse" ] || ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ])); then
|
||||
SENSORS_CHECK=(${SENSORa})
|
||||
# fi
|
||||
|
||||
for SENSOR in "${SENSORS_CHECK[@]}"; do
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "cpu" ]; then
|
||||
GAUGESH="'%25"
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
GAUGESH="'R"
|
||||
else
|
||||
GAUGESH="'F"
|
||||
fi
|
||||
[ "${last_sensor}" != "" ] && [ "${last_sensor}" != "${SENSOR%%-*}" ] && echo
|
||||
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[${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 [[ "${SENSORa}" = *"-Probe" ]]; then
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
for SENSOR in "${SENSORS_CHECK[@]}"; do
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "cpu" ]; then
|
||||
GAUGESH="'%25"
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
GAUGESH="'R"
|
||||
else
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') 2 yes`
|
||||
GAUGESH="'F"
|
||||
fi
|
||||
[ "${last_sensor}" != "" ] && [ "${last_sensor}" != "${SENSOR%%-*}" ] && echo
|
||||
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[${SENSORa}]}" == "system" ]; then
|
||||
if [[ "${SENSORa}" = *"CPU"* ]]; then
|
||||
temp_c=$(vcgencmd measure_temp)
|
||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||
elif [[ "${SENSORa}" = *"FAN"* ]]; then
|
||||
temp_c=$(cat /sys/class/hwmon/hwmon2/fan1_input)
|
||||
fi
|
||||
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#*=}
|
||||
fi
|
||||
# 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[${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[${SENSORa}]} "/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// /_})
|
||||
average7=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 7 ${vSENSOR// /_})
|
||||
# average7=0
|
||||
else
|
||||
average1=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 1)
|
||||
average7=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 7)
|
||||
# average7=0
|
||||
fi
|
||||
fi
|
||||
|
||||
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
|
||||
if [ "${SENSOR}" == "ServerRoomTH" ]; then
|
||||
temp_f=`echo "scale=2; ${temp_c}*1.8+32+${PW_ServerRoomTH_Dev}" | bc`
|
||||
else
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ]; then
|
||||
temp_f=$(echo "scale=2; $temp_c/1" | bc -l)
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
temp_f=${temp_c}
|
||||
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 [[ "${SENSORa}" = *"-Probe" ]]; then
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes`
|
||||
else
|
||||
temp_f=$(bc <<< "scale=2; ${temp_c}*1.8+32")
|
||||
temp_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') 2 yes`
|
||||
fi
|
||||
(( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}"
|
||||
fi
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
temp_f_disp=$(IDS_NUMBER_FORMAT ${temp_f})
|
||||
if [ "${1}" != "" ]; then
|
||||
average1_disp=$(IDS_NUMBER_FORMAT ${average1})
|
||||
average7_disp=$(IDS_NUMBER_FORMAT ${average7})
|
||||
|
||||
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 [[ "${SENSORa}" = *"FAN"* ]]; then
|
||||
temp_c=$(cat /sys/class/hwmon/hwmon2/fan1_input)
|
||||
fi
|
||||
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#*=}
|
||||
fi
|
||||
# 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[${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[${SENSORa}]} "/opt/idssys/defaults/get-data.sh cpu-usage")
|
||||
fi
|
||||
else
|
||||
temp_f_disp=${temp_f}
|
||||
if [ "${1}" != "" ]; then
|
||||
average1_disp=${average1}
|
||||
average7_disp=${average7}
|
||||
temp_c=''
|
||||
fi
|
||||
|
||||
if [ "${1}" != "" ]; then
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
||||
average1=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 1 ${vSENSOR// /_})
|
||||
average7=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 7 ${vSENSOR// /_})
|
||||
# average7=0
|
||||
else
|
||||
average1=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 1)
|
||||
average7=$(AVERAGETEMP ${PW_SENSOR_ID[${SENSORa}]} 7)
|
||||
# average7=0
|
||||
fi
|
||||
fi
|
||||
[ "${1}" != "" ] && echo -e "${SENSOR}${spc}${temp_f_disp}${GAUGESH} / ${average1_disp}${GAUGESH} / ${average7_disp}${GAUGESH}" || echo -e "${SENSOR}${spc}${temp_f_disp}${GAUGESH}"
|
||||
|
||||
else
|
||||
echo -e "${SENSOR}${spc}No Data"
|
||||
|
||||
fi
|
||||
last_sensor=${SENSORa%%-*}
|
||||
done
|
||||
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
|
||||
if [ "${SENSOR}" == "ServerRoomTH" ]; then
|
||||
temp_f=`echo "scale=2; ${temp_c}*1.8+32+${PW_ServerRoomTH_Dev}" | bc`
|
||||
else
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ]; then
|
||||
temp_f=$(echo "scale=2; $temp_c/1" | bc -l)
|
||||
elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
temp_f=${temp_c}
|
||||
else
|
||||
temp_f=$(bc <<< "scale=2; ${temp_c}*1.8+32")
|
||||
fi
|
||||
(( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}"
|
||||
fi
|
||||
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]; then
|
||||
temp_f_disp=$(IDS_NUMBER_FORMAT ${temp_f})
|
||||
if [ "${1}" != "" ]; then
|
||||
average1_disp=$(IDS_NUMBER_FORMAT ${average1})
|
||||
average7_disp=$(IDS_NUMBER_FORMAT ${average7})
|
||||
fi
|
||||
else
|
||||
temp_f_disp=${temp_f}
|
||||
if [ "${1}" != "" ]; then
|
||||
average1_disp=${average1}
|
||||
average7_disp=${average7}
|
||||
fi
|
||||
fi
|
||||
[ "${1}" != "" ] && echo -e "${SENSOR}${spc}${temp_f_disp}${GAUGESH} / ${average1_disp}${GAUGESH} / ${average7_disp}${GAUGESH}" || echo -e "${SENSOR}${spc}${temp_f_disp}${GAUGESH}"
|
||||
|
||||
else
|
||||
echo -e "${SENSOR}${spc}No Data"
|
||||
|
||||
fi
|
||||
last_sensor=${SENSORa%%-*}
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user