centos7使用monit监控服务运行状态

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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. 监控页面截图:
    技术分享图片
    技术分享图片

以上是关于centos7使用monit监控服务运行状态的主要内容,如果未能解决你的问题,请参考以下文章

Monit:开源服务器监控工具

Monit:开源服务器监控工具

Monit

Monit : 开源监控工具介绍

如何使用Monit部署服务器监控系统

网站访问状态和超时时间监控报警设置