Livejournal
Log in
Post
Friends
My journal
sa_chernomor
human readable /proc/net/netstat
Mar 21, 2011 17:20
cat /proc/net/netstat | \ awk '(f==0) {name=$1; i=2; while ( i<=NF) {n[i] = $i; i++ }; f=1; next} \ (f==1){ i=2; while ( i<=NF){ printf "%s%s = %d\n", name, n[i], $i; i++}; f=0} '
network
Leave a comment
Comments 5
anonymous
July 17 2013, 00:09:37 UTC
Unfortunately, this does not look quite right. The last items in each line are missing. Here is a better script.
cat /proc/net/netstat | \
awk '(f==0) { i=1; while ( i<=NF) {n[i] = $i; i++ }; f=1; next} \
(f==1){ i=2; while ( i<=NF){ printf "%s = %d\n", n[i], $i; i++}; f=0} '
Reply
sa_chernomor
July 17 2013, 19:06:56 UTC
Thanks a lot!
Reply
anonymous
April 9 2014, 04:17:26 UTC
Thanks a lot for your great script and for the corrected script!
As I mentioned, it can be used for reading /proc/net/snmp also
Reply
anonymous
May 10 2019, 13:45:50 UTC
Can anyone please explain these?
Reply
sa_chernomor
May 10 2019, 19:25:22 UTC
This script dump /proc/net/netstat like this:
TcpExt:SyncookiesSent = 0
TcpExt:SyncookiesRecv = 0
TcpExt:SyncookiesFailed = 0
TcpExt:EmbryonicRsts = 0
TcpExt:PruneCalled = 34841
TcpExt:RcvPruned = 0
TcpExt:OfoPruned = 0
TcpExt:OutOfWindowIcmps = 0
TcpExt:LockDroppedIcmps = 0
TcpExt:ArpFilter = 0
Reply
Leave a comment
Up
Comments 5
cat /proc/net/netstat | \
awk '(f==0) { i=1; while ( i<=NF) {n[i] = $i; i++ }; f=1; next} \
(f==1){ i=2; while ( i<=NF){ printf "%s = %d\n", n[i], $i; i++}; f=0} '
Reply
Reply
As I mentioned, it can be used for reading /proc/net/snmp also
Reply
Reply
TcpExt:SyncookiesSent = 0
TcpExt:SyncookiesRecv = 0
TcpExt:SyncookiesFailed = 0
TcpExt:EmbryonicRsts = 0
TcpExt:PruneCalled = 34841
TcpExt:RcvPruned = 0
TcpExt:OfoPruned = 0
TcpExt:OutOfWindowIcmps = 0
TcpExt:LockDroppedIcmps = 0
TcpExt:ArpFilter = 0
Reply
Leave a comment