Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3287709
  • 博文数量: 515
  • 博客积分: 5116
  • 博客等级: 大校
  • 技术积分: 4137
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-30 11:24
个人简介

黑马王子就是我! 技术认证:系统分析师,网络规划设计师,网络工程师,信息系统监理师,系统集成项目管理师,初级程序员,MCSE,MCDBA,CCNA 目前主攻虚拟化技术,VPN,系统架构,集群和高可用性等。

文章分类

全部博文(515)

文章存档

2023年(11)

2022年(17)

2021年(19)

2020年(28)

2019年(42)

2018年(53)

2017年(41)

2016年(33)

2015年(43)

2014年(25)

2013年(13)

2011年(6)

2010年(28)

2009年(47)

2008年(55)

2007年(26)

2006年(28)

分类: LINUX

2009-07-17 16:27:04


作为网络管理员,必须时刻肩负着维持公司网络稳定的任务。如果对于公司内网的机 器实时监控,有人流量比较大,属于非正常状态,或者因中毒导致流量很大的机器,大家就可以根据BANDWIDTHD的实时图像界面很直观的找出来,结合防 火墙,加以控制。我想,这样大大减少我们排查故障机器的工作量了。下面我给大家简单的写写我的安装过程吧。

   安装 bandwidthd 很简单,首先架设一台LINUX系统的机器,当然最后用在把BANDWIDTHD装在网关上。   我测试的系统跑的是CENTOS 5.2。

软件包准备:

gdbm-devel-1.8.0-26.2.1
gdbm-1.8.0-26.2.1
gdb-6.5-37.el5
gd-2.0.33-9.4.el5_1.1
gd-devel-2.0.33-9.4.el5_1.1

libpng-1.2.10-7.1.el5_0.1
libpng-devel-1.2.10-7.1.el5_0.1

libpcap-0.9.4-12.el5
libpcap-devel-0.9.4-12.el5

BANDWIDTHD软件和补丁

bandwidthd-1.2.1b.tgz

bandwidthd-cp3-1.2.1b.patch.gz

建议这些软件一个都不要少的,都安装上,否则在编译 的时候出现各种问题。

先安装支持的软件,就是一开始列出的那么多了。可以用rpm -qa | grep gd 这个命令查看包的安装情况

执行安装
把bandwidthd-cp3-1.2.1b.patch放在bandwidthd-1.2.1b目录同一级.

tar -xvzf bandwidthd-1.2.1b.tgz
显示:
[root@mail bandwidthd]# tar zxvf bandwidthd-1.2.1b.tgz
bandwidthd-1.2.1b/
bandwidthd-1.2.1b/etc/
bandwidthd-1.2.1b/etc/bandwidthd.conf
bandwidthd-1.2.1b/CHANGELOG
bandwidthd-1.2.1b/Makefile
bandwidthd-1.2.1b/Makefile.BSD
bandwidthd-1.2.1b/Makefile.Solaris
bandwidthd-1.2.1b/README
bandwidthd-1.2.1b/TODO
bandwidthd-1.2.1b/bandwidthd-0.4.kdevprj
bandwidthd-1.2.1b/bandwidthd.c
bandwidthd-1.2.1b/bandwidthd.h
bandwidthd-1.2.1b/conf.l
bandwidthd-1.2.1b/conf.y
bandwidthd-1.2.1b/graph.c
bandwidthd-1.2.1b/htdocs/
bandwidthd-1.2.1b/htdocs/index.html
bandwidthd-1.2.1b/htdocs/legend.gif
bandwidthd-1.2.1b/htdocs/logo.gif
bandwidthd-1.2.1b/htdocs/index2.html
bandwidthd-1.2.1b/htdocs/index3.html
bandwidthd-1.2.1b/htdocs/index4.html
bandwidthd-1.2.1b/conf.tab.c
bandwidthd-1.2.1b/conf.tab.h
bandwidthd-1.2.1b/conf.l.c
进入解压目录 cd bandwidthd-1.2.1b
执行补丁:   patch -p1 < ../bandwidthd-cp3-1.2.1b.patch
显示:
[root@mail bandwidthd-1.2.1b]# patch -p1 < ../bandwidthd-cp3-1.2.1b.patch
patching file bandwidthd-0.4.kdevprj
patching file bandwidthd.c
patching file bandwidthd.h
patching file conf.l
patching file conf.y
patching file etc/bandwidthd.conf
patching file etc/bandwidthd.conf.orig
patching file graph.c
patching file Makefile
patching file Makefile.BSD
patching file Makefile.Solaris
patching file tables.c
patching file tables.h

显示这步,说明补丁打成功了。

然后执行编译 make install
显示:
[root@mail bandwidthd-1.2.1b]# make install
cc -I/usr/local/include -O3 -Wall    -c -o bandwidthd.o bandwidthd.c
cc -I/usr/local/include -O3 -Wall    -c -o graph.o graph.c
bison -d conf.y
cc -I/usr/local/include -O3 -Wall    -c -o conf.tab.o conf.tab.c
lex -s -i -t -I conf.l >; conf.l.c
cc -O3   -c -o conf.l.o conf.l.c
cc -I/usr/local/include -O3 -Wall    -c -o tables.o tables.c
cc -I/usr/local/include -O3 -Wall bandwidthd.o graph.o conf.tab.o conf.l.o tables.o -o bandwidthd -L/usr/local/lib -lgd -lpng -lpcap  
if [ ! -d /usr/local/bandwidthd/etc ] ; then mkdir -p /usr/local/bandwidthd/etc ; fi
if [ ! -d /usr/local/bandwidthd/htdocs ] ; then mkdir -p /usr/local/bandwidthd/htdocs ; fi
cp bandwidthd /usr/local/bandwidthd
if [ ! -f /usr/local/bandwidthd/etc/bandwidthd.conf ] ; then cp etc/bandwidthd.conf /usr/local/bandwidthd/etc/ ; fi
cp htdocs/legend.gif /usr/local/bandwidthd/htdocs/
cp htdocs/logo.gif /usr/local/bandwidthd/htdocs/

这样就算安装完成了,它会将 bandwidthd 安装 至 /usr/local/bandwidthd 下

配置bandwidthd.conf
bandwidthd 的配置很简单,一个配置文件搞定,
一般修改一下网段和掩码,其他的用默认值即可,编辑:
/usr/local/bandwidthd/etc/bandwidthd.conf
####################################################
# Bandwidthd.conf
#
# Commented out options are here to provide
# documentation and represent defaults

# Subnets to collect statistics on
#subnet 10.0.0.0 255.0.0.0
#subnet 208.16.191.0 255.255.255.0
subnet 192.168.3.1 255.255.255.0   #以3网段为例
# Device to listen on
dev "eth0"   #(这是你要检测的网卡,可以调整为对应的网络连接设备)
###################################################
# Options that don't usually get changed
# An interval is 2.5 minutes, this is how many
# intervals to skip before doing a graphing run
skip_intervals 0   #默间隔认2.5 minutes 刷新

# Graph cutoff is how many k must be transfered by an
# ip before we bother to graph it
graph_cutoff 1024   #默间1M 以上的流量才有图形

#Put interface in promiscuous mode to score to traffic
#that may not be routing through the host machine.
promiscuous true    #让网卡在混杂模式中记录

#Log data to cdf file htdocs/log.cdf   在bandwidthd中生成log2.cdf   log.cdf格式数据记录
output_cdf true

#Read back the cdf file on startup 在启动bandwidth时重新读取cdf的数据
recover_cdf true

#Libpcap format filter string used to control what bandwidthd see's
#Please always include "ip" in the string to avoid strange problems
#以ip为过滤对象
filter "ip"

#Draw Graphs
graph true

#以下是我打了补丁bandwidthd-cp3-1.2.1b.patch才有的,
# List of controled protocols
# format: item "item_name" rgb_color protocol ports 这是记录的格式:端口名字,RGB颜色,端口号
# obs.: The yellow (0xffff00) color is predefined to the "TOTAL" item 黄色预设为TOTAL的颜色
item "TCP"   0x00ff00 tcp   all
item "HTTP" 0x0000ff tcp   80 443
item "FTP"   0xc0c0ff tcp   20 21
item "P2P"   0xff00ff tcp   1044 1045 1214 4661 4661 4665 5190 5500 5501 5502 5503 6346 6347 6666 6667 7788 8888 8889 28864 288
65
item "UDP"   0x800000 udp   all
item "ICMP" 0xff0000 icmp all
item "SMTP"   0xFF8C00 tcp   25  
item "POP3"   0x00FFFF tcp   110

其中SMTP和POP3是我为了更详细的数据流而增加上去的.你也可以增加你想检测的端口,这就是为何我推荐打这个补丁再安装的原因.
存盘之后,便可执行。

运行 ,要先转到安装目录才能执行
cd /usr/local/bandwidthd
./bandwidthd  

在web 主目录下做个软连接,执行
ln -s /usr/local/bandwidthd/htdocs bandwidthd
接着您便可用 http://你的主机/bandwidthd

这样就可以在浏览器里面检测你需要的流量了 ,它会自动排出前20个流量高的机器的IP并列在页面上。配置很简单,希望大家有不明白的地方和我交流!

参考


阅读(2049) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~