部署monit监控进程

安装

    sudo apt-get install monit

基本配置

  • 打开/etc/monit/monitrc
  • 在以下配置前,去掉注释

      sudo httpd port 2812 and
              allow user:password
    
  • 保存后返回
  • 检查是否有语法错误

      sudo monit -t
    
  • 重新加载服务

      sudo monit reload
    
  • 查看运行状态

      sudo monit status
    
  • 在浏览器打开http://xxx.xxx.xxx.xxx/2812,并输入 username 和 password

配置

邮件提醒

  • 安装程序

      sudo apt-get update
      sudo apt-get install sendmail
    
  • 打开 sudo vi /etc/monit/monitrc, 输入配置

      set mailserver smtp.qq.com port 465
             username "12345@qq.com" password "你的授权码" using sslv3
             with timeout 30 seconds
    
    • 阿里云企业邮箱报错
    • gmail 连接不上
    • 网易邮箱太难用
    • 只能用 QQ 邮箱
  • 然后输入sudo monit reload 重新加载一下就 OK 了

Jenkins 监控

    check process jenkins with pidfile /var/run/jenkins/jenkins.pid
        start program = "/etc/init.d/jenkins start"
        stop program = "/etc/init.d/jenkins stop"
        if changed pid then alert
  • 监控 pid 文件的变化
  • startstop都需要配置,不然无法运行
  • alert发邮件报警

远程服务器端口监控

    # ICMP check
    check host hostname.com with address xx.xx.xx.xx
        if failed icmp type echo
            for 5 times within 5 cycles
        then alert

    # HTTP check
    if failed port 80 protocol http
        for 5 times within 5 cycles
    then alert

    # HTTPS check
    if failed port 443 type tcpSSL protocol http
        for 5 times within 5 cycles
    then alert

参考

Jul 27th, 2016

Comments