Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gaols/7813bfd015e8abac4db4e05c1745630c to your computer and use it in GitHub Desktop.
Save gaols/7813bfd015e8abac4db4e05c1745630c to your computer and use it in GitHub Desktop.
list/count open connections (sockets) for All/certain process
# 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