zoukankan      html  css  js  c++  java
  • monit安装配置

    环境centos5(32bit),monit-5.17.1,下载地址 https://bitbucket.org/tildeslash/monit/downloads/

    1、tar zxvf monit-5.17.1-linux-x86.tar.gz

    2、cp monit-5.17.1/conf/monitrc /etc/

    3、chmod 0700 /etc/monitrc

    4、vi /etc/monitrc

    set daemon  30   ##设置30秒检查一次

    set logfile /var/log/messages  ##设置日志文件

    set httpd port 2812 and
       use address X.X.X.X
       allow 0.0.0.0/0.0.0.0 
       allow admin:123456

    设置访问及monit监听端口,允许登录ip,页面登录用户名密码

    check system 127.0.0.1
        if loadavg (1min) > 4 then alert
        if loadavg (5min) > 2 then alert
        if cpu usage > 90% for 10 cycles then alert
        if memory usage > 50% then alert
        if swap usage > 25% then alert

    设置监控本地CPU内存等信息

    check process xinetd with pidfile /var/run/xinetd.pid
        start program = "/etc/init.d/xinetd start"
        stop program = "/etc/init.d/xinetd stop"
        if changed pid then alert

    根据PID监控进程,服务死掉后自动重启

    check process mysql matching "/usr/bin/mysql"
        start program = "/etc/init.d/mysql start"
        stop program = "/etc/init.d/mysql stop"

    check process h5 with MATCHING h5
    start program = "/usr/local/bin/h5 > /var/log/h5.log &" with timeout 10 seconds
    stop program = "/bin/ps -ef |grep h5|grep -v "grep" |awk '{print $2}'|xargs kill -9" with timeout 10 seconds
    if failed port 8081 for 3 cycles then restart

    监听进程的另一种方式

    还有监听文件等等,就不写了。

    主要关注的告警功能

    set mailserver smtp.163.com port 25    ##设置邮件服务器及端口,这里使用的163邮件服务器
          username 发件人有限 password “发件人邮箱密码”

    set mail-format {
        from: shibo46@163.com
        subject: monit alert -- $EVENT $SERVICE
        message: $EVENT Service $SERVICE
        Date: $DATE
        Action: $ACTION
        Host: $HOST
        Description: $DESCRIPTION
        Your faithful employee,
        Monit
    }

    #设置邮件发送内容

    set alert XXXX@163.com  #设置收件人邮箱,多个收件人写多行

    配置好后执行monit程序启动 monit-5.17.1/bin/monit

  • 相关阅读:
    .net remoting学习(2)MarshalByRefObject与对象激活
    Android之旅Service
    Android之旅Handler与多线程
    Android之旅广播(BroadCast)
    .net remoting学习(3) 配置与服务端广播
    网址收藏
    Asp.net生命周期
    Android API 拦截系统短消息
    TCL脚本语言学习
    实现一个包含Microsoft.Advertising和SmartMad广告控件的UserControl
  • 原文地址:https://www.cnblogs.com/tiantianhappy/p/9084247.html
Copyright © 2011-2022 走看看