nagios网卡流量监控

ngios 流量监控文档<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

所需软件net-snmp net-snmp-utils net-snmp-libs

所需脚本 check_traffic.sh 可从下面链接下载

1.查看系统是否安装rpm –qa|grep snmp,如没有上传以上包,再上传check_traffic.sh脚本至$nagios/libexec/,并更改traffic脚本权限为755

2.未安装时下载上面的snmprpm包我用的为

net-snmp-5.1.2-13.el4.i386 net-snmp-utils-5.1.2-13.el4.i386 net-snmp-libs-5.1.2-13.el4

3.vi /etc/snmp/snmp.conf

a)更改

#       sec.name        source          community

com2sec notConfigUser   default         public

#       sec.name  source          community

com2sec notConfigUser  localhost(源IP       nagios(访问密码)

b)更改

access  notConfigGroup ""      any       noauth    exact  systemview none none

access notConfigGroup "" any noauth exact mib2 none none

c)去掉该的#

#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc

d)启动snmp

/etc/init.d/snmpd start

检查启动情况

Netstat –na|grep 161

测试snmpsnmpwalk -v 1 -c nagios localhost system

Traffic 脚本测试
如果不知道网卡
/usr/local/nagios/libexec//check_traffic.sh -V 2c -C nagios -H localhost –L命令列出
 
/usr/local/nagios/libexec//check_traffic.sh -V 2c -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M –b

4./usr/local/nagios/etc/nrpe.cfg

加入command[check_traffic]=/usr/local/nagios//libexec/check_traffic.sh -V 2c -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M –b

5.重启xinetd

6.更改下面的文件权限让nagios用户拥有读写权限

chmod 666 /var/tmp/check_traffic_localhost_2.hist_dat

 

 

7.nagios监控端配置

services.cfg加入

define service{

        hostgroup_name                  gahosts,rehosts

        service_description             TRAFFIC

        check_command                   check_nrpe_traffic

        contact_groups                  test

        check_period                    24x7

        max_check_attempts              4

        normal_check_interval           3

        retry_check_interval            2

        contact_groups                  test

        notifications_enabled           1

        }

commads.cfg加入

define command{

        command_name    check_nrpe_traffic

        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$  -c check_traffic

        }

 

 

Nagios相关问题

页面问题1

Error: Could not open command file '/opt/nagios/var/rwnagios.cmd’

可通过更改此权限解决:Chmod 777 $nagioshome/var/rw/nagios.cmd

上面那方法不太好使重启nagios后可能还会出现类似问题

网上有另一种方法:

nagiosapache 放到一个组nagcmd
[root@localhost etc]# id nagios
uid=607(nagios) gid=605(nagios) groups=605(nagios),607(nagcmd)
[root@localhost etc]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),607(nagcmd)
另外修改完后,还需要重启一下apache

页面问题2
通过验证访问问题,通过apachehtpasswd文件给nagios页面增加了页面用户访问控制权限后,用户登录后并不能查看到监控的相关信息

更改$nagioshome/etc/cgi.cfg文件

#default_user_name=guest 去掉该行的#,并更改guest为你所设置的用户我的用户为guest

如下含有nagiosadmin字段的允许用户的一些权限设置,

vi cgi.cfg时用:1,$s/nagiosadmin/nagiosadmin,guest/

authorized_for_configuration_information=nagiosadmin

check_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 nagios@"IP";

nagios监控端配置

vi services.cfg加入

define service{

        hostgroup_name                  game-hosts

        service_description             mysql

        check_command                   check_mysql

        contact_groups                  test

        check_period                    24x7

        max_check_attempts              4

        normal_check_interval           3

        retry_check_interval            2

        contact_groups                  test

        notifications_enabled           1

        }

Vi commands.cfg加入

define command{

        command_name    check_mysql

        command_line    $USER1$/check_mysql -H $HOSTADDRESS$  -u nagios  -d nagios -w 15 -c 20

        }

配置mysql监控时需注意版本相关问题 如果版本不同生成的check_mysql监控就不能实现

 

关于check_http问题 此监控需在你网站的默认根目录建立一个index.html文件供nagios抓取

关于check_mem问题,check_memcheck_traffic均来自于网络
 
 
关于nagios流量监控问题

监控脚本报NRPE: Unable to read output 

因为那个traffic脚本是在http://sourceforge.net/下载过来的,看了下里面内容执行了下发现该脚本比较简单但实用没有提示相关错误的功能,在出现这个问题的时候我在看nrpe相关文档及网上搜索相关资料,发现大部分人出现的问题是在nrpe.cfg配置,及plugin安装,脚本问题,但在排除这几个出错的可能性后,不得其解,找到以前的同事问了下,我描述了下相关问题他让我查看下/tmp下生成的临时文件,我看了下权限是root,更改为nagios用户问题解决

command[check_traffic]=/usr/local/nagios//libexec/check_traffic -H localhost -i 2 -b 8000000 -r sss -w 80 -c 90

 

该监控脚本的参数,必需全部填上才可使用

-i是网卡index号一般是etho为2 如果不知道可以用附件中的check_traffic.sh脚本用-L参数列数,-b为网卡最大流量注意此值与报警有关,根据情况设置单位为byte,-r为生成的rrd文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值