Created
October 12, 2017 09:24
-
-
Save tgxworld/e049b469f17af9d8d418be6cdcf33280 to your computer and use it in GitHub Desktop.
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
sum = 0 | |
processes = [] | |
Dir["/proc/*/fd"].each do |dir| | |
if dir =~ /proc\/(\d+)\/fd/ | |
count = Dir[dir + '/*'].count | |
sum += count | |
if count > 400 | |
pid_info = `ps -p #{Regexp.last_match[1]} -o args=`.chomp | |
processes << [pid_info, count] | |
end | |
end | |
end | |
processes.sort_by { |_, count| count }.each do |pid_info, count| | |
puts "#{pid_info} || #{count}" | |
end | |
puts "Total Allocated FDs: #{sum}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment