monit Unix系统监控服务

2025-05-25 0 78

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
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 monit Unix系统监控服务 https://www.kuaiidc.com/51242.html

相关文章

发表评论
暂无评论