Nagios 网卡流量监控.doc_第1页
Nagios 网卡流量监控.doc_第2页
Nagios 网卡流量监控.doc_第3页
Nagios 网卡流量监控.doc_第4页
Nagios 网卡流量监控.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Nagios 网卡流量监控本文所用到的监控流量插件来自石头的 1.20 版 shell 插件。感谢之。下载地址为: 点击下载 。 总体设置可以分为两块, linux 主机及非 linux 主机。稍有出入。不多说直接上配置一、linux主机主要步骤:1、安装snmpd服务软件包并设置启动之。2、上传监控插件至被监控机nagios/libexec目录并授权3、网卡参数检测4、nrpe.cfg文件增加监控command5、nagios服务器配置service.cfg添加监控项具体实施:1、 安装修改启动snmpd服务安装:rootnagios nagios# yum -y install net-snmp*Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfileSetting up Install ProcessPackage 1:net-snmp-devel--9.el5_5.1.i386 already installed and latest versionPackage 1:net-snmp-libs--9.el5_5.1.i386 already installed and latest versionPackage 1:net-snmp-utils--9.el5_5.1.i386 already installed and latest versionPackage 1:net-snmp-perl--9.el5_5.1.i386 already installed and latest versionPackage 1:net-snmp--9.el5_5.1.i386 already installed and latest versionNothing to do#我已经安装过了。就上面这些包了。修改snmpd.conf# source communitycom2sec notConfigUser (localhost也可不改) XXXX(共同体名)# group context sec.model sec.level prefix read write notifaccess notConfigGroup any noauth exact mib2 none none#改system为mib2view mib2 included .ernet.mgmt.mib-2 fc#去掉前面的#注释符2、上传插件被授权上传check_traffic.sh至/usr/local/nagios/libexec改属主为:nagioschown nagios.nagios ./check_traffic.sh3、网卡参数检测:rootOAServer etc# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H -LList Interface for host .Interface index 1 orresponding to loInterface index 2 orresponding to bond0Interface index 3 orresponding to eth0Interface index 4 orresponding to eth1Interface index 5 orresponding to sit0可以测试是否能够正常采集到数据/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H -I 2 -w 1200,1500 -c 1700,1800 -K -bOK - The Traffic In is 356Kbps, Out is 414Kbps, Total is 770Kbps. The Check Interval is 30s |In=356Kbps;1200;1700;0;0 Out=414Kbps;1500;1800;0;0 Total=770Kbps;2700;3500;0;0 Interval=30s;1200;1800;0;0注:-V snmp协议版本-C 共同体名-I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。该插件其它使用方法及各参数解释详情-help或者看上面论坛石头描述更改/var/tmp/check_traffic* 文件权限为nagios用户可读写。简单的给个777吧。chmod 777 /var/tmp/check_traffic__2.hist_dat_root_324、 更改nrpe.cfg增加如下行:commandcheck_traffic=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H -I 2 -w 300,350 -c 500,600 -K -B重启nrpe程序rootOAServer # ps aux |grep nrpenagios 2822 0.0 0.0 4808 1448 ? Ss Jun01 0:04 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -droot 1123 0.0 0.0 5936 736 pts/2 S+ 11:02 0:00 grep nrperootOAServer # kill -9 2822/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d5、nagios服务器(监控端)编辑service.cfg增加监控网卡流量项目;define servicehost_name WEBservice_description check_trafficcheck_command check_nrpe!check_trafficmax_check_attempts 5normal_check_interval 3retry_check_interval 2check_period 24x7notification_interval 10notification_period 24x7notification_options w,u,c,rcontact_groups sagroup6、重启 nrpe:# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d7、 如果是监控本机网卡流量:将命令写入监测端的 commands.cfg 中:# vi /usr/local/nagios/etc/objects/commands.cfgdefine command command_name check_traffic command_line $USER1$/check_traffic.sh -V 2c -C nagios -H localhost -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b在 service 段中调用就可以了。二、其它设备:(win主机、交换、路由、防火墙)这些主机上都是没办法安装nrpe插件的。所以我们只有通过snmp协议采集。(两者异同之处就在于snmp数据报文是否在网络传输。前者snmp数据只会在本机产生,自己采集自身数据而后由nrpe插件传输到nagios服务器前端显示出来(数据文件在本机)。后者则是nagios服务器通过snmp协议采集目标主机信息而后前端显示(数据文件在服务器)。就安全性而言,前者更优于后者。主要步骤:1、设置主机snmp协议(共同体名、权限、trap目标主机)2、nagios服务器snmp连接测试及网卡参数确定3、nagios服务器commands.cfg配置4、service.cfg监控项目添加5、重启nagios服务测试具体实施:演示设备:windows2003、netscreen防火墙、H3C路由以及H3C交换机。1、 设置主机snmp协议Windows主机:添加snmp组件。在服务里找到snmp service编辑如下:防火墙:路由器:交换机:snmp-agentsnmp-agent local-engineid 800063A2000FE2CCFAA36877snmp-agent community write XXXXXsnmp-agent sys-info version allsnmp-agent target-host trap address udp-domain XXXXXX params securityname XXXXX1、 nagios服务器snmp连接测试及网卡参数确定:以防火墙为例,找到个接口参数:rootnagios nagios# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C ksense -H 54 -LList Interface for host 54.Interface index 1 orresponding to ethernet0/0Interface index 2 orresponding to ethernet0/1Interface index 3 orresponding to ethernet0/2Interface index 4 orresponding to ethernet0/3Interface index 5 orresponding to vlan1注意:index 后数字和网卡对应关系。后面写service.cfg时需用到。2、 配置commands.cfg增加如下内容:rootnagios nagios# tail -8 /usr/local/nagios/etc/commands.cfg#check_traffic#define commandcommand_name check_trafficcommand_line $USER1$/check_traffic.sh -V 2c -C ksense -H $HOSTADDRESS$ -I $ARG1$ $ARG2$ $ARG3$ -K -B3、 service.cfg监控项目添加:以防火墙设备为例,其它方法相同define servicehost_name juniper-ssg-320service_description check_traffic_trustcheck_command check_traffic!1 -w 600,600 -c 800,800#注:叹号后面数据对应上面的$ARG1$ $ARG2$ $ARG3$3个字段,中间空格隔开max_check_attempts 5normal_check_interval 3retry_check_interval 2check_period 24x7notification_interval 10notification_period 24x7notification_options w,u,c,rcontact_groups sagroupdefine servicehost_name juniper-ssg-320service_description check_traffic_DMZcheck_command check_traffic!2 -w 600,600 -c 800,800max_check_attempts 5normal_check_interval 3retry_check_interval 2check_period 24x7notification_interval 10notification_period 24x7notification_options w,u,c,rcontact_groups sagroupdefine servicehost_name juniper-ssg-320service_description check_traffic_untrust1check_command check_traffic!3 -w 600,600 -c 800,800max_check_attempts 5normal_check_interval 3retry_check_interval 2check_period 24x7notification_interval 10notification_period 24x7notification_options w,u,c,rcontact_groups sagroupdefine servicehost_name juniper-ssg-320service_description check_traffic_untrust2check_command check_traffic!4 -w 600,600 -c 800,800max_check_attempts 5normal_check_interval 3retry_check_interval 2check_period 24x7notification_interval 10notification_period 24x7notification_options w,u,c,rcontact_groups sagroup5、rootnagios nagios# !1025/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgTotal Warnings: 0Total Errors: 0检查下配置文件是否有报错。没有就重启nagios服务即可生效了。监控效果图:Pnp图形:原文链接:/201011/51.htmlNagios相关问题页面问题1Error: Could not open command file /opt/nagios/var/rwnagios.cmd可通过更改此权限解决:Chmod 777 $nagioshome/var/rw/nagios.cmd上面那方法不太好使重启nagios后可能还会出现类似问题网上有另一种方法:将nagios和apache放到一个组nagcmd rootlocalhost etc# id nagiosuid=607(nagios) gid=605(nagios) groups=605(nagios),607(nagcmd)rootlocalhost etc# id apacheuid=48(apache) gid=48(apache) groups=48(apache),607(nagcmd)另外修改完后,还需要重启一下apache页面问题2通过验证访问问题,通过apache的htpasswd文件给nagios页面增加了页面用户访问控制权限后,用户登录后并不能查看到监控的相关信息更改$nagioshome/etc/cgi.cfg文件#default_user_name=guest 去掉该行的#,并更改guest为你所设置的用户我的用户为guest如下含有nagiosadmin字段的允许用户的一些权限设置,在vi cgi.cfg时用:1,$s/nagiosadmin/nagiosadmin,guest/authorized_for_configuration_information=nagiosadmincheck_mysql问题由于需要监控相关mysql,在安装nagios-plugin时,系统并没有安装mysql-devel在绕了个圈查找相关脚本时,有网友告知安装了mysql-devel包后再编译安装nagios-plugin时会生成相关check_mysql#Mysql p进入mysql后创建nagios监控库create database nagios;授于监控端IP查询该库权限grant select on nagios.* to nagiosIP;nagios监控端配置vi services.cfg加入define servicehostgroup_name game-hostsservice_description mysqlcheck_command check_mysqlcontact_groups testcheck_period 24x7max_check_attempts 4normal_check_interval 3retry_check_interval 2contact_groups testnotifications_enabled 1Vi commands.cfg加入define commandcommand_name check_mysqlc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论