Created
June 5, 2014 09:19
-
-
Save germanramos/6c9ad745b4667f14620c to your computer and use it in GitHub Desktop.
Get number of connections of a process
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
#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