Process Information (Rails app)
I found it very useful to see my application process info on an admin page, as following:
You can do it inside your Rails app.
Inside your controller/admincontroller.rb_:
def index
@processes = `ps -g #{Process.getsid($$)} -o pid,wchan,%cpu,%mem,rss,vsz,command`.strip.split("\n")
@proc_headers = @processes.shift.split(/\s+/)
@processes.map! { |line| line.strip.split(/\s+/, @proc_headers.size) }.
reject! { |line| line.last.start_with?('ps -g') }
end
and add the following to your view/admin/index.html.erb
<table>
<thead>
<tr>
<% @proc_headers.each do |th| %>
<th><%= th %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @processes.each do |line| %>
<tr>
<% line.each do |td| %>
<td><%= td %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
I would like to thank @romanbsd for this source.
Written by David Paluy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#