* 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

Netdata란?

CPU 사용량, 디스크 활동, 대역폭 사용량, 웹 사이트 방문 등과 같은 실시간 메트릭을 수집한 다음 해석하기 쉬운 실시간 차트로 표시하도록 설계된 오픈 소스 도구이다.

Netdata는 시스템, 하드웨어, 컨테이너, 어플리케이션들로부터 수천개의 데이터를 실시간으로 수집하며 물리/ 가상 서버 및 컨테이너, 클라우드 환경, IOT 장비등 에서 영구적으로 동작한다.

 

대부분의 Linux 배포판 뿐만 아니라 Kubernetes나 Docker 등의 컨테이너 플랫폼 및 MacOS 등에서도 sudo 권한 없이 설치 할 수 있다.

 

Netdata는 아래와 같은 특징들을 가지고 있다.

  • 설정이 필요없다.
  • 관리가 필요없다.
  • 최소한의 Disk I/O 및 메모리 사용하며 싱글코어 1% 만의 CPU 점유한다.
  • 빠르고 인터렉티브 한 시각화를 제공한다.

 

설치방법

1. 서버 접속 후 아래 명령어 입력

curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh
  설치 중간중간 계속해서 설치할지 물어볼 때마다 Y 혹은 엔터키를 입력해준다.

 

2. 설치 완료 후 ip:19999 로 접속 하면 아래 화면처럼 바로 서버를 모니터링 할 수 있다.

 

* 자세한 설명은 아래 공식 문서를 통해 볼 수 있다.

https://learn.netdata.cloud/docs/getting-started/

'Infra' 카테고리의 다른 글

[Docker] Docker의 개념  (0) 2023.04.18
MSMTP와 SMTP  (0) 2023.04.18
[Netdata] Email을 이용한 알림 설정  (0) 2023.04.18

+ Recent posts