您的位置:首页 > 移动开发 > IOS开发

nagios流量监控的三种方法

2011-01-07 13:34 288 查看
使用nagios来监控接口流量主要有三种方法

1.使用snmp通用的做法,以下接口可以得到数据包的流量

IF-MIB::ifInOctets

snmpwalk -v 2c -c public 127.0.0.1 IF-MIB::ifInOctets

IF-MIB::ifOutOctets

snmpwalk -v 2c -c public 127.0.0.1 IF-MIB::ifOutOctets

2.使用check_traffic.sh脚本,这个个人比较偏好ITNMS石头版主很强大。

查看接口

./check_traffic.sh -V 2c -C public -H 127.0.0.1 -L

抓取接口流量

./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w200,300 -c400,500 -K -B

命令定义

define command{

command_name check_traffic

command_line /usr/lib/nagios/plugins/check_traffic.sh -V1 -C '$ARG1$' -H $HOSTADD

RESS$ -I '$ARG2$' -w '$ARG3$' -c '$ARG4$' '$ARG5$' -b

}

在这里第五个参数可以根据需要替换为M或者K

这个做流量监控还没有出现过问题,就是有时候没有装bc包的时候会报错

-bash-3.2# /usr/local/nagios/libexec/check_traffic.sh -V 1 -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M -b

/usr/local/nagios/libexec/check_traffic.sh: line 449: bc: command not found

/usr/local/nagios/libexec/check_traffic.sh: line 454: bc: command not found

/usr/local/nagios/libexec/check_traffic.sh: line 457: bc: command not found

/usr/local/nagios/libexec/check_traffic.sh: line 458: bc: command not found

/usr/local/nagios/libexec/check_traffic.sh: line 461: [: too many arguments

/usr/local/nagios/libexec/check_traffic.sh: line 576: bc: command not found

/usr/local/nagios/libexec/check_traffic.sh: line 577: bc: command not found

Unknown - Can not found data in the history data file. Please to check the file /var/tmp/check_traffic_localhost_2.hist_dat_root__32 ,or use use verbose mode and check the debug file

3.使用nagios自带的check_mrtgtraf来监控流量,前提是系统上面已经安装了mrtg了。让nagios来读取mrtg的流量日志数据,check_mrtgtraf -h

Options:

-h, --help

Print detailed help screen

-V, --version

Print version information

-F, --filename=STRING

File to read log from

-e, --expires=INTEGER

Minutes after which log expires

-a, --aggregation=(AVG|MAX)

Test average or maximum

-w, --warning

Warning threshold pair <incoming>,<outgoing>

-c, --critical

Critical threshold pair <incoming>,<outgoing>

define command{

command_name traffic_average

command_line /usr/lib/nagios/plugins/check_mrtgtraf '$ARG1$' 10 AVG '$ARG2$' '$ARG

3$' '$ARG4$' '$ARG5$'

}

值得注意的是这里的-F参数后面的日志文件是mrtg获取的日志数据的文件名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: