Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

smartmontools의 저장장치 오류 알림 메일로 받기

2018-09-21 by 편리

smartmontools 는 SSD 등의 저자장치 상태를 모니터링하는 툴이다. 저장장치에서 오류가 발생했을 때 메일로 오류 알림을 받을 수 있어 서버의 저장장치 오류를 확인하고 대비할 수 있는 방법이 될 수 있다. smartmontools 를 설치하고 메일 알림을 받기 위한 설정이다. 우분투 서버 16.04 x64 환경에서 테스트했다.

sudo apt-get -y install sendmail
sudo apt-get -y install mailutils
sudo apt-get -y install smartmontools

sendmail 등의 메일 패키지와 smartmontools 를 설치한다.

smartd 데몬 실행을 위해 /etc/default/smartmontools 파일을 아래와 같이 수정한다. #start_smartd=yes 의 주석을 제거한다.

# Defaults for smartmontools initscript (/etc/init.d/smartmontools)
# This is a POSIX shell fragment

# List of devices you want to explicitly enable S.M.A.R.T. for
# Not needed (and not recommended) if the device is monitored by smartd
#enable_smart="/dev/hda /dev/hdb"

# uncomment to start smartd on system startup
start_smartd=yes

# uncomment to pass additional options to smartd on startup
#smartd_opts="--interval=1800"

/etc/smartd.conf 에 메일 설정을 한다.

# The word DEVICESCAN will cause any remaining lines in this
# configuration file to be ignored: it tells smartd to scan for all
# ATA and SCSI devices.  DEVICESCAN may be followed by any of the
# Directives listed below, which will be applied to all devices that
# are found.  Most users should comment out DEVICESCAN and explicitly
# list the devices that they wish to monitor.
DEVICESCAN -d removable -n standby -m usermail@gmail.com -M exec /usr/share/smartmontools/smartd-runner

-m root 부분을 -m usermail@gmail.com 으로 변경한다. usermail@gmail.com 은 실제 알림을 받을 메일 주소를 지정한다. 설정 변경 후 smartd 데몬의 설정을 다시 로드 한다.

/etc/init.d/smartmontools reload

smartd 데몬에서 메일이 발송되는지 확인해 보기 위해서는 아래 명령을 실행한다.

sudo echo "/dev/sda -m usermail@gmail.com -M test" > /etc/smartd.conf.test
sudo smartd -c /etc/smartd.conf.test
sudo rm -f /etc/smartd.conf.test

smartmontools 등의 패키지 설치와 메일 발송 테스트를 자동화한 스크립트는 아래와 같다.

#!/bin/bash

# Install mail
sudo apt-get -y install sendmail
sudo apt-get -y install mailutils
sudo apt-get -y install smartmontools

# add email
sudo sed -i "21s/-m root/-m usermail@gmail.com/" /etc/smartd.conf
/etc/init.d/smartmontools reload

# email test
sudo echo "/dev/sda -m usermail@gmail.com -M test" > /etc/smartd.conf.test
sudo smartd -c /etc/smartd.conf.test
sudo rm -f /etc/smartd.conf.test

 

참고자료

  • https://help.ubuntu.com/community/Smartmontools
  • https://myminutes.wordpress.com/2011/02/13/short-tutorial-smartd-with-mail-notification-to-remote-address/

Post navigation

Previous Post:

우분투 서버 netdata 에 smart_log 차트 표시

Next Post:

[nodejs] request, cheerio 를 이용한 웹페이지 크롤링

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅
  • 우분투 시스템 터미널쉘 zsh 로 변경

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes