Hi, Creating Shell Script Cron-Job Application: LMsensors Shell Script funktions: 1. If CPU hot'er than X then sendmail and log 2. If CPU hot'er than Y then sendmail, log and shutdown Problems: 1. Script works regarding log'ing and shut'ing down - but I'm having trouble getting the script to sendmail (and to put text into the mail/sending msg.txt) LMsensors Print - Command "sensors" root@server1:/home/user# sensors it8712-isa-0290 Adapter: ISA adapter in0: +1.52 V (min = +0.00 V, max = +4.08 V) in1: +1.47 V (min = +0.00 V, max = +4.08 V) in2: +3.30 V (min = +0.00 V, max = +4.08 V) in3: +3.01 V (min = +0.00 V, max = +4.08 V) in4: +3.06 V (min = +0.00 V, max = +4.08 V) in5: +2.30 V (min = +0.00 V, max = +4.08 V) in6: +1.36 V (min = +0.00 V, max = +4.08 V) in7: +3.04 V (min = +0.00 V, max = +4.08 V) Vbat: +4.08 V fan1: 7670 RPM (min = 0 RPM, div = 8) fan3: 0 RPM (min = 0 RPM, div = 8) temp1: +25.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor temp2: -12.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor temp3: +44.0°C (low = +127.0°C, high = +127.0°C) sensor = thermal diode cpu0_vid: +1.525 V intrusion0: ALARM Running Script and setting variables $1 and $2 using the line command: ./CPUTempShutdown.sh 30 60 [BEGIN SCRIPT] echo "JOB RUN AT $(date)" echo "=============================================" echo '' echo 'CPU Warning Limit set to => '$1 echo 'CPU Shutdown Limit set to => '$2 echo '' echo '' sensors echo '' echo '' str=$(sensors | grep "temp1:") newstr=${str:15:2} if [ ${newstr} -ge $1 ] # LOG'GING WORKS JUST FINE. NEED TO MAIL AS WELL USING SENDMAIL then echo '============================================' >>/home/user/MonitorHardware/CPUWarning.Log echo $(date) >>/home/user/MonitorHardware/CPUWarning.Log echo '' >>/home/user/MonitorHardware/CPUWarning.Log echo ' WARNING: TEMPERATURE CORE EXCEEDED' $1 '=>' $newstr >>/home/user/MonitorHardware/CPUWarning.Log echo '' >>/home/user/MonitorHardware/CPUWarning.Log echo '============================================' >>/home/user/MonitorHardware/CPUWarning.Log fi if [ ${newstr} -ge $2 ] # SHUTDOWN WORKS JUST FINE. NEED TO LOG AND MAIL AS WELL USING SENDMAIL then echo '============================================' echo '' echo 'CRITICAL: TEMPERATURE CORE EXCEEDED' $2 '=>' $newstr echo '' echo '============================================' /sbin/shutdown -h now /usr/sbin/ssmtp [email protected] </home/user/MyScripts/HotCPU.txt echo 'Email Sent.....' exit else echo ' Temperature temp1 OK at =>' $newstr echo '' fi echo 'CPU Core is within limits' echo '' [END SCRIPT]
Normally you would use the sendmail compatibility binary on a postfix server to send mails from a shell script. So the command to send mail is: /usr/sbin/sendmail and not: /usr/sbin/ssmtp