centos7使用monit監控服務運行狀態
阿新 • • 發佈:2018-10-23
啟動 pem start emc system sha it監控 enable art 安裝:
配置:
vim /etc/monitrc
配置監控服務:
a. 監控apache:
vim /etc/monit.d/apache
常用語法:
a. 檢測配置文件語法:
監控頁面截圖:
yum -y install epel-release
yum -y install monit
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/*
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"
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
centos7使用monit監控服務運行狀態