本来想写一篇关于nicstat的文章,霸爷已经写的非常好了参考这里nicstat 网络流量统计利器
这里说明一下使用nicstat 可以完美替代iptraf ,nload 等工具
同样可以替代watch –命令行模式:
eg:
Every 1.0s: /sbin/ifconfig eth0 | grep bytes Wed Feb 27 22:20:58 2013 RX bytes:1851917520138 (1.6 TiB) TX bytes:41460941958 (38.6 GiB) -- Every 1.0s: /sbin/ifconfig eth0 | grep bytes Wed Feb 27 22:21:27 2013 RX bytes:1851921542828 (1.6 TiB) TX bytes:41461009539 (38.6 GiB)
[root@db-83 nicstat-1.92]# nicstat -help USAGE: nicstat [-hvnsxpztual] [-i int[,int...]] [-S int:mbps[,int:mbps...]] [interval [count]] -h # help -v # show version (1.92) -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 -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 [root@db-83 nicstat-1.92]# nicstat -a 22:14:24 InKB OutKB InSeg OutSeg Reset AttF %ReTX InConn OutCon Drops TCP 0.00 0.00 125.7 57.71 0.01 0.01 0.000 0.15 0.01 0.00 22:14:24 InDG OutDG InErr OutErr UDP 0.00 0.00 0.00 0.00 22:14:24 RdKB WrKB RdPkt WrPkt IErr OErr Coll NoCP Defer %Util lo 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.00 0.00 0.00 eth0 185.3 4.15 127.4 57.70 0.00 0.00 0.00 0.00 0.00 0.16 [root@db-83 nicstat-1.92]# nicstat -i eth0 5 4 Time Int rKB/s wKB/s rPk/s wPk/s rAvs wAvs %Util Sat 22:14:31 eth0 185.3 4.15 127.4 57.70 1488.9 73.62 0.16 0.00 22:14:36 eth0 0.32 0.29 3.00 2.40 109.5 125.3 0.00 0.00 22:14:41 eth0 0.23 0.05 3.60 0.40 66.67 136.0 0.00 0.00 22:14:46 eth0 494.6 5.77 337.8 78.99 1499.6 74.83 0.41 0.00 [root@db-83 nicstat-1.92]# nicstat -v nicstat version 1.92 Time Int rKB/s wKB/s rPk/s wPk/s rAvs wAvs %Util Sat 22:15:50 lo 0.00 0.00 0.01 0.01 50.00 50.00 0.00 0.00 22:15:50 eth0 185.3 4.15 127.4 57.70 1488.9 73.62 0.16 0.00
NOTES:
– Some unusual network cards may not provide all the details to Kstat,(or provide different symbols). Check for newer versions of this program, and the @Network array in the code below.
– Utilisation is based on bytes transferred divided by speed of the interface (if the speed is known). It should be impossible to reach 100% as there are overheads due to bus negotiation and timing.
– Loopback interfaces may only provide packet counts (if anything), and so bytes and %util will always be zero. Newer versions of Solaris (newer than Solaris 10 6/06) may provide loopback byte stats.
– Saturation is determined by counting read and write errors caused by the interface running at saturation. This approach is not ideal, and the value reported is often lower than it should be (eg, 0.0). Reading the rKB/s and wKB/s fields may be more useful.