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.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 6th June 2013, 17:49
danhansen@denmark danhansen@denmark is offline
Senior Member
 
Join Date: Mar 2013
Posts: 249
Thanks: 53
Thanked 4 Times in 4 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 17:53.
Reply With Quote
Sponsored Links
 

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 22:39
Connection timed out on intermail outgoing mails gouravgarg Server Operation 6 5th March 2010 21:31
amavis rejects all inbound emails aclhkaclhk Installation/Configuration 5 28th February 2010 05:24
Unbale to login to Postfix from webmail wasimriz HOWTO-Related Questions 5 6th April 2009 14:49
ISPConfig3 mail issues warlock Developers' Forum 19 26th January 2009 11:34


All times are GMT +2. The time now is 14:33.


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