Files
powerwall/powerwall.sh
2022-09-03 11:28:48 -05:00

46 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# powerwall - CLI commands to control VM guest power
action="$1"
FOLDER='/opt/idssys/powerwall'
VERS='1.030921'
source /opt/idssys/powerwall/defaults.inc
source /opt/idssys/powerwall/powerwall.conf
source /opt/idssys/defaults/colors.inc
source /opt/idssys/defaults/default.inc
shopt -s lastpipe
#ssh root@10.5.10.35 '/vmfs/volumes/NFS_ESXi-Vault/esxi-shutdown.sh > /dev/null 2>&1' & > /dev/null 2>&1
CHECKTEMP(){
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
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"
if [ $temp_f -ge ${TEMP_THRESHOLDS[${1}]['warn']} ] && [ $temp_f -lt ${TEMP_THRESHOLDS[${1}]['crit']} ]; then
echo "WARNING: $temp_f"
elif [ $temp_f -ge ${TEMP_THRESHOLDS[${1}]['crit']} ]; then
echo "CRITICAL: $temp_f"
else
echo "normal: $temp_f"
fi
fi
}
if [ ${action-x} ]; then
case $action in
checktemp) CHECKTEMP ${2};;
esac
fi
exit 0