网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

nagios通过SNMP服务的网络监控

nagios通过SNMP服务的网络监控,当达到某个设定的值,那么就报警

创新互联建站专业为企业提供马村网站建设、马村做网站、马村网站设计、马村网站制作等企业网站建设、网页设计与制作、马村企业网站模板建站服务,十年马村做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

http://bbotte.blog.51cto.com/6205307/1403997 nagios服务端和客户端的安装配置

http://bbotte.blog.51cto.com/6205307/1583484 Nagios结合pnp4nagios图形监控


借助于网上提供的资源,做下面的操作

https://github.com/cloved/check_traffic/releases  下载最新版本的shell脚本
下载check_traffic.sh  V1.4.0,在附件已经上传

#被监控端/客户端

cd /usr/local/nagios/libexec/  #下载此脚本
chmod 755 check_traffic.sh
# yum install net-snmp-utils net-snmp net-snmp-libs bc -y  #因脚本里面需要用到bc
# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
# vim /etc/snmp/snmpd.conf                                 #配置snmp服务
# cat /etc/snmp/snmpd.conf|grep -v ^\# |sed '/^$/d'
com2sec notConfigUser  default       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.25.1.1
access  notConfigGroup ""      any       noauth    exact  all none none
view all    included  .1                               80
view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
access notConfigGroup ""      any       noauth    exact  all none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
 
# service snmpd start
# snmpd -L                                                  #测试snmp配置文件
Error opening specified endpoint ""
Server Exiting with code 1
# ./check_traffic.sh -V 2c -C public -H localhost -L -vvvv  #测试本机的网口,主要的数值是index后面的数字
List Interface for host localhost.
Interface index 1 orresponding to  lo
Interface index 2 orresponding to  eth0
Interface index 3 orresponding to  eth2
 
# ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,3000 -c 3001,5000 -K –B
OK - It is the first time of this plugins to run, or some data file lost. We will get the data from the next time.
 
# ll /var/tmp/check_traffic_127.0.0.1_2__itnms.hist_dat_64   #检查权限,所属用户和组都为nagios
#此脚本有帮助说明,用-h查看,上面 -I 2 即是对eth0做监控,-w 2000,3000是流入2000K/s,或发送3000K/s会提示warning
# -V    1|2c|3
#    Specify the version of snmp
#
# -C    Community
#    Specify the Community
#
# -H    host
#    Specify the host
#
# -6    Use 64 bit counter, ifHC*  instead of if*.
#
# -r    Use Range instead of single value in warning and critical Threshold;
#
# -I    interface
#    Specify the interface
#
# -N    interface name
#    Specify the interface name
#
# -L    List all Interfaces on specify host
#
# -B/b  Switch to B/s or bps, default is -b, bps
#
# -K/M  Switch to K or M (bsp,B/s), default is -K

#被监控端/客户端

vim /usr/local/nagios/etc/nrpe.cfg
command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,4000 -c 4000,6000 -K -B
# service nrped restart

#监控端/服务端

vim /usr/local/nagios/etc/objects/linuxhost.cfg
define host{
        use                     mylinux-server,service-pnp
        host_name               192_168_23_2
        alias                   server tongji
        address                 192.168.23.2
        }
   
vim /usr/local/nagios/etc/objects/linux13.cfg
define service{
        use                             linux-service,service-pnp
        host_name                       192_168_1_2
        service_description             check network
        check_command                   check_nrpe!check_traffic
        }

完事把nagios重启一下,刚开始会搜集数据,如下面的提示 大概2分钟就能看到图形界面了,

PNP4Nagios Version 0.6.24
Please check the documentation for information about the following error.
XML file "/usr/local/pnp4nagios/var/perfdata/192_168_1_2/check_network.xml" not found. Read FAQ online

file [line]:
application/models/data.php [312]:
back

在nagios页面会看到

nagios通过SNMP服务的网络监控

nagios通过SNMP服务的网络监控

此图会有in,out的网卡流量,可以在服务器ifstat验证

此外,http://nagios.manubulon.com/ 这个网站也值得一看,里面有http://nagios.manubulon.com/check_snmp_int.pl 脚本,同样可以实现对网络的监控

附件:http://down.51cto.com/data/2365405

当前名称:nagios通过SNMP服务的网络监控
文章出自:http://bjjierui.cn/article/pcsspi.html

其他资讯