白森 发表于 2019-1-13 15:05:55

Nagios监控(linux)网卡流量

  要用到的插件check_traffic.sh 下载地址:http://pan.baidu.com/s/1jGmR1S6
  前提,已有nagios服务端(192.168.5.203) 和被监控端(192.168.5.204)
  1.检测服务端和被监控端是否安装snmp,如果没有用yum安装 #yum install snmp*
  # rpm -qa | grep snmp
  net-snmp-libs-5.5-37.el6.x86_64
  net-snmp-utils-5.5-37.el6.x86_64
  net-snmp-python-5.5-37.el6.x86_64
  net-snmp-perl-5.5-37.el6.x86_64
  net-snmp-5.5-37.el6.x86_64
  2.在nagios服务端和被监控端 修改/etc/snmp/snmpd.conf (nagios服务端和被监控端配置文件内容一致)
  # vim /etc/snmp/snmpd.conf
http://s3.运维网.com/wyfs02/M02/49/B9/wKioL1QZX1PiKlMXAAI7ubB7BSU502.jpg
  41 public 为密码 (网上看有些问文档 defualt改成了IP地址,经过验证,用default即可)
  57 新加一行 (修饰63行的mib2)
  63 mib2 (exact 与 none之间的参数改成了mib2)
  重启snmpd(nagios服务端和被监控端都要重启snmpd)

  # service snmpd restart
  #chkconfig snmpd on
  3.在被监控端定义命令

  # vim /usr/local/nagios/etc/nrpe.cfg
http://s3.运维网.com/wyfs02/M02/49/B8/wKiom1QZYtuT5aquAAICK_t-Iw4663.jpg208 -C public (snmp.conf里的public)
  -H 被监控端网卡IP,也可以写127.0.0.1
  -I 2 表示eth0的进流量 ;1 是lo ;3是eth1;4是eth2;
  -w 200,300 warning的范围
  -c 400,500 critical的范围
  -K -B是单位
  
  用这个命令可以查看 1 对应lo ,2 对应eth0
  # /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 192.168.5.204 -L
  List Interface for host 192.168.5.204.
  Interface index 1 orresponding tolo
  Interface index 2 orresponding toeth0
  重启nrpe进程

  4.在nagios服务端添加服务
  先测试一下:可能会出现以下报错

  
  # /usr/local/nagios/libexec/check_nrpe-H 192.168.5.204 -c check_traffic
  Unknown - Read or Write File /var/tmp/check_traffic_192.168.5.204_2.hist_dat_root__64 Error with user uid=500(nagios) gid=500(nagios) groups=500(nagios) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023.
  解决方法:清空/var/tmp/里的临时文件(nagios服务端和被监控端都要清空)
  清空后再测试,提示以下信息表上能监测流量数据
  
  # /usr/local/nagios/libexec/check_nrpe-H 192.168.5.204 -c check_traffic
  OK - It's the first time for this plugins run. We'll get the data from the next time.
  添加服务
  # vim /usr/local/nagios/etc/objects/services.cfg

  http://s3.运维网.com/wyfs02/M00/49/B8/wKiom1QZaOvQAjx2AABzwvthu3c432.jpg
  21 使用local-service模板,services-pnp使用画图
  22 主机名 web   (hosts.cfg已定义)
  23 服务描述 名称自定义
  24 检查命令
  重启ngios服务
  访问监控页面
  http://s3.运维网.com/wyfs02/M00/49/BA/wKioL1QZaeDg84OCAAGwXnRRLLI291.jpg
  看到这个图并不是马上就是正常OK状态,需要等待几分钟
  点击小太阳能看到图
  

  

  




页: [1]
查看完整版本: Nagios监控(linux)网卡流量