본문으로 건너뛰기

CentOS에서 하드웨어 상태를 모니터링하는 방법은 무엇인가요?

💡 요약 정리

  • lm_sensors로 CPU, 메인보드, 전압, 팬 속도 등을 모니터링합니다.
  • hddtemp로 하드디스크 온도를 측정합니다.
  • sensors-detect로 시스템의 센서를 자동 감지합니다.
  • sensors 명령으로 실시간 하드웨어 상태를 확인합니다.
  • 벤더 제공 도구(Dell OpenManage, HP PSP)와 병용하면 더욱 정확합니다.

설치환경

  • OS: CentOS 5.x (64bit)
  • 패키지: lm_sensors, hddtemp

개요

Linux에서도 서버의 하드웨어 상태를 체크할 수 있는 오픈소스 패키지가 있습니다.

벤더별 전용 도구 (권장)

서버 제조사에서 제공하는 전용 도구를 사용하는 것이 가장 정확하고 포괄적입니다:

  • Dell: OpenManage Server Administrator
  • HP: Proliant Support Pack (PSP)
  • IBM: IBM Systems Director
  • Supermicro: IPMICFG, IPMIView

오픈소스 도구

벤더 도구가 없거나 추가 모니터링이 필요한 경우:

  • lm_sensors: CPU, 메인보드, 전압, 팬 속도 모니터링
  • hddtemp: 하드디스크 온도 측정
  • smartmontools: 디스크 SMART 정보 확인

1. 패키지 설치

yum으로 lm_sensors, hddtemp 설치

[root@cafe24 ~]# yum install lm_sensors hddtemp
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: centos.mirror.cdnetworks.com
 * extras: centos.mirror.cdnetworks.com
 * rpmforge: ftp.riken.jp
 * updates: centosk3.centos.org
base                                                                        | 1.1 kB     00:00
base/primary                                                                | 1.2 MB     00:00
base                                                                                       3641/3641
extras                                                                      | 2.1 kB     00:00
extras/primary_db                                                           | 174 kB     00:00
rpmforge                                                                    | 1.9 kB     00:00
rpmforge/primary_db                                                         | 6.9 MB     00:01
updates                                                                     | 1.9 kB     00:00
updates/primary_db                                                          | 122 kB     00:01
Setting up Install Process
Package lm_sensors-2.10.7-9.el5.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package hddtemp.x86_64 0:0.3-0.14.beta15.el5.centos set to be updated
---> Package lm_sensors.i386 0:2.10.7-9.el5 set to be updated
--> Processing Dependency: libsysfs.so.2 for package: lm_sensors
--> Running transaction check
---> Package libsysfs.i386 0:2.1.0-1.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package                 Arch                Version                                Repository           Size
===========================================================================================================
Installing:
 hddtemp                 x86_64              0.3-0.14.beta15.el5.centos             extras               49 k
 lm_sensors              i386                2.10.7-9.el5                           base                511 k
Installing for dependencies:
 libsysfs                i386                2.1.0-1.el5                            base                 47 k

Transaction Summary
===========================================================================================================
Install       3 Package(s)
Upgrade       0 Package(s)

Total download size: 607 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): libsysfs-2.1.0-1.el5.i386.rpm                                                 |  47 kB     00:00
(2/3): hddtemp-0.3-0.14.beta15.el5.centos.x86_64.rpm                                 |  49 kB     00:00
(3/3): lm_sensors-2.10.7-9.el5.i386.rpm                                              | 511 kB     00:00
-----------------------------------------------------------------------------------------------------------
Total                                                                        2.5 MB/s | 607 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libsysfs                                                                              1/3
  Installing     : lm_sensors                                                                            2/3
  Installing     : hddtemp                                                                               3/3

Installed:
  hddtemp.x86_64 0:0.3-0.14.beta15.el5.centos              lm_sensors.i386 0:2.10.7-9.el5

Dependency Installed:
  libsysfs.i386 0:2.1.0-1.el5

Complete!

설치 패키지:

  • lm_sensors: 하드웨어 센서 모니터링 도구
  • hddtemp: 하드디스크 온도 측정 도구
  • libsysfs: lm_sensors 의존성 라이브러리

2. 하드웨어 센서 감지

sensors-detect 실행

패키지 설치 후 sensors-detect 명령으로 서버에 설치된 센서 목록을 자동 감지합니다.

[root@cafe24 ~]# sensors-detect
# sensors-detect revision 5291 (2008-06-23 23:40:46 -0700)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

We can start with probing for (PCI) I2C or SMBus adapters.
Do you want to probe now? (YES/no):
Probing for PCI bus adapters...
Use driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7

We will now try to load each adapter module in turn.
Module `i2c-i801' already loaded.
If you have undetectable or unsupported I2C/SMBus adapters, you can have
them scanned by manually loading the modules before running this script.

To continue, we need module `i2c-dev' to be loaded.
Do you want to load `i2c-dev' now? (YES/no):
Module loaded successfully.

센서 검색 과정

We are now going to do the I2C/SMBus adapter probings. Some chips may
be double detected; we choose the one with the highest confidence
value in that case.
If you found that the adapter hung after probing a certain address,
you can specify that address to remain unprobed.

Next adapter: SMBus I801 adapter at 1100 (i2c-0)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x2d
Probing for `National Semiconductor LM78'...                     No
Probing for `National Semiconductor LM78-J'...                   No
Probing for `National Semiconductor LM79'...                     No
Probing for `National Semiconductor LM80'...                     No
Probing for `National Semiconductor LM85 or LM96000'...          No
Probing for `Analog Devices ADM1027, ADT7460 or ADT7463'...      No
Probing for `SMSC EMC6D100, EMC6D101 or EMC6D102'...             No
Probing for `Analog Devices ADT7476'...                          No
Probing for `Andigilog aSC7611'...                               No
Probing for `Andigilog aSC7621'...                               No
Probing for `National Semiconductor LM87'...                     No
Probing for `National Semiconductor LM93'...                     No
Probing for `Winbond W83781D'...                                 No
Probing for `Winbond W83782D'...                                 No
Probing for `Winbond W83783S'...                                 No
Probing for `Winbond W83792D'...                                 No
Probing for `Winbond W83793R/G'...                               No
Probing for `Winbond W83791SD'...                                No
Probing for `Winbond W83627HF'...                                Success!
    (confidence 8, driver `use-isa-instead', other addresses: 0x48 0x49)
Probing for `Winbond W83627EHF'...                               No
Probing for `Winbond W83627DHG'...                               No

감지된 센서:

  • Winbond W83627HF: 메인보드 센서 칩
  • 위 예제에서는 ISA 버스를 통해 접근하도록 권장

ISA 버스 센서 확인

Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `w83627hf':
  * ISA bus, address 0x290
    Chip `Winbond W83627HF Super IO Sensors' (confidence: 9)

Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no):
Starting lm_sensors: loading module i2c-i801 [  OK  ]
                     loading module w83627hf [  OK  ]
                                                                        [  OK  ]
Unloading i2c-dev... OK

결과:

  • 감지된 센서 드라이버가 /etc/sysconfig/lm_sensors에 저장됨
  • 부팅 시 자동으로 로드되도록 설정됨

3. 하드웨어 상태 확인

sensors 명령어

시스템에 설치된 센서의 현재 상태를 확인합니다.

[root@cafe24 ~]# sensors
w83627hf-isa-0290
Adapter: ISA adapter
VCore:     +1.30 V  (min =  +1.42 V, max =  +1.57 V)   ALARM
+12V:     +11.90 V  (min = +10.82 V, max = +13.19 V)
+3.3V:     +3.28 V  (min =  +3.14 V, max =  +3.46 V)
+5V:       +4.97 V  (min =  +4.73 V, max =  +5.24 V)
-12V:     -12.13 V  (min = -13.18 V, max = -10.80 V)
V5SB:      +5.51 V  (min =  +4.76 V, max =  +5.24 V)   ALARM
VBat:      +3.20 V  (min =  +2.40 V, max =  +3.60 V)
fan1:        0 RPM  (min = 3245 RPM, div = 2)          ALARM
fan2:     3633 RPM  (min = 2657 RPM, div = 2)
fan3:        0 RPM  (min = 2657 RPM, div = 2)          ALARM
temp1:       +36°C  (high =   +45°C, hyst =   +40°C)  sensor = thermistor
temp2:       +34.5°C  (high =   +80°C, hyst =   +75°C)  sensor = thermistor
temp3:       +34.5°C  (high =   +80°C, hyst =   +75°C)  sensor = thermistor
cpu0_vid:  +1.450 V

출력 정보 설명:

항목설명정상 범위
VCoreCPU 코어 전압1.2V ~ 1.5V (CPU에 따라 다름)
+12V12V 전원 공급11.4V ~ 12.6V
+3.3V3.3V 전원 공급3.1V ~ 3.5V
+5V5V 전원 공급4.7V ~ 5.2V
-12V-12V 전원 공급-10.8V ~ -13.2V
V5SBStandby 5V4.7V ~ 5.2V
VBatCMOS 배터리 전압2.4V ~ 3.6V
fan1/2/3팬 속도 (RPM)제조사 규격 확인
temp1/2/3온도 센서 (°C)CPU: 3060°C, MB: 2550°C
cpu0_vidCPU VID 전압CPU 규격 확인

ALARM 표시:

  • 센서 값이 설정된 임계값을 벗어났음을 의미
  • 위 예제에서는 VCore, V5SB, fan1, fan3에 알람 발생
  • fan1, fan3의 0 RPM은 팬이 연결되지 않았거나 센서 미지원

4. 하드디스크 온도 확인

hddtemp 명령어

하드디스크의 온도를 SMART 정보에서 읽어옵니다.

[root@cafe24 ~]# hddtemp /dev/sda
/dev/sda: SAMSUNG HD501LJ: 38°C

옵션:

# 여러 디스크 한번에 조회
hddtemp /dev/sda /dev/sdb /dev/sdc

# Fahrenheit로 표시
hddtemp -f /dev/sda

# 데몬 모드로 실행 (포트 7634)
hddtemp -d /dev/sda

# 단위 표시 안 함
hddtemp -n /dev/sda

정상 온도 범위:

  • HDD: 30°C ~ 50°C
  • SSD: 25°C ~ 70°C
  • 60°C 이상: 냉각 확인 필요
  • 70°C 이상: 위험 수준, 즉시 조치 필요

5. 주기적 모니터링

watch를 이용한 실시간 모니터링

# 2초마다 센서 정보 갱신
watch -n 2 sensors

# 1초마다 디스크 온도 확인
watch -n 1 "hddtemp /dev/sda /dev/sdb"

cron을 이용한 로그 기록

/etc/cron.d/sensors-log 생성:

# 매 10분마다 센서 정보 로그 기록
*/10 * * * * root /usr/bin/sensors >> /var/log/sensors.log 2>&1
*/10 * * * * root /usr/sbin/hddtemp /dev/sda >> /var/log/hddtemp.log 2>&1

스크립트로 임계값 모니터링

센서 알람 체크 스크립트:

#!/bin/bash
# /usr/local/bin/check_sensors.sh

# 센서 출력에서 ALARM 확인
ALARMS=$(sensors | grep -i ALARM)

if [ -n "$ALARMS" ]; then
    echo "Hardware sensor alarm detected!"
    echo "$ALARMS"

    # 이메일 발송 (선택사항)
    echo "$ALARMS" | mail -s "Server Hardware Alert" admin@example.com
fi

# 디스크 온도 확인 (60도 이상 경고)
DISK_TEMP=$(hddtemp /dev/sda | awk -F: '{print $3}' | awk '{print $1}')
if [ "$DISK_TEMP" -gt 60 ]; then
    echo "Disk temperature too high: ${DISK_TEMP}°C"
    # 이메일 발송 (선택사항)
    echo "Disk /dev/sda temperature: ${DISK_TEMP}°C" | mail -s "Disk Temperature Alert" admin@example.com
fi

cron 등록:

# 매 5분마다 체크
*/5 * * * * root /usr/local/bin/check_sensors.sh

6. 센서 설정 파일 수정

/etc/sensors.conf

센서 임계값, 레이블 등을 수정할 수 있습니다.

예제: 팬 속도 임계값 변경

# /etc/sensors.conf 편집
vi /etc/sensors.conf

# Winbond W83627HF 섹션 찾기
chip "w83627hf-*"

# 팬 속도 최소값 변경
set fan1_min 2000
set fan2_min 2000
set fan3_min 2000

# 온도 임계값 변경
set temp1_max 50
set temp1_max_hyst 45

set temp2_max 70
set temp2_max_hyst 65

설정 적용:

# lm_sensors 서비스 재시작
service lm_sensors restart

# 또는
/etc/init.d/lm_sensors restart

7. 부팅 시 자동 시작

lm_sensors 서비스 활성화

# 서비스 시작
service lm_sensors start

# 부팅 시 자동 시작 설정
chkconfig lm_sensors on

# 상태 확인
chkconfig --list lm_sensors

출력 예:

lm_sensors      0:off   1:off   2:on    3:on    4:on    5:on    6:off

8. 벤더별 전용 도구 활용

Dell OpenManage

설치:

# Dell 저장소 추가
wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash

# OpenManage 설치
yum install srvadmin-all

# 서비스 시작
/opt/dell/srvadmin/sbin/srvadmin-services.sh start

웹 인터페이스 접속:

https://서버IP:1311

HP Proliant Support Pack (PSP)

설치:

# HP 저장소 추가
rpm --import http://downloads.linux.hpe.com/SDR/hpPublicKey1024.pub
rpm --import http://downloads.linux.hpe.com/SDR/hpPublicKey2048.pub
rpm --import http://downloads.linux.hpe.com/SDR/hpPublicKey2048_key1.pub

# PSP 설치
yum install hp-health hp-snmp-agents

# 서비스 시작
/sbin/hpasmd

명령어:

# 시스템 정보
hpasmcli

# 온도 확인
hpasmcli -s "show temp"

# 팬 속도 확인
hpasmcli -s "show fans"

# 전원 공급 장치 확인
hpasmcli -s "show powersupply"

9. IPMI 활용 (서버 하드웨어 지원 시)

ipmitool 설치

yum install ipmitool OpenIPMI

# IPMI 커널 모듈 로드
modprobe ipmi_devintf
modprobe ipmi_si

# 서비스 시작
service ipmi start
chkconfig ipmi on

IPMI 명령어

# 센서 정보 조회
ipmitool sensor list

# 온도만 조회
ipmitool sdr type Temperature

# 팬 속도 조회
ipmitool sdr type Fan

# 전압 조회
ipmitool sdr type Voltage

# 시스템 이벤트 로그 확인
ipmitool sel list

출력 예:

Temp             | 01h | ok  |  3.1 | 36 degrees C
Temp             | 02h | ok  |  3.2 | 34 degrees C
Fan1             | 30h | ok  |  7.1 | 3300 RPM
Fan2             | 31h | ok  |  7.2 | 3400 RPM
Vcore            | 40h | ok  |  3.1 | 1.30 Volts
+12V             | 41h | ok  |  7.1 | 11.90 Volts

10. 모니터링 시스템 연동

Nagios 플러그인

# check_sensors 플러그인 다운로드
wget -O /usr/lib64/nagios/plugins/check_sensors \
  https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=4117&cf_id=24

chmod +x /usr/lib64/nagios/plugins/check_sensors

# 실행
/usr/lib64/nagios/plugins/check_sensors

Zabbix 에이전트

# UserParameter 추가
vi /etc/zabbix/zabbix_agentd.conf

# 센서 값 수집
UserParameter=sensors.temp[*],sensors | grep "$1" | awk '{print $2}' | sed 's/+//;s/°C//'
UserParameter=sensors.fan[*],sensors | grep "$1" | awk '{print $2}'
UserParameter=hddtemp[*],hddtemp $1 | awk -F: '{print $3}' | awk '{print $1}'

# 서비스 재시작
service zabbix-agentd restart

11. 문제 해결

센서가 감지되지 않음

원인:

  • 하드웨어가 센서를 지원하지 않음
  • 드라이버 미지원
  • BIOS에서 센서 비활성화

해결 방법:

# 1. sensors-detect 재실행
sensors-detect

# 2. 커널 모듈 수동 로드
modprobe w83627hf
modprobe i2c-i801

# 3. BIOS에서 하드웨어 모니터링 활성화 확인

ALARM이 계속 표시됨

원인:

  • 센서 임계값이 잘못 설정됨
  • 하드웨어 실제 문제
  • 센서 오작동

해결 방법:

# 1. /etc/sensors.conf에서 임계값 조정
vi /etc/sensors.conf

# 2. 실제 하드웨어 상태 확인
# - 케이스 열고 팬 회전 확인
# - 전원 공급 장치 점검
# - 케이블 연결 상태 확인

# 3. BIOS에서 하드웨어 모니터링 정보 확인

hddtemp가 작동하지 않음

원인:

  • 디스크가 SMART를 지원하지 않음
  • SMART 기능 비활성화
  • 디바이스 경로 오류

해결 방법:

# 1. SMART 상태 확인 (smartmontools 설치 필요)
yum install smartmontools
smartctl -i /dev/sda | grep "SMART support"

# 2. SMART 활성화
smartctl -s on /dev/sda

# 3. hddtemp로 재확인
hddtemp /dev/sda

# 4. 지원되지 않는 경우
# hddtemp 데이터베이스에 드라이브 추가 또는
# smartctl로 온도 확인
smartctl -A /dev/sda | grep Temperature

12. 모범 사례

정기 점검 체크리스트

월간 점검:

  • 센서 로그 확인 (/var/log/sensors.log)
  • ALARM 발생 여부 확인
  • 디스크 온도 추이 분석
  • 팬 속도 변화 확인
  • 전압 안정성 확인

주간 점검:

  • 실시간 센서 값 확인 (sensors)
  • 디스크 온도 확인 (hddtemp)
  • 시스템 이벤트 로그 확인 (IPMI SEL)

실시간 모니터링:

  • 온도 임계값 초과 시 알림 설정
  • 팬 정지 시 즉시 알림
  • 전압 불안정 시 경고

임계값 설정 가이드

CPU 온도:

  • 정상: 30°C ~ 50°C
  • 경고: 60°C ~ 70°C
  • 위험: 70°C 이상

메인보드 온도:

  • 정상: 25°C ~ 40°C
  • 경고: 45°C ~ 55°C
  • 위험: 60°C 이상

하드디스크 온도:

  • 정상: 30°C ~ 45°C
  • 경고: 50°C ~ 55°C
  • 위험: 60°C 이상

전압:

  • 정상: ±5% 이내
  • 경고: ±10% 이내
  • 위험: ±10% 초과

팬 속도:

  • 최소: 제조사 규격의 50%
  • 경고: 제조사 규격의 30% 이하
  • 위험: 0 RPM (팬 정지)

13. 관련 명령어

smartmontools

디스크 SMART 정보 상세 확인:

# SMART 정보 조회
smartctl -a /dev/sda

# Health 상태 확인
smartctl -H /dev/sda

# 온도 확인
smartctl -A /dev/sda | grep Temperature

# Self-test 실행
smartctl -t short /dev/sda

dmidecode

하드웨어 정보 조회:

# 전체 하드웨어 정보
dmidecode

# BIOS 정보
dmidecode -t bios

# 시스템 정보
dmidecode -t system

# 메모리 정보
dmidecode -t memory

# CPU 정보
dmidecode -t processor

lshw

하드웨어 구성 조회:

# 전체 하드웨어 구성
lshw

# 간단한 출력
lshw -short

# CPU 정보
lshw -class processor

# 메모리 정보
lshw -class memory

# 디스크 정보
lshw -class disk

참고사항

  • lm_sensors는 모든 하드웨어를 지원하지 않으므로, 벤더 제공 도구와 병용하세요.
  • sensors-detect 실행 중 시스템이 멈출 수 있으니 중요한 서비스 실행 중에는 피하세요.
  • BIOS에서 하드웨어 모니터링 기능이 활성화되어 있는지 확인하세요.
  • ALARM 표시가 항상 문제를 의미하는 것은 아니며, 센서 오작동일 수도 있습니다.
  • 정기적인 로그 기록과 추이 분석으로 하드웨어 문제를 사전에 감지하세요.
  • 온도가 지속적으로 높으면 먼지 제거, 열전도 그리스 교체, 냉각 시스템 점검이 필요합니다.