1. 程式人生 > >centos7使用monit監控服務運行狀態

centos7使用monit監控服務運行狀態

啟動 pem start emc system sha it監控 enable art

  • 安裝:
    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監控服務運行狀態