* Netdata 설치는 이전 포스트 참고

2023.04.17 - [Infra] - [Netdata] 오픈소스 모니터링 시스템


다양한 오픈소스 모니터링 툴 중 Netdata를 선택한 가장 큰 이유는 바로!!

20가지가 넘는 알림들을 실시간으로 메일이나, 텔레그램, SMS, Email 등으로 보내주기 때문이다.

 

Netdata의 알림 기능을 사용해서 특정 프로그램의 CPU나 GPU의 점유율이 어느 정도 만큼 줄었을 때 설정한 알림을 통해 전달해주기 때문에 작업 종료를 빠르게 파악할 수 있다.

 

Email 알림을 이용한 글이 몇 개 없어 작업하는데 어려움을 겪어 이렇게 남겨놓는다..

 

Email 알림 구성

Netdata는 기본적으로 sendmail을 사용하여 이메일 알림을 보내지만 이메일 서버를 관리하는 것은 쉬운 일이 아니다.

Netdata는 SMTP를 지원하지 않지만 msmtp 클라이언트라는 패키지를 설치할 수 있어 SMTP 서버로 메일을 보낼 수 있다.

 

1. msmtp 설치

$ yum install msmtp

 

2. msmtp 구성 파일 생성

$ sudo vi /etc/msmtprc

 

3. 위에서 생성한 파일에 아래 내용 입력

# Set default values for all following accounts.
defaults

# Use the mail submission port 587 instead of the SMTP port 25.
port 587

# Always use TLS.
tls on

# The SMTP server of your ISP
account gmail
host smtp.gmail.com
auth on
user <yoursesusername>
password <yoursespassword>

# Set default account to isp
account default: gmail

 

4. 생성한 파일의 권한 수정

$ chmod 644 /etc/msmtprc

 

5. Email 알림 설정을 위해 Netdata의 구성 파일 편집

$ cd /usr/lib/netdata/conf.d/
$ vi health_alarm_notify.conf

 

6. 아래 내용을 찾아 msmtp 경로 입력

# The full path to the sendmail command.
# If empty, the system $PATH will be searched for it.
# If not found, email notifications will be disabled (silently).
sendmail="/usr/bin/msmtp"

 

7. 아래 내용을 찾아 이메일 발송인과 수신인의 세부 정보 입력

# email global notification options

# multiple recipients can be given like this:
#              "admin1@example.com admin2@example.com ..."

# the email address sending email notifications
# the default is the system user netdata runs as (usually: netdata)
# The following formats are supported:
# EMAIL_SENDER="user@domain"
# EMAIL_SENDER="User Name <user@domain>"
# EMAIL_SENDER="'User Name' <user@domain>"
# EMAIL_SENDER="\"User Name\" <user@domain>"
EMAIL_SENDER="이메일 발송인"

# enable/disable sending emails
SEND_EMAIL="YES"

# if a role recipient is not configured, an email will be send to:
DEFAULT_RECIPIENT_EMAIL="이메일 수신인"
# to receive only critical alarms, set it to "root|critical"

 

8. 수정한 파일 저장 후 /etc/netdata 경로로 복사

$ cp /usr/lib/netdata/conf.d/health_alarm_notify.conf /etc/netdata/health_alarm_notify.conf

 

Email 알림 테스트

1. 설치 중 생성된 시스템 사용자 netdata로 로그인

$ sudo su -s /bin/bash netdata

 

2. 알람 알림 스크립트를 실행하여 테스트 알람 전송

$ /usr/libexec/netdata/plugins.d/alarm-notify.sh test

 

3. 아래 결과가 나오면 테스트 성공

 

4. 수신인 이메일로 세 개의 테스트 경고 이메일을 받아야 성공

 

'Infra' 카테고리의 다른 글

[Docker] Docker의 개념  (0) 2023.04.18
MSMTP와 SMTP  (0) 2023.04.18
[Netdata] 오픈소스 모니터링 시스템  (0) 2023.04.17

+ Recent posts