update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
VERS='2.3.300-12032023'
|
||||
VERS='2.3.320-12032023'
|
||||
|
||||
noheader=' update service dailytemp '
|
||||
|
||||
@@ -37,11 +37,13 @@ declare -A PW_TEMP_THRESHOLDS
|
||||
# PW_TEMP_THRESHOLDS['ServerRoomTH']="83,88,95" #Normal broken
|
||||
PW_TEMP_THRESHOLDS['ServerRoomTH']="78,85,91" #Normal -4
|
||||
PW_TEMP_THRESHOLDS['Powerwall-CPU']="122,131,176"
|
||||
PW_TEMP_THRESHOLDS['Powerwall-CPU-Usage']="40,80"
|
||||
PW_TEMP_THRESHOLDS['OctoPI-CPU']="122,131,176"
|
||||
|
||||
declare -A PW_SENSOR_TYPE
|
||||
PW_SENSOR_TYPE['ServerRoomTH']='mqtt'
|
||||
PW_SENSOR_TYPE['Powerwall-CPU']='system'
|
||||
PW_SENSOR_TYPE['Powerwall-CPU-Usage']='cpu'
|
||||
PW_SENSOR_TYPE['OctoPI-CPU']='remotesystem'
|
||||
PW_SENSOR_TYPE['iDS-vMS-Host0']='esxi'
|
||||
PW_SENSOR_TYPE['iDS-vMS-Host1']='esxi'
|
||||
@@ -54,6 +56,7 @@ PW_SENSOR_TYPE['OFF-vMS-Host1']='esxi'
|
||||
|
||||
declare -A PW_REMOTE_SENSORS
|
||||
PW_REMOTE_SENSORS['Powerwall-CPU']='127.0.0.1'
|
||||
PW_REMOTE_SENSORS['Powerwall-CPU-Usage']='127.0.0.1'
|
||||
PW_REMOTE_SENSORS['ServerRoomTH']='10.10.20.10'
|
||||
PW_REMOTE_SENSORS['OctoPI-CPU']='10.10.1.80'
|
||||
|
||||
@@ -148,6 +151,8 @@ PW_OFFSITEHOSTS=(${PW_OFFSITEHOSTS})
|
||||
PW_ALLHOSTS=(${PW_ALL_HOSTS})
|
||||
unset IFS
|
||||
|
||||
# RNIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
|
||||
SENDNOTICE(){
|
||||
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
||||
|
||||
|
||||
56
powerwall.sh
56
powerwall.sh
@@ -90,6 +90,27 @@ CHECKTEMP(){
|
||||
reading=$(CHECKTEMPSENSOR ${SENSOR} . . . . ${avgdays})
|
||||
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
echo -e "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}"
|
||||
|
||||
if [ "${SENSOR}" == "Powerwall-CPU" ]; then
|
||||
CPUPER=$(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))
|
||||
echo ${PW_TEMP_THRESHOLDS['Powerwall-CPU-Usage']} | cut -d',' -f 1 | read cpu_warn
|
||||
echo ${PW_TEMP_THRESHOLDS['Powerwall-CPU-Usage']} | cut -d',' -f 2 | read cpu_crit
|
||||
|
||||
msg="Powerwall-CPU Processor Usage"
|
||||
c=0; spc=''; spc1=`expr ${cw} - ${#msg}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${msg}${idsST[Reset]}${spc}${idsCL[Default]}: "
|
||||
|
||||
if [ $(bc -l <<< "${CPUPER} >= ${cpu_warn}") -eq 1 ] && [ $(bc -l <<< "${CPUPER} < ${cpu_crit}") -eq 1 ]; then
|
||||
echo -en "${idsCL[Yellow]}WARNING ${spct}${CPUPER}%${idsCL[Default]}"
|
||||
elif [ $(bc -l <<< "${CPUPER} >= ${cpu_crit}") -eq 1 ]; then
|
||||
echo -en "${idsCL[Red]}CRITICAL${spct}${CPUPER}%${idsCL[Default]}"
|
||||
else
|
||||
echo -en "${idsCL[Green]}Normal ${spct}${CPUPER}%${idsCL[Default]}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
@@ -131,39 +152,54 @@ CHECKTEMPSENSOR(){
|
||||
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
|
||||
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))
|
||||
else
|
||||
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "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))"
|
||||
fi
|
||||
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
|
||||
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
|
||||
fi
|
||||
|
||||
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
|
||||
temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32")
|
||||
[ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ] && temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32") || temp_f=temp_c
|
||||
#echo "${temp_c} -> ${temp_f}"
|
||||
c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ ${c} = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done
|
||||
|
||||
if [ "${average}" != "" ]; then
|
||||
if [ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]; then
|
||||
c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ ${c} = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
|
||||
if [ "${average}" == "" ]; then
|
||||
averagedisp="${idsCL[Green]}"
|
||||
elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
|
||||
averagedisp="${idsCL[Yellow]}${average}'F"
|
||||
averagedisp="${idsCL[Yellow]}${average}"
|
||||
elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
|
||||
averagedisp="${idsCL[Red]}${average}'F"
|
||||
averagedisp="${idsCL[Red]}${average}"
|
||||
else
|
||||
averagedisp="${idsCL[Green]}${average}'F"
|
||||
averagedisp="${idsCL[Green]}${average}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then
|
||||
[ "${average}" != "" ] && echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}'F${idsCL[Default]}"
|
||||
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}${idsCL[Default]}"
|
||||
elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ]; then
|
||||
[ "${average}" != "" ] && echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}'F${idsCL[Default]}"
|
||||
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}${idsCL[Default]}"
|
||||
else
|
||||
[ "${average}" != "" ] && echo -en "${idsCL[Green]}Normal ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Green]}Normal ${spct}${temp_f}'F${idsCL[Default]}"
|
||||
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Green]}Normal ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Green]}Normal ${spct}${temp_f}${idsCL[Default]}"
|
||||
fi
|
||||
[ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ] && echo -en "%" || echo -en "'F"
|
||||
|
||||
tmp="${spct}${temp_f}"
|
||||
c=0; spc=''; spc1=`expr 10 - ${#tmp}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
|
||||
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
|
||||
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
||||
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}'F${idsCL[Default]} /${spcc}${idsCL[Red]}${temp_crit}'F=>${idsCL[Default]} ]"
|
||||
if [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
|
||||
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}%${idsCL[Default]} /${spcc}${idsCL[Red]}${temp_crit}%=>${idsCL[Default]} ]"
|
||||
|
||||
else
|
||||
echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}'F${idsCL[Default]} /${spcc}${idsCL[Red]}${temp_crit}'F=>${idsCL[Default]} ]"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
AVERAGETEMP(){
|
||||
|
||||
Reference in New Issue
Block a user