티스토리 뷰

Linux

monit 설치

초보의 CHOMAN 2019.03.20 09:17

monit

공식홈페이지
https://mmonit.com/monit/

메뉴얼
https://mmonit.com/monit/documentation/monit.html

특별한 저장소 설치 (기본 repo 에는 없음)

yum install epel-release

monit 설치

yum install monit

높은 버전은 위 공식 홈페이지 접근하여서 바이러니나 소스 설치 필요함

monit 설정 파일

/etc/monit.conf
set daemon  30 # 30초 마다 데몬 체크

monit 시작

service monit start

로그 위치
cat /var/log/monit

[KST Mar 20 09:24:56] info     :  New Monit id: 0c8ecd415060dea3f080f175a821f7fc
 Stored in '/root/.monit.id'
[KST Mar 20 09:24:56] info     : Starting Monit 5.25.1 daemon with http interface at [localhost]:2812
[KST Mar 20 09:24:56] info     : 'localhost.localdomain' Monit 5.25.1 started

구문체크

monit -t

Control file syntax OK

httpd 데몬 체크 (파일 생성만 하면 됨)

vim /etc/monit.d/httpd

check process httpd with pidfile /var/run/httpd/httpd.pid
start program = "/bin/systemctl start httpd.service"
stop program = "/bin/systemctl stop httpd.service"

monit 로 체크 가능한것들

Service checks
Each service entry consists of the keywords check, followed by the service type. Each entry requires a unique descriptive name, which may be freely chosen. This name is used by Monit to refer to the service internally and in all interactions with the user.

Currently, nine types of check statements are supported:

Process
    CHECK PROCESS <unique name> <PIDFILE <path> | MATCHING <regex>>
<path> is the absolute path to the program's pid-file. A pid-file is a file, containing a Process's unique ID. If the pid-file does not exist or does not contain the PID number of a running process, Monit will call the entry's start method if defined.

<regex> is an alternative to using PID files and uses process name pattern matching to find the process to monitor. The top-most matching parent with highest uptime is selected, so this form of check is most useful if the process name is unique. Pid-file should be used where possible as it defines expected PID exactly. You can test if a process match a pattern from the command-line using monit procmatch "regex-pattern". This will lists all processes matching or not, the regex-pattern.

File
    CHECK FILE <unique name> PATH <path>
<path> is the absolute path to the file. If the file does not exist, Monit will call the entry's start method if defined, if <path> does not point to a regular file type (for instance a directory), Monit will disable monitoring of this entry. If Monit runs in passive mode or the start method is not defined, Monit will just send an alert on error.

Fifo
    CHECK FIFO <unique name> PATH <path>
<path> is the absolute path to the fifo. If the fifo does not exist, Monit will call the entry's start method if defined, if <path> does not point to a fifo type (for instance a directory), Monit will disable monitoring of this entry. If Monit runs in passive mode or the start method is not defined, Monit will just send an alert on error.

Filesystem
    CHECK FILESYSTEM <unique name> PATH <string>
<path> is the path to the device/disk, mount point or NFS/CIFS/FUSE connection string. If the filesystem becomes unavailable, Monit will call the service's start method if defined. If Monit runs in passive mode or the start method is not defined, Monit will just send an alert on error.

Directory
    CHECK DIRECTORY <unique name> PATH <path>
<path> is the absolute path to the directory. If the directory does not exist, Monit will call the entry's start method if defined. If <path> does not point to a directory, monit will disable monitoring of this entry. If Monit runs in passive mode or the start methods is not defined, Monit will just send an alert on error.

Remote host
    CHECK HOST <unique name> ADDRESS <host>
The host address can be specified as a hostname string or as an IP-address string on a dotted decimal format. Such as, "tildeslash.com" or "64.87.72.95".

System
    CHECK SYSTEM <unique name>
The unique name is usually the local host name, but any descriptive name can be used. If you use the variable $HOST as the name, it will expand to the hostname. This check allows one to monitor general system resources such as CPU usage, total memory usage or load average. The unique name is used as the system hostname in mail alerts and as the initial name of the host entry in M/Monit.

Program
    CHECK PROGRAM <unique name> PATH <executable file> [TIMEOUT <number> SECONDS]
<path> is the absolute path to the executable program or script. The status test allows one to check the program's exit status. If the program does not finish executing within <number> seconds, Monit will terminate it. The default program timeout is 300 seconds (5 minutes). The output of the program is recorded and made available in the User Interface and in alerts, by default up to 512 bytes. You can change the output limit using the set limits statement).

Network
    CHECK NETWORK <unique name> <ADDRESS <ipaddress> | INTERFACE <name>>
<ipaddress> is the IPv4 or IPv6 address of the monitored network interface. It is also possible to use interface name, such as "eth0" on Linux.

원문 참고 사이트

https://nolboo.kim/blog/2016/08/13/monitoring-linux-monit/
댓글
  • 프로필사진 초보의 CHOMAN 'monit without PidFile' PID 파일이 존재하지 않는 데몬 체크 및 서비스 시작은 잘 실행되지 않음
    matching 이라는 옵션이 PidFile 없이 체크가 가능한 옵션이기는 하나 더 많은 example 이 필요한 상태
    2019.05.08 15:40 신고
댓글쓰기 폼
공지사항
Total
726,085
Today
138
Yesterday
194
링크
«   2019/08   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함