Problems with cron table

thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Problems with cron table

Post by thebigbaddie »

I am following this wonderful guide but I have come across some issues that quite frankly I cannot solve on my own.

Problem 1: I was testing the effectiveness of the HDD temp script and to confirm it was working I set the values to a value that would trigger the shutdown. Specifically I used 15 and 25 as the numerical arguments. However now I cannot get back into my server to adjust the temps to the right values. Additionally I am noticing that I am not getting emails saying that my server has shutdown.

Problem 2: I am getting an error when trying to test the CPU Core temp script but I cannot post any specifics as I cant keep my server on for longer than a minute. Ill post more details when I can access the information.

####EDIT####

I got into my system and changed the values. Okay so here are my two scripts.

CPUTempShutdown

Code: Select all

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 ''

for i in 0 1
do

  str=$(sensors | grep "Core $i:")
  newstr=${str:14:2}

  if [ ${newstr} -ge $1 ]
  then
    echo '============================'                             >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
    echo $(date)                                                    >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
    echo ''                                                         >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
    echo ' WARNING: TEMPERATURE CORE' $i 'EXCEEDED' $1 '=>' $newstr >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
    echo ''                                                         >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
    echo '============================'                             >>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning.Log
  fi
  
  if [ ${newstr} -ge $2 ]
  then
    echo '============================'
    echo ''
    echo 'CRITICAL: TEMPERATURE CORE' $i 'EXCEEDED' $2 '=>' $newstr
    echo ''
    echo '============================'
    /sbin/shutdown -h now
    /usr/sbin/ssmtp dylan.server244@gmail.com </home/thebigbaddie/Documents/CoreTempLogMsgs/msg.txt
    echo 'Email Sent.....'
    exit
  else
    echo ' Temperature Core '$i' OK at =>' $newstr
    echo ''
  fi
done

echo 'Both CPU Cores are within limits'
echo ''
If I run that in webmin I get the following errors.

Code: Select all

/home/thebigbaddie/Documents/MyScripts/CPUTempShutdown.sh: line 47: [: -ge: unary operator expected
/home/thebigbaddie/Documents/MyScripts/CPUTempShutdown.sh: line 57: [: -ge: unary operator expected
/home/thebigbaddie/Documents/MyScripts/CPUTempShutdown.sh: line 47: [: -ge: unary operator expected
/home/thebigbaddie/Documents/MyScripts/CPUTempShutdown.sh: line 57: [: -ge: unary operator expected
Next problem, I am not getting emails from either scripts. Here is the second script.

DriveTempShutdown

Code: Select all

echo "JOB RUN AT $(date)"
echo '============================'

echo ''
echo 'Drive Warning Limit set to =>' $1
echo 'Drive Shutdown Limit set to =>' $2
echo ''
echo ''

if [ $# -eq 2 ]
then
  MyList='a b c d e f'
  echo 'Testing all drives'
else 
  MyList=($3)
  echo 'Testing only the system drive'
fi

echo ''

for i in $MyList
do
  echo 'Drive /dev/sd'$i
  /usr/sbin/smartctl -n standby -a /dev/sd$i | grep Temperature_Celsius
done

echo ''
echo ''

for i in $MyList
do
 #Check state of drive 'active/idle' or 'standby'
  stra=$(/sbin/hdparm -C /dev/sd$i | grep 'drive' | awk '{print $4}')

  echo 'Testing Drive sd'$i

  if [ ${stra} = 'standby' ]
  then 
    echo '    Drive sd'$i 'is in standby'
    echo ''
  else

    str1='/usr/sbin/smartctl -n standby -a /dev/sd'$i
    str2=$($str1 | grep Temperature_Celsius | awk '{print $10}')

    if [ ${str2} -ge $1 ]
    then

      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo $(date)                                                    		>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo 'WARNING: TEMPERATURE FOR DRIVE sd'$i 'EXCEEDED' $1 '=>' $str2	>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
    fi

    if [ ${str2} -ge $2 ]
    then

      echo '============================'
      echo ''
      echo 'CRITICAL: TEMPERATURE FOR DRIVE sd'$i 'EXCEEDED' $2 '=>' $str2
      echo ''
      echo '============================'
      /sbin/shutdown -h now
      /usr/sbin/ssmtp dylan.server244@gmail.com </home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo 'Email Sent.....'
      exit
    else

      echo '    Temperature of Drive '$i' is OK at =>' $str2
      echo ''
    fi
  fi
done

echo 'All Drives are within limits'
echo ''
Here is the output from the sensors cmd.

Code: Select all

nct6776-isa-0290
Adapter: ISA adapter
Vcore:        +1.46 V  (min =  +0.00 V, max =  +1.74 V)
in1:          +0.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:         +3.33 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:        +3.33 V  (min =  +2.98 V, max =  +3.63 V)
in4:          +0.55 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:          +1.69 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:         +3.46 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:         +3.38 V  (min =  +2.70 V, max =  +3.30 V)  ALARM
fan1:           0 RPM  (min =    0 RPM)  ALARM
fan2:        3488 RPM  (min =    0 RPM)  ALARM
fan3:           0 RPM  (min =    0 RPM)  ALARM
fan4:           0 RPM  (min =    0 RPM)  ALARM
fan5:           0 RPM  (min =    0 RPM)  ALARM
SYSTIN:       +38.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:       +35.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:       -31.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
cpu0_vid:    +0.000 V
intrusion0:  ALARM
intrusion1:  ALARM

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +1.2°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)
Thanks for looking.
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

So I was looking over the scripts and I figured out why I was not getting emails. Please forgive me as I am new to linux. I have more experience with Java so if you can equate it that way it may be better.

As for the code, the script is executing the shutdown command before the email command. I reversed the order and commented out the shutdown command to make testing easier. Now I still cant test the CPUCore script without getting errors I posted above but I can execute the Drive script. When it runs it emails me the following:

Code: Select all

/home/thebigbaddie/Documents/MyScripts/DriveTempShutdown.sh: line 85: /home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt: No such file or directory
So I am guessing the file is not being created and I am not quite sure how to confirm this in linux. For curiosity sake what language is this? i.e. java, c++, etc
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

Okay I figured out that there was not msg.txt being created. I followed the same principle you were using for the log if statement and edited the script to reflect those actions. Here is the updated Drive script.

Code: Select all

#!/bin/bash

# PURPOSE: Script to check temperature of installed hard drives and report/shutdown if specified temperatures exceeded
#
# Expects three arguments:
#    1. Warning temperature
#    2. Critical shutdown temperature
#    3. If argument 3 is present then just check that drive letter
#    eg. using ./DriveTemps.sh 35 45
#	will warn when temperature of one or more drives reaches 35degrees and shutdown when any one of them hits 45
#    eg. using ./DriveTemps.sh 35 45 c
#	will warn when temperature of drive sdc reaches 35degrees and shutdown when it hits 45

# NOTES:
#  Change the string ">>/home/htkh" as required
#  Substitute string "myemail@myaddress.com" with your own email address in the string which starts "/usr/sbin/ssmtp myemail@myaddress.com"
#  Change the command   MyList='a b c d e' to the number of drives you have. In this case I'm using 6 drives

# Assumes  /usr/sbin/smartctl -n standby -a /dev/sd$i returns the string 'Temperature_Celsius' somewhere

echo "JOB RUN AT $(date)"
echo '============================'

echo ''
echo 'Drive Warning Limit set to =>' $1
echo 'Drive Shutdown Limit set to =>' $2
echo ''
echo ''

if [ $# -eq 2 ]
then
  MyList='a b c d e f'
  echo 'Testing all drives'
else 
  MyList=($3)
  echo 'Testing only the system drive'
fi

echo ''

for i in $MyList
do
  echo 'Drive /dev/sd'$i
  /usr/sbin/smartctl -n standby -a /dev/sd$i | grep Temperature_Celsius
done

echo ''
echo ''

for i in $MyList
do
 #Check state of drive 'active/idle' or 'standby'
  stra=$(/sbin/hdparm -C /dev/sd$i | grep 'drive' | awk '{print $4}')

  echo 'Testing Drive sd'$i

  if [ ${stra} = 'standby' ]
  then 
    echo '    Drive sd'$i 'is in standby'
    echo ''
  else

    str1='/usr/sbin/smartctl -n standby -a /dev/sd'$i
    str2=$($str1 | grep Temperature_Celsius | awk '{print $10}')

    if [ ${str2} -ge $1 ]
    then

      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo $(date)                                                    		>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo 'WARNING: TEMPERATURE FOR DRIVE sd'$i 'EXCEEDED' $1 '=>' $str2	>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
    fi

    if [ ${str2} -ge $2 ]
    then

      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo 'CRITICAL: TEMPERATURE FOR DRIVE sd'$i 'EXCEEDED' $2 '=>' $str2	>>/home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo ''									>>/home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo '============================'					>>/home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      /usr/sbin/ssmtp dylan.server244@gmail.com </home/thebigbaddie/Documents/HDDTempLogMsgs/msg.txt
      echo 'Email Sent.....'
      #/sbin/shutdown -h now
      exit
    else

      echo '    Temperature of Drive '$i' is OK at =>' $str2
      echo ''
    fi
  fi
done

echo 'All Drives are within limits'
echo ''
However now I am running into the issue of only getting information on sda. This is the hourly test that should test all 6 drives and report back. If I set the shutdown temp to 20, with my drives running at around 32, it should message me on all accounts. I know what I need to do to fix the script in java but alas this is not java. I need to loop and test all 6 drives and then report any findings if it is necessary. The present script is seeing sda is above the set temp and shutting down right then and not checking the rest of the drives. While it is shutting down I would rather know if all the drives temps are okay or atleast report them in addition to the drives temp that is over the critical value.

Another note, it seems that the script is merely adding to msg.txt as when I let it run it just seems to add another entry.
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

I am also seeing that the script is only logging the sda entry and not scanning the other drives. Going to look at bash programming and see if I can find a better way to loop the drive letters and then scan.

I am assuming by the popularity of your guide not many people have this issue but alteast I will learn some bash code from this experience.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Problems with cron table

Post by Ian »

Hi there and welcome to the forums.

OK, let's take things one step at a time. The reason the script isn't working for you is because it needs to be edited to suit your CPU. Looking at the output from this script, which is your CPU? The one which says CPUTIN? What is the one which says AUXTIN, is that another core/cpu?

Code: Select all

nct6776-isa-0290
Adapter: ISA adapter
Vcore:        +1.46 V  (min =  +0.00 V, max =  +1.74 V)
in1:          +0.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:         +3.33 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:        +3.33 V  (min =  +2.98 V, max =  +3.63 V)
in4:          +0.55 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:          +1.69 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:         +3.46 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:         +3.38 V  (min =  +2.70 V, max =  +3.30 V)  ALARM
fan1:           0 RPM  (min =    0 RPM)  ALARM
fan2:        3488 RPM  (min =    0 RPM)  ALARM
fan3:           0 RPM  (min =    0 RPM)  ALARM
fan4:           0 RPM  (min =    0 RPM)  ALARM
fan5:           0 RPM  (min =    0 RPM)  ALARM
SYSTIN:       +38.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:       +35.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:       -31.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
cpu0_vid:    +0.000 V
intrusion0:  ALARM
intrusion1:  ALARM

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +1.2°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)
The reason the shutdown command comes before the command to send the email is to ensure the server gets shutdown. I didn't want it staying alive if the email command made the whole script hang. The server does not shut down instantly and so has enough time to run the other lines in the script.

If you want to re-create msg.txt from scratch each time it runs the remove one of the ">"s from this line.

Code: Select all

      echo '============================'               >>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
">>" appends to a file but one ">" will wipe it and start over.

Ian.
User avatar
Ian
Moderator
Posts: 752
Joined: January 1st, 2011, 7:00 am

Re: Problems with cron table

Post by Ian »

thebigbaddie wrote:I am also seeing that the script is only logging the sda entry and not scanning the other drives. Going to look at bash programming and see if I can find a better way to loop the drive letters and then scan.

I am assuming by the popularity of your guide not many people have this issue but alteast I will learn some bash code from this experience.
I can help you with this too but the thread will get messy if we jump around so let me help you fix your CPU script first ;)

Ian.
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

Ian wrote:Hi there and welcome to the forums.

OK, let's take things one step at a time. The reason the script isn't working for you is because it needs to be edited to suit your CPU. Looking at the output from this script, which is your CPU? The one which says CPUTIN? What is the one which says AUXTIN, is that another core/cpu?

Code: Select all

nct6776-isa-0290
Adapter: ISA adapter
Vcore:        +1.46 V  (min =  +0.00 V, max =  +1.74 V)
in1:          +0.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:         +3.33 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:        +3.33 V  (min =  +2.98 V, max =  +3.63 V)
in4:          +0.55 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:          +1.69 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:         +3.46 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:         +3.38 V  (min =  +2.70 V, max =  +3.30 V)  ALARM
fan1:           0 RPM  (min =    0 RPM)  ALARM
fan2:        3488 RPM  (min =    0 RPM)  ALARM
fan3:           0 RPM  (min =    0 RPM)  ALARM
fan4:           0 RPM  (min =    0 RPM)  ALARM
fan5:           0 RPM  (min =    0 RPM)  ALARM
SYSTIN:       +38.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:       +35.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:       -31.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
cpu0_vid:    +0.000 V
intrusion0:  ALARM
intrusion1:  ALARM

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +1.2°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)
The reason the shutdown command comes before the command to send the email is to ensure the server gets shutdown. I didn't want it staying alive if the email command made the whole script hang. The server does not shut down instantly and so has enough time to run the other lines in the script.

If you want to re-create msg.txt from scratch each time it runs the remove one of the ">"s from this line.

Code: Select all

      echo '============================'               >>/home/thebigbaddie/Documents/HDDTempLogs/DriveWarning.Log
">>" appends to a file but one ">" will wipe it and start over.

Ian.
I have an AMD A4-5300 which is a dual core processor. Cheap $50 CPU. I tried to google understanding the output of the sensors cmd but it really didnt help me much.
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

Everything I have read indicates that temp1 is my core temp. However as I said this is a 2 core processor so as to why I am missing a temp I do not know.

Regardless here is the last output from the sensors cmd.

Code: Select all

nct6776-isa-0290
Adapter: ISA adapter
Vcore:        +1.46 V  (min =  +0.00 V, max =  +1.74 V)
in1:          +0.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:         +3.33 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:        +3.33 V  (min =  +2.98 V, max =  +3.63 V)
in4:          +0.55 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:          +1.68 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:         +3.46 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:         +3.38 V  (min =  +2.70 V, max =  +3.30 V)  ALARM
fan1:           0 RPM  (min =    0 RPM)  ALARM
fan2:        3488 RPM  (min =    0 RPM)  ALARM
fan3:           0 RPM  (min =    0 RPM)  ALARM
fan4:           0 RPM  (min =    0 RPM)  ALARM
fan5:           0 RPM  (min =    0 RPM)  ALARM
SYSTIN:       +38.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:       +35.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:       -31.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
cpu0_vid:    +0.000 V
intrusion0:  ALARM
intrusion1:  ALARM

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +1.1°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

Read up some more on lm-sensors and couldnt find anything concrete. So assuming temp1 is the only variable of interest how do i modify the script to reflect that change.

####EDIT####

from cat /proc/cpuinfo I get

Code: Select all

processor	: 1
vendor_id	: AuthenticAMD
cpu family	: 21
model		: 16
model name	: AMD A4-5300 APU with Radeon(tm) HD Graphics    
stepping	: 1
microcode	: 0x6001119
cpu MHz		: 1400.000
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 1
apicid		: 17
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 tce nodeid_msr tbm topoext perfctr_core arat cpb hw_pstate npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold bmi1
bogomips	: 6787.44
TLB size	: 1536 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 48 bits physical, 48 bits virtual
power management: ts ttp tm 100mhzsteps hwpstate cpb eff_freq_ro
So there is only one physical core which means temp 1 is correct as there is only one physical core.
thebigbaddie
Member
Member
Posts: 9
Joined: July 16th, 2013, 8:31 pm

Re: Problems with cron table

Post by thebigbaddie »

Fixed the issue with the CPU script and it works wonderfully. Working on the drive script now. Although I did make some changes to the script. The only real change is the addition of dates and times to the files so I can keep a record of when the core overheats.

Code: Select all

#!/bin/bash

# PURPOSE: Script to check temperature of CPU cores and report/shutdown if specified temperatures exceeded
#
# Expects two arguments:
#    1. Warning temperature
#    2. Critical shutdown temperature
#    eg. using ./CPUTempShutdown.sh 30 40
#        will warn when temperature of one or more cores hit 30degrees and shutdown when either hits 40degrees.

# NOTES:
# Change the strings ">>/home/htkh" as required
# Substitute string "myemail@myaddress.com" with your own email address in the string which starts "/usr/sbin/ssmtp myemail@myaddress.com"

# Assumes output from sensors command is as follows:
#
# coretemp-isa-0000
# Adapter: ISA adapter
# Core 0:      +35.0 C  (high = +78.0 C, crit = +100.0 C)  
#
# coretemp-isa-0001
# Adapter: ISA adapter
# Core 1:      +35.0 C  (high = +78.0 C, crit = +100.0 C) 
#
# if not then modify the commands str=$(sensors | grep "Core $i:") & newstr=${str:14:2} below accordingly

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 ''

for i in 1
do

  str=$(sensors | grep "temp$i:")
  newstr=${str:16:1}

  if [ ${newstr} -ge $1 ]
  then
    echo '============================'                             		>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
    echo $(date)                                                    		>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
    echo ''                                                         		>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
    echo ' WARNING: Temperature of core ' $i ' exceeded ' $1 ' => ' $newstr 	>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
    echo ''                                                         		>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
    echo '============================'                             		>>/home/thebigbaddie/Documents/CoreTempLogs/CPUWarning`date +%F_%T`.Log
  fi
  
  if [ ${newstr} -ge $2 ]
  then
    echo '============================'						>>/home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    echo ''									>>/home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    echo 'CRITICAL: Temperature of core ' $i ' exceeded ' $2 ' => ' $newstr	>>/home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    echo ''									>>/home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    echo '============================'						>>/home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    /usr/sbin/ssmtp dylan.server244@gmail.com </home/thebigbaddie/Documents/CoreTempLogMsgs/msg`date +%F_%T`.txt
    /sbin/shutdown -h now
    exit
  
  else
    echo ' Temperature Core '$i' OK at =>' $newstr
    echo ''
  fi
done

echo 'Both CPU Cores are within limits'
echo ''
Working on the drive scripts now.
Post Reply