Last active
January 26, 2017 20:41
-
-
Save pwielgolaski/cd655afa50d9688ccecffa08730b22cd to your computer and use it in GitHub Desktop.
connection start per pid
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
netstat -tap --numeric-port 2>/dev/null |\ | |
awk 'NR >2 { print $6,$4,$5,substr($7,0,index($7, "/")-1);}' |\ | |
sort -ru |\ | |
awk -v pids="$1" 'BEGIN {OFS=","} { port=substr($2,index($2,":")+1) } pids !~ $4 {next} /LISTEN/ { listen[port]=1; $1="LIS"; print $0; next} { (port in listen)?$1="IN":$1="OUT"; print $0 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment