1. 程式人生 > 其它 >centos7使用monit監控服務執行狀態

centos7使用monit監控服務執行狀態

一個單機監控工具 目錄

1. 安裝

yum -y install epel-release
yum -y install monit

2. 配置

vim /etc/monitrc

set daemon  30
set log syslog
set httpd port 2812 and
    use address 172.20.10.11
    allow 172.20.10.2
    allow admin:monit
    #with ssl {            # enable SSL/TLS and set path to server certificate
    #    pemfile: /etc/ssl/certs/monit.pem
    #}
include /etc/monit.d/*

3. 配置監控服務

a. 監控apache:
vim /etc/monit.d/apache

check  process  apache  with  pidfile  /etc/httpd/logs/httpd.pid
start  program  =  "/usr/bin/systemctl  start  httpd"
stop  program    =  "/usr/bin/systemctl  stop  httpd"

b. 監控mysql:
vim /etc/monit.d/mysql

check  process  mysql  with  pidfile  /usr/local/mysql/data/lee.pid
start  program  =  "/usr/bin/systemctl  start  mysqld"
stop  program    =  "/usr/bin/systemctl  stop  mysqld"

c. 監控ssh:
vim /etc/monit.d/ssh

check  process  ssh  with  pidfile  /run/sshd.pid
start  program  =  "/usr/bin/systemctl  start  sshd"
stop  program    =  "/usr/bin/systemctl  stop  sshd"

4. 常用語法

a. 檢測配置檔案語法:

monit  -t

b. 啟動服務:

systemctl  start  monit

c. 停止服務:

systemctl  stop  monit

d. 重啟服務:

systemctl  restart  monit

e. 檢視服務執行狀態:

systemctl  status  monit  -l

f. 檢視錯誤日誌:

tail  /var/log/monit.log

5. 監控頁面

http://172.20.10.11:2812
附記:在茫茫的資訊海洋中,遇到就是有緣,期待回覆交流,為緣分留下痕跡……