This commit is contained in:
2023-05-14 16:47:05 -05:00
parent 80f5dd3df6
commit 73d31c4f7c

View File

@@ -16,23 +16,29 @@ VERBOSE=false
#ssh root@10.5.10.35 '/vmfs/volumes/NFS_ESXi-Vault/esxi-shutdown.sh > /dev/null 2>&1' & > /dev/null 2>&1 #ssh root@10.5.10.35 '/vmfs/volumes/NFS_ESXi-Vault/esxi-shutdown.sh > /dev/null 2>&1' & > /dev/null 2>&1
CHECKTEMP(){ CHECKTEMP(){
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` [ "${1}" != "" ] && SENSORS=("${1}") || SENSORS=${SENSOR_ID[@]}
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
#echo "$temp_c -> $temp_f"
echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn for SENSOR in ${SENSORS[@]}; do
echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit echo "HERE: $SENSOR"
done
if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then # mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
echo "WARNING: $temp_f°F" # echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then # if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
echo "CRITICAL: $temp_f°F" # temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
else # #echo "$temp_c -> $temp_f"
echo "normal: $temp_f°F" #
fi # echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
fi # echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
#
# if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
# echo "WARNING: $temp_f°F"
# elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then
# echo "CRITICAL: $temp_f°F"
# else
# echo "normal: $temp_f°F"
# fi
# fi
} }
CHECKTEMP_SERVICE(){ CHECKTEMP_SERVICE(){
@@ -40,10 +46,8 @@ CHECKTEMP_SERVICE(){
[ ! -f ${logsrvc} ] && touch ${logsrvc} [ ! -f ${logsrvc} ] && touch ${logsrvc}
last_temp=0 last_temp=0
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
while true while true; do
do ${mqtt_conn} -t tele/${1}/SENSOR | while read -r mqtt_message; do
${mqtt_conn} -t tele/${1}/SENSOR | while read -r mqtt_message
do
echo $mqtt_message | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h echo $mqtt_message | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
echo $mqtt_message | cut -d'T' -f 2 | cut -d"\"" -f 3 | read temp_d echo $mqtt_message | cut -d'T' -f 2 | cut -d"\"" -f 3 | read temp_d
@@ -207,8 +211,7 @@ CHECKACV_SERVICE(){
} }
POWERLOGGER_SERVICE(){ POWERLOGGER_SERVICE(){
while true while true; do
do
datetime=`date +'%Y-%m-%d %H:%M:%S'` datetime=`date +'%Y-%m-%d %H:%M:%S'`
JSONSTATS=$(curl -s "http://10.10.0.61/stats.json") JSONSTATS=$(curl -s "http://10.10.0.61/stats.json")