2009年10月13日 星期二

即時網路流量

Linux


從 /proc/net/dev 去截取資料來運算。


[root@ip069 ~]# cat /proc/net/dev


Inter-| Receive | Transmit


face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed


lo:55684135 25897 0 0 0 0 0 0 55684135 25897 0 0 0 0 0 0


eth0:1439346272 9461893 0 0 82 0 0 0 904668828 3744265 0 0 0 0 0 0


eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0


sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0


virbr0: 0 0 0 0 0 0 0 0 9208 42 0 0 0 0 0 0


FreeBSD 監看即時流量可用以下指令:


# netstat -ibd -I bce0 1


input (bce0) output


packets errs bytes packets errs bytes colls drops


9 0 894 3 0 1486 0 0


11 0 942 2 0 388 0 0


5 0 879 2 0 356 0 0