This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Monit/ko

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Monit and the translation is 100% complete.
Resources

app-admin/monit은 유닉스 시스템의 프로세스, 프로그램, 파일, 디렉터리, 파일 시스템을 관리하고 감시하는 도구입니다.

설정

monit 설치

app-admin/monit 프로그램은 다음 USE 플래그를 활용합니다.

USE flags for app-admin/monit Monitoring and managing daemons or similar programs running on a Unix system

ipv6 Add support for IP version 6
pam Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)

Once the USE flags are properly determined, install app-admin/monit through emerge:

root #emerge --ask app-admin/monit

Monit 설정 파일

monit 프로그램은 /etc/monitrc 설정 파일을 활용합니다.

To make adding and removing monitoring definitions easy, monit supports including files inside a specified directory (usually /etc/monit.d. To enable this, edit /etc/monitrc like so:

파일 /etc/monitrc유연한 설정 항목 허용
## It is possible to include additional configuration parts from other files or
## directories.
include /etc/monit.d/*

When a Monit related configuration file is altered, tell monit to reread its configuration settings:

root #monit reload

부팅할 때 monit 자동 시작

It is recommended to start monit through the /etc/inittab so that init itself launches the monit application, and will automatically relaunch it when monit would suddenly die. Starting monit through an init script would not provide this functionality.

파일 /etc/inittabmonit 가동 실패시 자동 재시작
# Run monit in standard runlevels
mo:2345:respawn:/usr/bin/monit -Ic /etc/monitrc

After updating /etc/inittab, monit can be immediately started through telinit q.

사용자 관리

사용자를 monit 또는 users 그룹에 추가하면 해당 사용자는 웹 인터페이스를 통해 monit에 접근할 수 있습니다.

To add users to one of these groups, use gpasswd:

root #gpasswd -a $USER monit
root #gpasswd -a $USER users

/etc/monitrc 파일에서 allow 구문은 이 그룹을 다음과 같이 참조해야합니다:

파일 /etc/monitrc웹 인터페이스로의 그룹 접근 허용
set httpd port 2812
  allow @monit
  allow @users

monitrc 파일에 하드코딩한 사용자 이름 및 암호를 넣을 수 있습니다만, 추천하지 않습니다. monitrc 파일에 기본 암호가 있는지 확인하고, 제거하거나 더 강력하고 특별한 암호로 바꾸십시오. 여기서 사용하는 설정 방식은 allow <username>:<password>입니다.

monit 웹 서비스

웹 인터페이스 기본 위치는 localhost:2812이며 admin이 관리자 이름, monit은 기본 암호입니다. 기본 암호를 바꾸었는지 확인하십시오!

monit으로 프로그램 감시

monit 프로그램은 PID 파일을 사용하여 프로그램이 여전히 동작중인지를 확인합니다. PID 파일은 프로그램이 실행하는동안 반드시 있어야 하며, 그렇지 않으면 monit의 실행 여부를 보장하지 못합니다. 데몬에서 PID 파일을 만들지 않으면 래퍼en로 PID 파일을 만드십시오.

참고
The use of PID files (and validating PIDs from tools like ps) for monitoring is often said to be broken[1]. Monit does try to overcome this weakness by checking the PID file frequently enough to be reliable.

/etc/monit.d/ 위치를 활용하면 추가 감시 규칙을 쉽게 추가할 수 있습니다.

여기서는 MySQL이 갑자기 멈추었을 때 자동으로 시작하게 합니다:

파일 /etc/monit.d/mysqlmysql 자동 시작
check process mysql with pidfile /var/run/mysqld/mysqld.pid
    start program = "/bin/bash -c 'rc-service mysql start'"
    stop program  = "/bin/bash -c 'rc-service mysql stop'"

또 다른 예제에서는 프로세스의 메모리 사용량이 설정한 한계점을 넘었을 때 경고를 나타내도록 합니다:

파일 /etc/monit.d/squidsquid를 점검하여 메모리 점유 용량이 512MB를 넘으면 경고
check process squid with pidfile /run/squid.pid
   start program = "/bin/bash -c 'rc-service squid start'"
   stop  program = "/bin/bash -c 'rc-service squid stop'"
   if totalmem > 512 MB then alert

monit 디버깅

monit 전면 실행

To run monit in the foreground and provide feedback on everything it is detecting, use the -Ivv option:

root #monit -Ivv
...
'squid' total mem amount of 525748kB matches resource limit [total mem amount>524288kB]

외부 자료

Monit에 대한 더 많은 내용을 찾아보려한다면 다음 자료를 통해 도움을 받으실 수 있습니다.

참고 자료

  1. Greg Wooledge. Process management, Retrieved on January 1st, 2015