lib/daemonizer/stats.rb in daemonizer-0.4.8 vs lib/daemonizer/stats.rb in daemonizer-0.4.9
- old
+ new
@@ -130,15 +130,37 @@
def to_a
return [pid, ppid, vm_size_in_mb, private_dirty_rss_in_mb, rss_in_mb, name]
end
end
- def print(pool_name)
+ attr_reader :pool
+
+ def initialize(pool)
+ @pool = pool
+ end
+
+ def find_all_processes
+ find_monitor + find_workers
+ end
+
+ def find_workers
+ self.list_processes(:match => /#{@pool.name} worker: instance \d{1,}/)
+ end
+
+ def find_monitor
+ self.list_processes(:match => /#{@pool.name} monitor/)
+ end
+
+ def print
puts
- pool_processes = list_processes(:match =>
- /(#{pool_name} worker: instance \d{1,}|#{pool_name} monitor)/)
- print_process_list("#{pool_name} processes", pool_processes, :show_ppid => false)
+ pool_processes = find_all_processes
+ if pool_processes.size == 0
+ puts "*** It seems like pool '#{@pool.name}' is not running"
+ return
+ end
+ puts
+ print_process_list("#{@pool.name} processes", pool_processes, :show_ppid => false)
if RUBY_PLATFORM !~ /linux/
puts
puts "*** WARNING: The private dirty RSS can only be displayed " <<
"on Linux. You're currently using '#{RUBY_PLATFORM}'."
@@ -146,11 +168,11 @@
puts
puts "*** WARNING: Please run this tool as root. Otherwise the " <<
"private dirty RSS of processes cannot be determined."
end
end
-
+
# Returns a list of Process objects that match the given search criteria.
#
# # Search by executable path.
# list_processes(:exe => '/usr/sbin/apache2')
#
@@ -222,9 +244,10 @@
end
return processes
end
private
+
def platform_provides_private_dirty_rss_information?
return RUBY_PLATFORM =~ /linux/
end
# Returns the private dirty RSS for the given process, in KB.