安装

1
2
3
yum install -y monit;
# 查看版本
monit --version
1
2
3
This is Monit version 5.25.1
Built with ssl, with ipv6, with compression, with pam and with large files
Copyright (C) 2001-2017 Tildeslash Ltd. All Rights Reserved.
1
2
3
4
5
6
# 默认配置文件
cat /etc/monitrc
# systemd
systemctl enable monit
systemctl start monit
systemctl status monit

nginx

1
vi /etc/monit.d/nginx
1
2
3
check process nginx with pidfile /data/nginx/logs/nginx.pid
start program = "/data/nginx/sbin/nginx"
stop program  = "/data/nginx/sbin/nginx -s stop"
1
2
monit status nginx
monit summary nginx