Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > ISPConfig 3 Priority Support

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th June 2013, 16:49
danhansen@denmark danhansen@denmark is offline
HowtoForge Supporter
 
Join Date: Mar 2013
Posts: 176
Thanks: 36
Thanked 3 Times in 3 Posts
Exclamation ISPconfig3 - Ubuntu 12.04.2 - ShellScript issues -> LMsensors

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.0C (low = +127.0C, high = +127.0C) sensor = thermistor
temp2: -12.0C (low = +127.0C, high = +127.0C) sensor = thermistor
temp3: +44.0C (low = +127.0C, high = +127.0C) 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 warning@domain.tld </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]
__________________
Kind Regards
Dan

__________________________________________________ _______
Fixed IP/WAN
DMZ -> "ispserverip"
Primary NameServer -> ns1.myprimarynameserver.tld
Secondary NameServer -> ns2.somedomainservice.tld

Ubuntu Server 12.04.4
ISPconfig 3 v.3.0.5.2 (Single Server Setup)
NameServer: BIND v.9.8.1-P1
SquirrelMail: v.1.4.22
MailServer: PostFix v.2.9.6 - IMAP/POP3 Dovecot v.2.0.19
Database: MySQL Server v.5.5.29-0ubuntu0.12.04.2
Tutorial: "ThePerfectServer-ISPconfig3-Ubuntu12.04"

Last edited by danhansen@denmark; 6th June 2013 at 16:53.
Reply With Quote
Sponsored Links
  #2  
Old 7th June 2013, 09:33
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 34,586
Thanks: 792
Thanked 4,983 Times in 3,903 Posts
Default

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
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 7th June 2013, 10:10
danhansen@denmark danhansen@denmark is offline
HowtoForge Supporter
 
Join Date: Mar 2013
Posts: 176
Thanks: 36
Thanked 3 Times in 3 Posts
 
Default

Hi,

thanks for your reply. I will try that..
__________________
Kind Regards
Dan

__________________________________________________ _______
Fixed IP/WAN
DMZ -> "ispserverip"
Primary NameServer -> ns1.myprimarynameserver.tld
Secondary NameServer -> ns2.somedomainservice.tld

Ubuntu Server 12.04.4
ISPconfig 3 v.3.0.5.2 (Single Server Setup)
NameServer: BIND v.9.8.1-P1
SquirrelMail: v.1.4.22
MailServer: PostFix v.2.9.6 - IMAP/POP3 Dovecot v.2.0.19
Database: MySQL Server v.5.5.29-0ubuntu0.12.04.2
Tutorial: "ThePerfectServer-ISPconfig3-Ubuntu12.04"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating ISPConfig3 - Ubuntu Server 10.04 danhansen@denmark HOWTO-Related Questions 1 18th March 2013 21:39
Connection timed out on intermail outgoing mails gouravgarg Server Operation 6 5th March 2010 20:31
amavis rejects all inbound emails aclhkaclhk Installation/Configuration 5 28th February 2010 04:24
Unbale to login to Postfix from webmail wasimriz HOWTO-Related Questions 5 6th April 2009 13:49
ISPConfig3 mail issues warlock Developers' Forum 19 26th January 2009 10:34


All times are GMT +2. The time now is 15:25.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.