monit Unix系统监控服务
作者:服务器运维 • 更新时间:2023-07-25 •
monit 介绍
monit监控和管理进程、程序、文件、目录和Unix系统的文件的工具。可以进行自动维护和修理,在错误的情况下执行有意义的因果关系的行动。比如,某个进程没有运行启动它;没有响应重启它;占用太多资源停止该进程等等。也可以用来监控文件、目录或系统文件的变化,如时间戳的改变,检验和的改变或大小的改变。
文档地址:http://mmonit.com/monit/documentation/monit.html
monit 安装
# yum install monit
monit 配置
# vi /etc/monit.conf
set daemon 30
set mailserver localhost
set mail-format { from: moniter@ttlsa.com }
set alert mobei@ttlsa.com
set httpd port 2812 and
use address 192.168.1.190
allow localhost
allow admin:'123456' # password: 123456
allow @monit
allow @users readonly检查配置文件正确性
# monit -t Control file syntax OK
启动
# service monit start
实际应用实例
监控服务的monit配置文件放在/etc/monit.d/目录下,如:
nginx监控服务
# vi /etc/monit.d/nginx.monit.conf
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"php-fpm监控服务
# vi /etc/monit.d/php-fpm.monit.conf
check process php-fpm with pidfile /var/run/php-fpm.pid
group www
start program = "/etc/init.d/php-fpm start"
stop program = "/etc/init.d/php-fpm stop"
if failed port 9000 type TCP then restart
## if failed unixsocket /var/run/php-fpm.sock then restart
if 3 restarts within 5 cycles then timeout 本文由主机测评网发布,不代表主机测评网立场,转载联系作者并注明出处:https://zhujiwo.jb51.net/yunwei/8160.html
