Receiving Emails Every Minute, on the Minute

Post Reply
BRisher777
Member
Member
Posts: 5
Joined: August 12th, 2012, 2:02 pm

Receiving Emails Every Minute, on the Minute

Post by BRisher777 »

Hello all,

Let me preface my post by saying that this guide is amazing and provided a DIY'r ample direction on building a home media server. I haven't played around with everything yet (KVM and some others), but I doubt I could have accomplished this half as well without this guide.

Now for my problem, lol.

I am receiving an email from my server every minute. It's the CPU script, as far as I can tell from the email. I've uploaded my ssmtp.conf, the script that I've edited, and the email message that I'm receiving. Any help in figuring out where my setup skills failed would be greatly appreciated!

Also, my cron job command reads:

/home/ben/MyScripts/CPUTempShutdown.sh 35 45 > /dev/null

I have 3 cron jobs I made with the help of this guide, and this particular one is the offender. It's the only one I turned off, and that stopped the email spam.

Again, I would be grateful for any help. Thank you very much!

-Ben

EDIT: I guess it would be helpful to say that my CPU's aren't actually reaching the temperature where the IF statement should be activated.

acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +103.0°C)
temp2: +29.8°C (crit = +103.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +32.0°C (high = +82.0°C, crit = +102.0°C)
Core 0: +31.0°C (high = +82.0°C, crit = +102.0°C)
Core 1: +28.0°C (high = +82.0°C, crit = +102.0°C)

This is the output from 'sudo sensors'
Attachments
ssmtp.conf - Ben.txt
(711 Bytes) Downloaded 239 times
CPUTempScript - ben.txt
(2.34 KiB) Downloaded 260 times
EmailMessage - ben.txt
(585 Bytes) Downloaded 232 times
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Receiving Emails Every Minute, on the Minute

Post by Ian »

Hi Ben and welcome to the forums.

OK, it looks like the reason you're getting those emails is because you've not configured the script properly. I wrote it to suit the output from my server, the output from yours is slightly different. No big deal tho. From the output you posted it looks like you need to change line 47 which currently reads

Code: Select all

newstr=${str:14:2}
to

Code: Select all

 newstr=${str:9:2}
Then try and run the script again and see what output you get. You should see something along the lines of 'Both CPU Cores are within limits' rather than what you were getting before.

Good luck :thumbup:

Ian.
BRisher777
Member
Member
Posts: 5
Joined: August 12th, 2012, 2:02 pm

Re: Receiving Emails Every Minute, on the Minute

Post by BRisher777 »

The original problem is good to go now, thank you very much!
After making the change, when I run it from the CLI, I get this:


JOB RUN AT Sun Aug 12 12:43:43 CDT 2012
=======================================

CPU Warning Limit set to => 35
CPU Shutdown Limit set to => 45


acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +103.0°C)
temp2: +29.8°C (crit = +103.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +33.0°C (high = +82.0°C, crit = +102.0°C)
Core 0: +30.0°C (high = +82.0°C, crit = +102.0°C)
Core 1: +27.0°C (high = +82.0°C, crit = +102.0°C)



./CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
./CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
Temperature Core 0 OK at =>

./CPUTempShutdown.sh: line 49: [: -ge: unary operator expected
./CPUTempShutdown.sh: line 59: [: -ge: unary operator expected
Temperature Core 1 OK at =>

Both CPU Cores are within limits

I googled unary operators, didn't help me out much... lol. Any thoughts?

EDIT: Actually, let me retract that statement. I have 18 new emails.... :lol: It's emailing me the 4 lines that are expecting unary operators.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Receiving Emails Every Minute, on the Minute

Post by Ian »

Maybe I can't count or maybe the forum is messing with the output. Basically from this output:

Code: Select all

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +33.0°C (high = +82.0°C, crit = +102.0°C)
Core 0: +30.0°C (high = +82.0°C, crit = +102.0°C)
Core 1: +27.0°C (high = +82.0°C, crit = +102.0°C)


You're trying to pull out the 30 and the 27 from the lines which start "Core...." To me this look like position 9 but given the script is still bleating then obviously it's not.

So, add the following two lines to your script after the line which reads newstr=${str:9:2}

Code: Select all

echo str $str
echo newstr $newstr


Then, tinker with the newstr=${str:9:2} (maybe it's 8:2 or 10:2) until you see the 30 and the 27 in the output. So, when you have it correct it'll say

str Core 0: +30.0°C (high = +82.0°C, crit = +102.0°C)
newstr 30
Temperature Core 0 OK at => 30

str Core 1: +27.0°C (high = +82.0°C, crit = +102.0°C)
newstr 33
Temperature Core 1 OK at => 27


Ian.
BRisher777
Member
Member
Posts: 5
Joined: August 12th, 2012, 2:02 pm

Re: Receiving Emails Every Minute, on the Minute

Post by BRisher777 »

BAM! lol

It's working now. The formatting got a little wonky from my ssh to the forums. There was actually a tab or a bunch of spaces in there that wasn't being displayed when I C&P'd it. It ended up being 17:2. (I had to google what that str:x:x command was doing, then counted appropriately, lol). Thank you very much for your help!

#IansTheMan
Post Reply