출처 : http://www.havetheknowhow.com/Configure-the-server/Monitor-server-temperatures.html
해당 웹페이지에 hdd 온도 체크에 관련된 내용도 있다.

먼저 할 것
$ yum install -y acpid lm_sensors
$ sensors-detect
y -> -y -> … -> enter -> y

스크립트 내용.
#!/bin/bash

# PURPOSE: Script to check temperature of CPU cores and report/shutdown if specified temperatures exceeded
#
# AUTHOR: feedback[AT]HaveTheKnowHow[DOT]com

# 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 0 1
do

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

  if [ ${newstr} -ge $1 ]
  then
    echo '============================'                             >>/home/htkh/Desktop/CPUWarning.Log
    echo $(date)                                                    >>/home/htkh/Desktop/CPUWarning.Log
    echo "                                                         >>/home/htkh/Desktop/CPUWarning.Log
    echo ' WARNING: TEMPERATURE CORE' $i 'EXCEEDED' $1 '=>' $newstr >>/home/htkh/Desktop/CPUWarning.Log
    echo "                                                         >>/home/htkh/Desktop/CPUWarning.Log
    echo '============================'                             >>/home/htkh/Desktop/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 myemail@myaddress.com </home/htkh/MyScripts/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 "

리눅스 CPU 온도체크 및 셧다운

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다