zoukankan      html  css  js  c++  java
  • 服务器监控之热身:只是试用monit

    一、需求

      一直想为机房众多服务器找一个合适的监控方案,要求:

    1. 监控SAP应用状态;
    2. 监控Oracle服务器状态;
    3. 监控文件系统使用情况,最好有历史数据展示图;
    4. CPU、内存、负载情况,最好有历史数据展示图;
    5. 监控服务器是否可用;
    6. 必须能通过邮件或短信提醒,或者易于扩展提醒功能; 

      暂时想到这么多,目前找到的开源监控系统有:cacti、nagios、zenooshyperic等等一些,比较感兴趣的同时貌似有一定用户量的是:cactinagios,以后有机会试试。

    二、monit干什么

      通过飞龙日志看到monit监控系统关键进程的文章,觉得很清凉,提供web管理界面,还能重启关键进程和监控远程主机的常用端口和协议,试试用了一下。最终达到:

    1. 监控安装monit服务器本身的cpu、内存、负载等信息(可以配置监控关键进程如mysql等)
    2. 监控远程服务器是否ping通
    3. 通过配置发送邮件

      参考网络上的资料,感觉monit的特点主要集中在:

    1. 查看localhost的状态,同时能灵活设定条件(cpu、内存使用率,空间使用率,失败次数,发生周期)判断故障是否发生并报警
    2. 对配置后的进程根据条件进行重启等一些操作

      缺点:

    1. 没有历史数据库并绘图展示;
    2. 不支持snmp协议,对远程服务器监控功能较差;

    三、安装配置monit

    1.lucid(172.20.10.196)安装

    # apt-get install monit

    很方便安装成功,直接启动monit不成功,需要配置。

    2.配置lucid

      先配置/etc/default/monit文件中的startup参数:

    # You must set this variable to for monit to start
    startup=1

      然后根据需要配置自己的/etc/monit/monitrc文件,里面包括了需要监控的localhost主要信息和关键进程信息等等等等重要信息,参照注释:

    ##
    #
    # Start monit in the background (run as a daemon):
    #
    set daemon 10# check services at 2-minute intervals
    ......
    ## Set syslog logging with the 'daemon' facility. If the FACILITY option is
    #
    # omitted, monit will use 'user' facility by default. If you want to log to
    #
    # a stand alone log file instead, specify the path to a log file
    #
    #
    set logfile syslog facility log_daemon
    set logfile /var/log/monit.log
    ......
    ## Set the list of mail servers for alert delivery. Multiple servers may be
    #
    # specified using comma separator. By default monit uses port 25 - this
    #
    # is possible to override with the PORT option.
    #
    set mailserver smtp.gmail.com port 587
    username
    "yourname@gmail.com" password "yourpasswd" using tlsv1 with timeout 30 seconds
    ......
    # set mail-format { from: monit@foo.bar }
    #
    #
    set mail-format { from: erick@yunnancopper.com }
    ......
    #
    #
    set alert sysadm@foo.bar # receive all alerts
    #
    set alert manager@foo.bar only on { timeout } # receive just service-
    #
    # timeout alert
    #
    #
    set alert erick@yunnancopper.com
    ......
    ## Monit has an embedded web server which can be used to view status of
    #
    # services monitored, the current configuration, actual services parameters
    #
    # and manage services from a web interface.
    #
    set httpd port 2812 and
    use address
    172.20.10.196
    allow
    0.0.0.0/0.0.0.0
    allow admin:admin
    #加入一个远程服务器检查是否ping通
    check host debianVM with address 172.20.10.195
    if failed icmp type echo count 3 with timeout 3 seconds then alert

      上面这个monit配置文件里面配置了使用Gmail的smtp服务器进行提醒的发送,这里遇到一个问题,不能设置普通验证类型的smtp服务器,高手请解答;这里monit还提供了一个内置的web server,这里地址为:http://172.20.10.196:2812/,可以方便的查看监控内容和配置情况:

    3.重启monit

    sudo /etc/init.d/monit start
    sudo /etc/init.d/monit stop
    sudo /etc/init.d/monit restart

    四、总结

      简单的试用了monit的基本监控功能,效果不错,但绝不是他的所有功能,同时还有一个收费工具M/Monit提供将所有安装monit的客户端(这里可以叫agent)集成到一个web接口的平台进行管理监控,但是不便宜;以后有时间再对Cacti进行简单的介绍,感觉所有的工具都不是十分贴合需求,但是能有一个图形化的监控工具对于善于汇报的中国系统管理员非常有用,最后祝大家事业有成。

  • 相关阅读:
    Memcached初识
    排序
    查找
    Redis初识

    C#
    C#
    C#
    C#
    C#
  • 原文地址:https://www.cnblogs.com/ddr888/p/1969087.html
Copyright © 2011-2022 走看看