Skip to content

Instantly share code, notes, and snippets.

@kazeburo
Created January 16, 2020 08:22
Show Gist options
  • Save kazeburo/833aad285a791c095085c0fb68f1d234 to your computer and use it in GitHub Desktop.
Save kazeburo/833aad285a791c095085c0fb68f1d234 to your computer and use it in GitHub Desktop.
#!perl
use strict;
my %stats;
{
open my $fh, '<', '/proc/net/snmp' or die "$!\n";
my @keys;
while (<$fh>) {
chomp;
if (/^Tcp\:/ && ! @keys) {
@keys = split / /;
} elsif ( /^Tcp\:/ ) {
for my $v (split / /) {
$stats{shift @keys} = $v;
}
}
}
}
{
open my $fh, '<', '/proc/net/netstat' or die "$!\n";
my @keys;
while (<$fh>) {
chomp;
if (/^TcpExt\:/ && ! @keys) {
@keys = split / /;
} elsif ( /^TcpExt\:/ ) {
for my $v (split / /) {
$stats{shift @keys} = $v;
}
}
}
}
my @stats;
for my $k (keys %stats) {
push @stats, "$k:$stats{$k}";
}
print join($ARGV[0] eq "-l" ? "\n" : "\t", @stats),"\n";
@kazeburo
Copy link
Author

$ ./netsv
TCPLossUndo:1046 TCPLossProbes:2885818 TCPFullUndo:1150 TCPSackRecoveryFail:1 AttemptFails:294 TCPDSACKRecv:52743 TCPSackRecovery:14628 ActiveOpens:1755174932TCPHPHitsToUser:0 TCPACKSkippedPAWS:0 TCPACKSkippedFinWait2:0 TCPOFODrop:0 TCPTimeWaitOverflow:119947386 TCPRenoFailures:0 TCPPrequeued:0 ListenOverflows:5028 TCPRenoRecovery:0 DelayedACKLocked:17696 TCPOrigDataSent:22753561345 TCPSACKReneging:0 TCPAbortOnData:574219 LockDroppedIcmps:0 TWKilled:0 TCPFACKReorder:1604 TCPDSACKOldSent:190519 PAWSActive:0 TCPSlowStartRetrans:5 TCPMD5NotFound:0 TCPMemoryPressures:0 PAWSPassive:0 TCPDSACKUndo:2201 Tcp::Tcp: TCPWantZeroWindowAdv:93 TCPRcvCoalesce:2029786619 TCPAbortOnClose:216 SyncookiesSent:0 TCPTSReorder:1003 TCPChallengeACK:92 TCPFromZeroWindowAdv:36 TCPFastOpenPassiveFail:0 TCPDirectCopyFromBacklog:0 TCPFastOpenPassive:0 TCPAbortOnMemory:0 ListenDrops:5028 TCPLostRetransmit:0 OutRsts:1899805 TCPSYNChallenge:6 TCPFastOpenActiveFail:0 TCPMinTTLDrop:0
TCPAbortFailed:0 TCPSpuriousRTOs:1 TCPHystartTrainDetect:1735688 TCPDSACKIgnoredNoUndo:36514 DelayedACKLost:190232 TCPSchedulerFailed:0 InErrs:4 TCPBacklogDrop:0 TCPRenoRecoveryFail:0 TCPFastOpenListenOverflow:0 TCPReqQFullDrop:0 TCPLossProbeRecovery:33076 SyncookiesFailed:2 TCPSackMerged:9344 TCPMD5Unexpected:0 PAWSEstab:11 TCPACKSkippedChallenge:0 SyncookiesRecv:0 TCPFastOpenActive:0 BusyPollRxPackets:0 TCPOFOMerge:2 ArpFilter:0 TCPHPHits:9670031359 PFMemallocDrop:0 TCPAutoCorking:16446127 TCPACKSkippedTimeWait:0 RcvPruned:0 IPReversePathFilter:0 TCPRcvCollapsed:0 TCPHystartDelayDetect:628 TWRecycled:192942137 OutOfWindowIcmps:0 TCPDSACKOfoSent:2 TCPSACKDiscard:0 TCPFastRetrans:38608 TCPTimeouts:3169 TCPPartialUndo:1238 TCPDSACKIgnoredOld:1 TCPForwardRetrans:7187 TCPACKSkippedSeq:0 PassiveOpens:491601946 TCPPureAcks:2512205834 TCPSackShiftFallback:98134 OutSegs:38930320459 DelayedACKs:2082202661 TCPSpuriousRtxHostQueues:781 TCPSackShifted:6285 TCPSACKReorder:1604 TCPRetransFail:573 RetransSegs:2930822 InSegs:29932019523 TCPPrequeueDropped:0 OfoPruned:0 PruneCalled:0 TCPHystartDelayCwnd:15283 RtoMax:120000 TCPSynRetrans:4967 TcpExt::TcpExt: TCPToZeroWindowAdv:36 TCPAbortOnLinger:0 TCPRenoReorder:0 TCPLossFailures:0 EstabResets:16183 EmbryonicRsts:0
CurrEstab:2813 TCPAbortOnTimeout:1 TCPReqQFullDoCookies:0 TCPDeferAcceptDrop:459455974 TCPHPAcks:7651725087 InCsumErrors:0 TW:1230008929 TCPDirectCopyFromPrequeue:0 RtoAlgorithm:1 TCPOFOQueue:457862 TCPFastOpenCookieReqd:0 TCPDSACKOfoRecv:0 TCPSackFailures:10590 MaxConn:-1 TCPWqueueTooBig:0 TCPACKSkippedSynRecv:0 RtoMin:200 TCPHystartTrainCwnd:68019469

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment