Update powerwall.sh
This commit is contained in:
16
powerwall.sh
16
powerwall.sh
@@ -66,16 +66,16 @@ CHECKTEMP_SERVICE(){
|
|||||||
if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
|
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
|
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
|
echo "($datetime) WARNING TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)" | mail -s "${1} TEMP WARNING" $email_alert
|
||||||
echo "alert sent"
|
[ $VERBOSE = true ] && echo "alert sent"
|
||||||
last_temp=$temp_f
|
last_temp=$temp_f
|
||||||
fi
|
fi
|
||||||
echo "($datetime) WARNING: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
[ $VERBOSE = true ] && echo "($datetime) WARNING: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||||
|
|
||||||
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit_sys") -eq 1 ]; then
|
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit_sys") -eq 1 ]; then
|
||||||
echo "($datetime) CRITICAL: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
[ $VERBOSE = true ] && echo "($datetime) CRITICAL: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||||
if [ $temp_diff -gt 1 ] || [ "$last_temp" = "1" ]; then
|
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
|
echo -e "($datetime) CRITICAL TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)\nShutting down servers!!" | mail -s "${1} TEMP CRITICAL" $email_alert
|
||||||
echo "alert sent"
|
[ $VERBOSE = true ] && echo "alert sent"
|
||||||
last_temp=$temp_f
|
last_temp=$temp_f
|
||||||
SHUTDOWN_SERVERS MAIN
|
SHUTDOWN_SERVERS MAIN
|
||||||
echo -e "($datetime) Main servers have been shutdown" | mail -s "SERVERS SHUTDOWN" $email_alert
|
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}°)"
|
echo "($datetime) SYSTEM CRITICAL: ${temp_f}°F - (Difference of ${temp_diff}°)"
|
||||||
if [ $temp_diff -gt 1 ] || [ "$last_temp" = "1" ]; then
|
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
|
echo -e "($datetime) SYSTEM CRITICAL TEMP: ${temp_f}°F - (Difference of ${temp_diff}°)\nShutting down system servers!!" | mail -s "${1} TEMP CRITICAL" $email_alert
|
||||||
echo "alert sent"
|
[ $VERBOSE = true ] && echo "alert sent"
|
||||||
last_temp=$temp_f
|
last_temp=$temp_f
|
||||||
SHUTDOWN_SERVERS SYS
|
SHUTDOWN_SERVERS SYS
|
||||||
echo -e "($datetime) System servers have been shutdown\nAll servers are now offline" | mail -s "SERVERS SHUTDOWN" $email_alert
|
echo -e "($datetime) System servers have been shutdown\nAll servers are now offline" | mail -s "SERVERS SHUTDOWN" $email_alert
|
||||||
@@ -93,19 +93,19 @@ CHECKTEMP_SERVICE(){
|
|||||||
else
|
else
|
||||||
if [ $last_temp -gt 1 ]; then
|
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
|
echo -e "($datetime) NORMAL TEMP: ${temp_f}°F\nPrevious Temp: ${last_temp}°F" | mail -s "${1} BACK TO NORMAL" $email_alert
|
||||||
echo "alert sent"
|
[ $VERBOSE = true ] && echo "alert sent"
|
||||||
elif [ $last_temp -eq 0 ]; then
|
elif [ $last_temp -eq 0 ]; then
|
||||||
echo "NORMAL TEMP: ${temp_f}°F" | mail -s "${1} TEMP NORMAL" $email_alert;
|
echo "NORMAL TEMP: ${temp_f}°F" | mail -s "${1} TEMP NORMAL" $email_alert;
|
||||||
fi
|
fi
|
||||||
last_temp=1
|
last_temp=1
|
||||||
echo "($datetime) normal: ${temp_f}°F"
|
[ $VERBOSE = true ] && echo "($datetime) normal: ${temp_f}°F"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
QRY="USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`, \`hum\`) VALUES ('${SENSOR_ID[$1]}','${datetime}','${temp_f}','${temp_h}')"
|
QRY="USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`, \`hum\`) VALUES ('${SENSOR_ID[$1]}','${datetime}','${temp_f}','${temp_h}')"
|
||||||
${mysql_conn} -e "${QRY}"
|
${mysql_conn} -e "${QRY}"
|
||||||
else
|
else
|
||||||
echo "($datetime) ERROR reading temperature" | mail -s "${1} ERROR" $email_alert
|
echo "($datetime) ERROR reading temperature" | mail -s "${1} ERROR" $email_alert
|
||||||
echo "alert sent"
|
[ $VERBOSE = true ] && echo "alert sent"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|||||||
Reference in New Issue
Block a user