Created
June 20, 2012 17:31
-
-
Save Alfreddd/2961071 to your computer and use it in GitHub Desktop.
list/count open connections (sockets) for All/certain process
This file contains hidden or 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
# list open sockets for PID | |
sudo lsof -p 13264 | egrep 'TCP|UDP' | |
# count of sockets | |
sudo lsof -p 13264 | egrep "TCP|UDP" | wc -l | |
# list the open sockets for all passengers | |
passenger-status | grep PID | awk '{ print $3}' | xargs -i sudo lsof -p {} | egrep 'TCP|UDP' | |
# Alternative command | |
sudo netstat -anp --inet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to formulate a command line to give me the number of open sockets/files per process, that is, give me a list with a column with the process name and another column with the number of open sockets, can you help me with that.
ps ax | awk '{ print $1}' | xargs -i sudo lsof -p {} | egrep 'TCP|UDP'