Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get number of connections of a process
#Option 1: lsof
sudo lsof -n -i | grep 23889 | wc -l
#Option 2: python + psutil
>sudo python
import psutil
len(psutil.Process(23889).get_connections(kind='inet'))
where 23889 is the PID of the process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment