Sha256: e462ce3094a0ca9ad7131616fbfad737f3f222bc3efc2790623b47eb98f59aef
Contents?: true
Size: 1.08 KB
Versions: 561
Compression:
Stored size: 1.08 KB
Contents
#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' require 'rbbt/workflow' require 'rbbt/monitor' $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands options = SOPT.setup <<EOF Find process with deleted open files $ rbbt system deleted_files -h--help Print this help EOF rbbt_usage and exit 0 if options[:help] pids = {} Dir.glob('/proc/*/fd/*').each do |file| pid = file.split('/')[-3] begin dest = File.readlink(file) rescue next end next if File.exist? dest pids[pid] ||= [] pids[pid] << dest end pids.sort_by{|p,files| files.length}.each do |pid,files| dirs = {} files.each do |f| name = File.basename(f) dir = File.basename(File.dirname(f)) next if dir =~ /^pts|\.$/ dirs[dir] ||= [] dirs[dir] << name end next if dirs.empty? puts Log.color :magenta, pid dirs.sort_by{|dir,list| list.length}.each do |dir,list| puts Misc.format_definition_list_item(dir, list.length.to_s) end end puts "Total: #{pids.values.collect{|k,v| v}.flatten.length}"
Version data entries
561 entries across 561 versions & 1 rubygems