Skip to content

Instantly share code, notes, and snippets.

@germanramos
Created June 5, 2014 09:19
Show Gist options
  • Save germanramos/6c9ad745b4667f14620c to your computer and use it in GitHub Desktop.
Save germanramos/6c9ad745b4667f14620c to your computer and use it in GitHub Desktop.
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