Linux下使用命令iftop
查看带宽实时情况,这个命令是需要安装的。
安装
先安装依赖
yum install flex byacc libpcap ncurses ncurses-devel libpcap-devel
下载安装包
wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz
解压
tar xvf iftop-0.17.tar.gz
安装
cd iftop-0.17
./configure --prefix=/usr/local/iftop
make && make install
在configure
的时候遇到过一个错误
configure: error: can't find pcap.h You're not going to get very far without libpcap.
依赖没有安装完成,我多试了几次安装依赖的命令莫名其妙的安装成功了。
上网搜索解决问题的时候,有些方法是说手动添加源
ftp://fr2.rpmfind.net/linux/dag/redhat/el7/en/x86_64/dag/RPMS/
可以在这个里面寻找跟系统版本对应的源,下载下来,然后添加,例如
wget ftp://fr2.rpmfind.net/linux/dag/redhat/el7/en/x86_64/dag/RPMS/iftop-1.0-0.pre3.el7.rf.x86_64.rpm
rpm -ivh iftop-1.0-0.pre3.el7.rf.x86_64.rpm
这个是Centos7版本的源,如果是Centos6的则找el6的源,版本别添加错了,网上教程跟自己系统版本不一定一致,不能全部复制,执行,曾经吃过亏,后面学乖了
使用
命令行执行
iftop
结果显示
TX
:发送的流量
RX
:接收的流量
TOTAL
:发送和接收的总流量
cumm
:iftop运行到现在的总流量
peak
:网卡流量峰值
rates
:2s,10s,40s 平均流量值
单台服务器使用iftop命令,即可,但是如果服务器集群可以使用Ntop.
.