nicstat是一款分析网卡流量信息的工具,原生于Solaris,后来被移植到Linux上,官网地址https://blogs.oracle.com/timc/entry/nicstat_the_solaris_and_linux。
以下摘自官网:
nicstat is to network interfaces as "iostat" is to disks, or "prstat" is to processes. It is designed as a much better version of "netstat -i". Its differences include:
Reports bytes in & out as well as packets.
Normalizes these values to per-second rates.
Reports on all interfaces (while iterating)
Reports Utilization (rough calculation as of now)(Note:1.9.5 version could show both read and write utilization.)
Reports Saturation (also rough)
Prefixes statistics with the current time
nicstat对于分析网络接口的方法类似于iostat分析磁盘使用率,或者说类似于prstat分析进程信息,它比netstat -i更高级的地方在于:可以输出网卡速率,read/write 使用率,网卡的TCP, UDP信息。有人说那还不如用iptraf或者iftop呢,不一样都能查看网卡速率吗?nicstat强大的地方是可以以iostat的方式直接输出网卡使用率,而iftop,iptraf 只能跟踪单个网卡信息。
可以对比一下netstat -i 和 nicstat的输出数据:
显而易见,nicstat的输出更人性化。
命令帮助信息:
# root at shanker in ~/nicstat-1.95 [3:00:43] # ./nicstat.sh -h USAGE: nicstat [-hvnsxpztualMU] [-i int[,int...]] [-S int:mbps[,int:mbps...]] [interval [count]] -h # help -v # show version (1.95) -i interface # track interface only -n # show non-local interfaces only (exclude lo0) -s # summary output -x # extended output -p # parseable output -z # skip zero value lines -t # show TCP statistics -u # show UDP statistics -a # equivalent to "-x -u -t" -l # list interface(s) -M # output in Mbits/sec -U # separate %rUtil and %wUtil -S int:mbps[fd|hd] # tell nicstat the interface # speed (Mbits/sec) and duplex eg, nicstat # print summary since boot only nicstat 1 # print every 1 second nicstat 1 5 # print 5 times only nicstat -z 1 # print every 1 second, skip zero lines nicstat -i hme0 1 # print hme0 only every 1 second下面介绍一下如何安装nicstat,这个软件是非标准的Linux软件,所有用apt-get或者yum的方式都没法安装,只能下载官网的源码编译安装。
下载地址:http://sourceforge.net/projects/nicstat/files/
我这里下载的是最新版的1.95,这个版本多了一个新功能是-U,将read 和write的使用率分开显示。
安装README.txt的信息尝试make,但是失败了,后来发现如果不编译,直接使用目录下面自带的shell也可以,方法如下:
因为nicstat是在32位系统上编译的,所以要安装32位的libc文件,如果使用的是Ubuntu系统:
如果是Centos/RedHat 6 64Bit 系统:
sudo yum install glibc.i686 cd nicstat-1.95 ln -s .nicstat.Linux_i386 .nicstat.Linux_i386 ln -s nicstat.sh nicstat这样就可以用nicstat来执行命令了。
推荐大家将设置好的nicstat打包发送到github,以后使用的时候直接开包即用。
参考连接:
http://www.cyberciti.biz/hardware/linux-install-nicstat-command-to-print-network-statistics-for-nics/
http://blog.yufeng.info/archives/2518#more-2518
欢迎补充!