Permalink
Browse files

Merge improved memory_stats.rb from 'external_app_pool' branch.

  • Loading branch information...
1 parent 5c03034 commit 8b205b5fc45fa886be33fd43de4123d8604a4fcf @FooBarWidget FooBarWidget committed Apr 19, 2008
Showing with 3 additions and 16 deletions.
  1. +3 −16 misc/memory_stats.rb
View
@@ -30,25 +30,12 @@ def print
end
def start
- some_private_dirty_rss_cannot_be_determined = false
processes = list_processes(:exe => PlatformInfo::HTTPD)
- some_private_dirty_rss_cannot_be_determined = processes.any? do |p|
- p.private_dirty_rss.nil?
- end
print_process_list_stats(processes)
puts
- processes = list_processes(:match => /^(Passenger|Rails) /)
- some_private_dirty_rss_cannot_be_determined ||= processes.any? do |p|
- p.private_dirty_rss.nil?
- end
+ processes = list_processes(:match => /(^Passenger |^Rails:|ApplicationPoolServerExecutable)/)
print_process_list_stats(processes)
-
- if ::Process.uid != 0 && some_private_dirty_rss_cannot_be_determined
- puts
- puts "*** WARNING: Please run this tool as root, otherwise it " <<
- "can't determine the private dirty RSS of processes."
- end
end
# Returns a list of Process objects that match the given search criteria.
@@ -98,13 +85,13 @@ def list_processes(options)
def determine_private_dirty_rss(pid)
total = 0
File.read("/proc/#{pid}/smaps").split("\n").each do |line|
- line =~ /^(Shared|Private)_Dirty: +(\d+)/
+ line =~ /^(Private)_Dirty: +(\d+)/
if $2
total += $2.to_i
end
end
return total
- rescue Errno::EACCES
+ rescue Errno::EACCES, Errno::ENOENT
return nil
end

0 comments on commit 8b205b5

Please sign in to comment.