1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Add process/thread count summary to Busy page (#4806)

* Add process/thread count summary to Busy page

* pr

* Move Busy status numbers to stats tiles

* style nazi

* Add RSS stat box
This commit is contained in:
Mike Perham 2021-02-18 16:28:44 -08:00 committed by GitHub
parent 97350a459b
commit f0ddebc740
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 16 deletions

View file

@ -29,6 +29,7 @@ If this is a bare Rack app, use a session middleware before Sidekiq::Web:
use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
run Sidekiq::Web
```
- Add process/thread count summary to Busy page [#4806]
6.1.3
---------

View file

@ -806,7 +806,7 @@ module Sidekiq
yield Process.new(hash.merge("busy" => busy.to_i,
"beat" => at_s.to_f,
"quiet" => quiet,
"rss" => rss))
"rss" => rss.to_i))
end
end
@ -818,6 +818,17 @@ module Sidekiq
Sidekiq.redis { |conn| conn.scard("processes") }
end
# Total number of threads available to execute jobs.
# For Sidekiq Enterprise customers this number (in production) must be
# less than or equal to your licensed concurrency.
def total_concurrency
sum { |x| x["concurrency"] }
end
def total_rss
sum { |x| x["rss"] || 0 }
end
# Returns the identity of the current cluster leader or "" if no leader.
# This is a Sidekiq Enterprise feature, will always return "" in Sidekiq
# or Sidekiq Pro.

View file

@ -22,6 +22,14 @@ module Sidekiq
end
end
def singularize(str, count)
if count == 1 && str.respond_to?(:singularize) # rails
str.singularize
else
str
end
end
def clear_caches
@strings = nil
@locale_files = nil
@ -263,8 +271,10 @@ module Sidekiq
if rss_kb < 100_000
"#{number_with_delimiter(rss_kb)} KB"
else
elsif rss_kb < 10_000_000
"#{number_with_delimiter((rss_kb / 1024.0).to_i)} MB"
else
"#{number_with_delimiter((rss_kb / (1024.0 * 1024.0)).round(1))} GB"
end
end

View file

@ -186,7 +186,7 @@ form .btn {
}
form .btn-group .btn {
margin-right: 1px;
margin-right: 4px;
}
td form {

View file

@ -1,8 +1,39 @@
<div class="row header">
<div class="col-sm-8 pull-left flip">
<div class="col-sm-4 pull-left flip">
<h3><%= t('Status') %></h3>
</div>
</div>
<div class="table_container">
<div class="stats-container">
<div class="stat">
<h3><%= s = processes.size; number_with_delimiter(s) %></h3>
<p><%= t('Processes') %></p>
</div>
<div class="stat">
<h3><%= x = processes.total_concurrency; number_with_delimiter(x) %></h3>
<p><%= t('Threads') %></p>
</div>
<div class="stat">
<h3><%= ws = workers.size; number_with_delimiter(ws) %></h3>
<p><%= t('Busy') %></p>
</div>
<div class="stat">
<h3><%= x == 0 ? 0 : ((ws / x.to_f) * 100).round(0) %>%</h3>
<p><%= t('Utilization') %></p>
</div>
<div class="stat">
<h3><%= format_memory(processes.total_rss) %></h3>
<p><%= t('RSS') %></p>
</div>
</div>
</div>
<div class="row header">
<div class="col-sm-4 pull-left flip">
<h3><%= t('Processes') %></h3>
</div>
<div class="col-sm-4 pull-right flip">
<div class="col-sm-3 pull-right flip">
<form method="POST" class="warning-messages">
<%= csrf_tag %>
<div class="btn-group pull-right flip">
@ -12,15 +43,14 @@
</form>
</div>
</div>
<div class="table_container">
<table class="processes table table-hover table-bordered table-striped">
<thead>
<th><%= t('Name') %></th>
<th><%= t('Started') %></th>
<th><%= t('RSS') %><a href="https://github.com/mperham/sidekiq/wiki/Memory#rss"><span class="info-circle" title="Click to learn more about RSS">?</span></a></th>
<th><%= t('Threads') %></th>
<th><%= t('Busy') %></th>
<th class="col-sm-1"><%= t('RSS') %><a href="https://github.com/mperham/sidekiq/wiki/Memory#rss"><span class="info-circle" title="Click to learn more about RSS">?</span></a></th>
<th class="col-sm-1"><%= t('Threads') %></th>
<th class="col-sm-1"><%= t('Busy') %></th>
<th>&nbsp;</th>
</thead>
<% lead = processes.leader %>
@ -47,16 +77,14 @@
<td><%= process['concurrency'] %></td>
<td><%= process['busy'] %></td>
<td>
<div class="btn-group pull-right flip">
<form method="POST">
<form method="POST">
<div class="btn-group pull-right flip">
<%= csrf_tag %>
<input type="hidden" name="identity" value="<%= process['identity'] %>"/>
<% unless process.stopping? %>
<button class="btn btn-warn" type="submit" name="quiet" value="1"><%= t('Quiet') %></button>
<% end %>
<% unless process.stopping? %><button class="btn btn-warn" type="submit" name="quiet" value="1"><%= t('Quiet') %></button><% end %>
<button class="btn btn-danger" type="submit" name="stop" value="1"><%= t('Stop') %></button>
</form>
</div>
</div>
</form>
</td>
</tr>
<% end %>