通過/proc/net/dev分析網路包量,流量,錯包,丟包
一,/proc/net/dev
[email protected]:~> cat /proc/net/dev
Inter- | Receive | Transmit
face | bytes packets errs drop fifo frame compressed multicast | bytes packets errs drop fifo colls carrier compressed
eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth1: 67437819880 552776948 0 0 0 0 0 6 63179118041 486899714 0 0 0 0 0 0
lo: 2338316682 34154992 0 0 0 0 0 0 2338316682 34154992 0 0 0 0 0 0
tunl0: 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
ip6tnl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
最左邊的表示介面的名字,Receive表示收包,Transmit表示發包;
bytes表示收發的位元組數;
packets表示收發正確的包量;
errs表示收發錯誤的包量;
drop表示收發丟棄的包量;
二,/proc/net/snmp
[email protected]:~> cat /proc/net/snmp
Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
Ip: 2 64 583571152 0 0 0 0 0 583571152 520325247 0 0 0 0 0 0 0 0 0
Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 9859518 193 316 0 0 0 0 9859190 5 1 0 5 0 9859310 0 119 0 0 0 0 0 9859190 0 1 0 0
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts
Tcp: 1 200 120000 -1 42226398 41112433 0 407271 84 516490860 453242269 140892 0 1056150
Udp: InDatagrams NoPorts InErrors OutDatagrams
Udp: 57220606 116 0 57223663
通過訪問該檔案系統,可以對TCP和UDP進行監控:
平均每秒新增TCP連線數 |
通過/proc/net/snmp檔案得到最近240秒內PassiveOpens的增量,除以240得到每秒的平均增量 |
機器的TCP連線數 |
通過/proc/net/snmp檔案的CurrEstab得到TCP連線數 |
平均每秒的UDP接收資料報 |
通過/proc/net/snmp檔案得到最近240秒內InDatagrams的增量,除以240得到平均每秒的UDP接收資料報。 |
平均每秒的UDP傳送資料報 |
通過/proc/net/snmp檔案得到最近240秒內OutDatagrams的增量,除以240得到平均每秒的UDP傳送資料報。 |