nagios 配置 check_traffic 流量监控模块(Server 端)

  1. 安装软件包
    yum -y install net-snmp*
    chkconfig nrpe on
    chkconfig snmpd on
    chkconfig nagios on
  2. 修改snmp参数,vi /etc/snmp/snmpd.conf(可备份snmpd.conf,修改下面的localhost-IP为服务器IP,保存此文件即可)
    com2sec notConfigUser 127.0.0.1 public 
    com2sec notConfigUser localhost-IP public 
    
    group notConfigGroup v1 notConfigUser 
    group notConfigGroup v2c notConfigUser 
    
    view systemview included .1.3.6.1.2.1.1 
    view systemview included .1.3.6.1.2.1.2 
    view systemview included .1.3.6.1.2.1.25.1.1 
    view all included .1 
    
    access notConfigGroup "" any noauth exact all none none 
    snmpd.conf Code
  3. 拷贝check_traffic.sh到/usr/lib64/nagios/plugins/check_traffic.sh
    check_traffic.sh文件GitHub下载地址:https://github.com/cloved/check_traffic/blob/master/check_traffic.sh
    wget https://github.com/cloved/check_traffic/archive/master.zip

  4. 赋予执行权限并测试:
    chmod +x check_traffic.sh
    ./check_traffic.sh -V 2c -C public -H your_ip -I 2 -w 1200,1500 -c 1700,1800 -K -B
    ./check_traffic.sh -V 2c -C public -H your_ip -L
    ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -L

  5. 例子:
    ./check_traffic.sh -V 2c -C public -H your_ip -N eth0 -w 8,7 -c 16,14 -M -b
    -V snmp 版本
    -C 认证信息
    -H 主机IP
    -N 网卡
    -w 8,7   下行/上行流量超过 8,7 Mbit/s 警告
    -c 16,14 下行/上行流量超过 16,14 Mbit/s 严重
    -M 兆
    -b 比特

  6. 编辑/etc/nagios/objects/command.cfg文件,追加:

    # 'check_traffic' command definition
    define command{
            command_name    check_traffic
            command_line    $USER1$/check_traffic.sh -V 2c -C public -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b
            }
    Check _traffic Code
  7. 编辑/etc/nagios/objects/localhost.cfg文件

    define service{
            use                             local-service         ; Name of service template to use
            host_name                       localhost
            service_description             Check_Trafffic
            check_command                   check_traffic!2!12,15!20,30
            notifications_enabled           1
            normal_check_interval           5
            retry_interval          1
            }
    localhost.cfg

    并且修改localhost.cfg文件中的IP地址(127.0.0.1)为本机的IP!!!!!!!(坑了我2天)

  8. 删除临时文件
    /var/tmp/check_traffic_${Host}_${Interface}.hist_dat文件
  9. 重启nagios服务,配置成功后的截图如下


  10. 参考下面链接的部分内容:
    http://2860664.blog.51cto.com/2850664/1567068

转载于:https://www.cnblogs.com/Mrhuangrui/p/4570200.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值