Created
April 10, 2015 11:07
-
-
Save dotwaffle/bdeaec323f0815958eff to your computer and use it in GitHub Desktop.
List all the TCP connections on a box, and get the TCP_INFO for analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ss -tine \ | |
| tr '\t' ' ' \ | |
| sed \ | |
-e ': # first line is for humans' \ | |
-e '1d' \ | |
-e ': # remove the skbuf stuff' \ | |
-e 's/sk:ffff[0-9a-fA-F]\+//g' \ | |
-e ': # remove the ino stuff' \ | |
-e 's/\s\+ino:[0-9]\+//g' \ | |
-e ': # join the next two lines together' \ | |
-e 'N;s/\n/ /g' \ | |
-e ': # move the timer to the end (neater)' \ | |
-re 's/(timer:[^ ]+)(.*)/\2 \1/g' \ | |
-e ': # move the uid to the end (neater)' \ | |
-e 's/(uid:[0-9]+)(.*)/\2 \1/g' \ | |
-e ': # remove all space after the IP/ports' \ | |
-e 's/\s+cubic/\tcubic/g' \ | |
-e ': # send does not have a colon, annoying!' \ | |
-e 's/send /send:/g' \ | |
-e ': # remove the annoying <->' \ | |
-e 's/<->//g' \ | |
| sort -rnk3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment