Update powerwall.sh
This commit is contained in:
19
powerwall.sh
19
powerwall.sh
@@ -66,7 +66,7 @@ CHECKTEMP_SERVICE(){
|
||||
if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
|
||||
if [ $temp_diff -gt 1 ] || [ "$last_temp" = "1" ]; then
|
||||
echo "($datetime) WARNING TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)" | mail -s "${1} TEMP WARNING" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
last_temp=$temp_f
|
||||
fi
|
||||
[ $VERBOSE = true ] && echo "($datetime) WARNING: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||
@@ -75,7 +75,7 @@ CHECKTEMP_SERVICE(){
|
||||
[ $VERBOSE = true ] && echo "($datetime) CRITICAL: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||
if [ $temp_diff -gt 1 ] || [ "$last_temp" = "1" ]; then
|
||||
echo -e "($datetime) CRITICAL TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)\nShutting down servers!!" | mail -s "${1} TEMP CRITICAL" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
last_temp=$temp_f
|
||||
SHUTDOWN_SERVERS MAIN
|
||||
echo -e "($datetime) Main servers have been shutdown" | mail -s "SERVERS SHUTDOWN" $email_alert
|
||||
@@ -85,7 +85,7 @@ CHECKTEMP_SERVICE(){
|
||||
echo "($datetime) SYSTEM CRITICAL: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||
if [ $temp_diff -gt 1 ] || [ "$last_temp" = "1" ]; then
|
||||
echo -e "($datetime) SYSTEM CRITICAL TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)\nShutting down system servers!!" | mail -s "${1} TEMP CRITICAL" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
last_temp=$temp_f
|
||||
SHUTDOWN_SERVERS SYS
|
||||
echo -e "($datetime) System servers have been shutdown\nAll servers are now offline" | mail -s "SERVERS SHUTDOWN" $email_alert
|
||||
@@ -93,7 +93,7 @@ CHECKTEMP_SERVICE(){
|
||||
else
|
||||
if [ $last_temp -gt 1 ]; then
|
||||
echo -e "($datetime) NORMAL TEMP: ${temp_f}°F\nPrevious Temp: ${last_temp}°F" | mail -s "${1} BACK TO NORMAL" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
elif [ $last_temp -eq 0 ]; then
|
||||
echo -e "($datetime) Service Startup\n NORMAL TEMP: ${temp_f}°F" | mail -s "${1} TEMP NORMAL" $email_alert;
|
||||
fi
|
||||
@@ -105,7 +105,7 @@ CHECKTEMP_SERVICE(){
|
||||
${mysql_conn} -e "${QRY}"
|
||||
else
|
||||
echo "($datetime) ERROR reading temperature" | mail -s "${1} ERROR" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
fi
|
||||
done
|
||||
sleep 10
|
||||
@@ -122,12 +122,12 @@ CHECKACV_SERVICE(){
|
||||
if [ $voltstatus -eq 3 ]; then
|
||||
[ $VERBOSE = true ] && echo "($datetime) back to normal voltage: ${INPUTACV}V"
|
||||
echo -e "($datetime) Normal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "POWER NOMINAL AGAIN" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
else
|
||||
[ $VERBOSE = true ] && echo "($datetime) normal voltage: ${INPUTACV}V"
|
||||
if [ $voltstatus -eq 0 ]; then
|
||||
echo -e "($datetime) Service Startup\nNormal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "Power Nominal" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
fi
|
||||
fi
|
||||
voltstatus=1
|
||||
@@ -135,9 +135,12 @@ CHECKACV_SERVICE(){
|
||||
echo "($datetime) LOW voltage: ${INPUTACV}V"
|
||||
if [ $voltstatus -lt 3 ]; then
|
||||
echo -e "($datetime) Power off or low voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "POWER ALERT - LOW POWER!!" $email_alert
|
||||
[ $VERBOSE = true ] && echo "alert sent"
|
||||
[ $VERBOSE = true ] && echo "($datetime) alert sent"
|
||||
fi
|
||||
voltstatus=3
|
||||
BATTVOLT=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs ..battV')
|
||||
[ $VERBOSE = true ] && echo "($datetime) Battery Voltage: ${BATTVOLT}V"
|
||||
|
||||
fi
|
||||
sleep 10
|
||||
done # &
|
||||
|
||||
Reference in New Issue
Block a user