Last active
August 29, 2015 14:25
-
-
Save pvdb/295a687285b7ed04a726 to your computer and use it in GitHub Desktop.
Get the number of TCP connections owned by current Ruby 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
# | |
# This first version should work on Mac OS X and Linux, but it spawns a process | |
# | |
# the number of TCP connections owned by the process. | |
def Process.tcp_count() `lsof -l -n -P -p #{Process.pid} -a -i tcp | egrep -v '^COMMAND' | wc -l`.chomp.to_i ; end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment