Network Statistics
"Netstat -s -P tcp" provides you with detail summary of the Tcp statistics. See below
$ netstat -s -P tcp
TCP tcpRtoAlgorithm = 4 tcpRtoMin = 400
tcpRtoMax = 60000 tcpMaxConn = -1
tcpActiveOpens = 105 tcpPassiveOpens = 6929
tcpAttemptFails = 9 tcpEstabResets = 24
tcpCurrEstab = 10 tcpOutSegs =14831657
tcpOutDataSegs =14504882 tcpOutDataBytes =1579349845
tcpRetransSegs = 398 tcpRetransBytes =116003
tcpOutAck =326541 tcpOutAckDelayed =204020
tcpOutUrg = 0 tcpOutWinUpdate = 0
tcpOutWinProbe = 0 tcpOutControl = 14170
tcpOutRsts = 14 tcpOutFastRetrans = 14
tcpInSegs =14736303
tcpInAckSegs =14290274 tcpInAckBytes =1579351049
tcpInDupAck = 10033 tcpInAckUnsent = 0
tcpInInorderSegs =14467627 tcpInInorderBytes =681280146
tcpInUnorderSegs = 60 tcpInUnorderBytes = 3120
tcpInDupSegs = 62 tcpInDupBytes = 2184
tcpInPartDupSegs = 0 tcpInPartDupBytes = 0
tcpInPastWinSegs = 0 tcpInPastWinBytes = 0
tcpInWinProbe = 0 tcpInWinUpdate = 0
tcpInClosed = 0 tcpRttNoUpdate = 103
tcpRttUpdate =14283487 tcpTimRetrans = 300
tcpTimRetransDrop = 12 tcpTimKeepalive = 9353
tcpTimKeepaliveProbe= 2967 tcpTimKeepaliveDrop = 0
tcpListenDrop = 0 tcpListenDropQ0 = 0
tcpHalfOpenDrop = 0 tcpOutSackRetrans = 49
It is possible to timestamp each of these network metrics. If you collect them over a period of time, you can plot it with Gnuplot and study the trend of these TCP parameters.
This script should be able to do this job as a normal user and it will append timestamp and metrics to individual parameter files. So all you have to do is to loop through the script with a while loop. I will leave this to the reader as an exercise.
$ls
net.sh
$ cat net.sh
#! /bin/sh
timestamp=`date '+%Y%m%d%H%M%S'`
netstat -s -P tcp | \
sed -e 's/=/ /g' -e 's/TCP//' | \
nawk -v ts=$timestamp '
NF==2 {
cmd=sprintf("echo %s %s >> %s",ts,$2,$1)
system(cmd)
}
NF==4 {
cmd=sprintf("echo %s %s >> %s",ts,$2,$1)
system(cmd)
cmd=sprintf("echo %s %s >> %s",ts,$4,$3)
system(cmd)
}'
$ ls
net.sh tcpInDupBytes tcpInWinUpdate tcpOutSackRetrans tcpRttNoUpdate
tcpActiveOpens tcpInDupSegs tcpListenDrop tcpOutSegs tcpRttUpdate
tcpAttemptFails tcpInInorderBytes tcpListenDropQ0 tcpOutUrg tcpTimKeepalive
tcpCurrEstab tcpInInorderSegs tcpMaxConn tcpOutWinProbe tcpTimKeepaliveDrop
tcpEstabResets tcpInPartDupBytes tcpOutAck tcpOutWinUpdate tcpTimKeepaliveProbe
tcpHalfOpenDrop tcpInPartDupSegs tcpOutAckDelayed tcpPassiveOpens tcpTimRetrans
tcpInAckBytes tcpInPastWinBytes tcpOutControl tcpRetransBytes tcpTimRetransDrop
tcpInAckSegs tcpInPastWinSegs tcpOutDataBytes tcpRetransSegs
tcpInAckUnsent tcpInUnorderBytes tcpOutDataSegs tcpRtoAlgorithm
tcpInClosed tcpInUnorderSegs tcpOutFastRetrans tcpRtoMax
tcpInDupAck tcpInWinProbe tcpOutRsts tcpRtoMin
$ more tcpActiveOpens
20070712081804 29


0 Comments:
Post a Comment
<< Home