diff --git a/Changes.md b/Changes.md index e46be3a5d..99d8d5a7f 100644 --- a/Changes.md +++ b/Changes.md @@ -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 --------- diff --git a/lib/sidekiq/api.rb b/lib/sidekiq/api.rb index fbaf0cb06..05ab5f5b7 100644 --- a/lib/sidekiq/api.rb +++ b/lib/sidekiq/api.rb @@ -806,7 +806,7 @@ def each 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 @@ def size 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. diff --git a/lib/sidekiq/web/helpers.rb b/lib/sidekiq/web/helpers.rb index 71a279bcf..ef272abb4 100644 --- a/lib/sidekiq/web/helpers.rb +++ b/lib/sidekiq/web/helpers.rb @@ -22,6 +22,14 @@ def strings(lang) 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 @@ def format_memory(rss_kb) 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 diff --git a/web/assets/stylesheets/application.css b/web/assets/stylesheets/application.css index ceff1dbf3..b935e3699 100644 --- a/web/assets/stylesheets/application.css +++ b/web/assets/stylesheets/application.css @@ -186,7 +186,7 @@ form .btn { } form .btn-group .btn { - margin-right: 1px; + margin-right: 4px; } td form { diff --git a/web/views/busy.erb b/web/views/busy.erb index c1487cffa..2c2bc9057 100644 --- a/web/views/busy.erb +++ b/web/views/busy.erb @@ -1,8 +1,39 @@
-
+
+

<%= t('Status') %>

+
+
+ +
+
+
+

<%= s = processes.size; number_with_delimiter(s) %>

+

<%= t('Processes') %>

+
+
+

<%= x = processes.total_concurrency; number_with_delimiter(x) %>

+

<%= t('Threads') %>

+
+
+

<%= ws = workers.size; number_with_delimiter(ws) %>

+

<%= t('Busy') %>

+
+
+

<%= x == 0 ? 0 : ((ws / x.to_f) * 100).round(0) %>%

+

<%= t('Utilization') %>

+
+
+

<%= format_memory(processes.total_rss) %>

+

<%= t('RSS') %>

+
+
+
+ +
+

<%= t('Processes') %>

-
+
<%= csrf_tag %>
@@ -12,15 +43,14 @@
-
- - - + + + <% lead = processes.leader %> @@ -47,16 +77,14 @@ <% end %>
<%= t('Name') %> <%= t('Started') %><%= t('RSS') %>?<%= t('Threads') %><%= t('Busy') %><%= t('RSS') %>?<%= t('Threads') %><%= t('Busy') %>  
<%= process['concurrency'] %> <%= process['busy'] %> -
-
+ +
<%= csrf_tag %> - <% unless process.stopping? %> - - <% end %> + <% unless process.stopping? %><% end %> - -
+
+