diff --git a/powerwall.sh b/powerwall.sh index e382dcce..d6a56ec4 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -68,44 +68,44 @@ 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 - echo "($datetime) alert sent" >> ${logsrvc} + echo "($datetime) - ${temp_f}F - alert sent" >> ${logsrvc} last_temp=$temp_f fi - echo "($datetime) WARNING TEMP: ${temp_f}°F - (Difference of ${temp_diff}°) - alert sent" >> ${logsrvc} + echo "($datetime) - ${temp_f}F - WARNING TEMP - (Difference of ${temp_diff}°)" >> ${logsrvc} 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}°)" >> ${logsrvc} + echo "($datetime) - ${temp_f} F - CRITICAL - (Difference of ${temp_diff} F)" >> ${logsrvc} 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 "($datetime) alert sent" >> ${logsrvc} + echo "($datetime) - ${temp_f}F - alert sent" >> ${logsrvc} last_temp=$temp_f # 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" >> ${logsrvc} + echo -e "($datetime) - ${temp_f}F - Main servers have been shutdown" >> ${logsrvc} fi elif [ $(bc -l <<< "$temp_f >= $temp_crit_sys") -eq 1 ]; then - echo "($datetime) SYSTEM CRITICAL: ${temp_f} F - (Difference of ${temp_diff}°)" >> ${logsrvc} + echo "($datetime) - ${temp_f}F - SYSTEM CRITICAL - (Difference of ${temp_diff})" >> ${logsrvc} 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 "($datetime) alert sent" >> ${logsrvc} + echo "($datetime) - ${temp_f}F - alert sent" >> ${logsrvc} last_temp=$temp_f # SHUTDOWN_SERVERS SYS echo -e "($datetime) System servers have been shutdown" | mail -s "SERVERS SHUTDOWN" $email_alert - echo -e "($datetime) System servers have been shutdown" >> ${logsrvc} + echo -e "($datetime) - ${temp_f}F - System servers have been shutdown" >> ${logsrvc} fi 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 - echo -e "($datetime) Back to NORMAL TEMP: ${temp_f} F - Previous Temp: ${last_temp} F" >> ${logsrvc} + echo -e "($datetime) - ${temp_f}F - Back to NORMAL TEMP - Previous Temp: ${last_temp}F" >> ${logsrvc} echo "($datetime) alert sent" >> ${logsrvc} elif [ $last_temp -eq 0 ]; then echo -e "($datetime) Service Startup\n NORMAL TEMP: ${temp_f}°F" | mail -s "${1} TEMP NORMAL" $email_alert; - echo -e "($datetime) Service Startup - NORMAL TEMP: ${temp_f} F" >> ${logsrvc} + echo -e "($datetime) - ${temp_f}F - Service Startup - NORMAL TEMP" >> ${logsrvc} fi last_temp=1 errtime=$(expr `date +%s` - $(stat -c %Y ${logsrvc})) - [ $errtime -ge 10 ] && echo "($datetime) Normal Temp: ${temp_f} F" >> ${logsrvc} + [ $errtime -ge 10 ] && echo "($datetime) - ${temp_f}F - Normal Temp" >> ${logsrvc} fi QRY="USE servermonitor; INSERT INTO sensor_data (\`sensorid\`, \`date\`, \`temp\`, \`hum\`) VALUES ('${SENSOR_ID[$1]}','${datetime}','${temp_f}','${temp_h}')"