Skip to content

Commit

Permalink
Add processes to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelga committed Jan 16, 2015
1 parent cf77959 commit 94fa624
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/sidekiq/web.rb
Expand Up @@ -50,7 +50,7 @@ def custom_tabs
p.quiet! if params[:quiet]
p.stop! if params[:stop]
else
Sidekiq::ProcessSet.new.each do |pro|
processes.each do |pro|
pro.quiet! if params[:quiet]
pro.stop! if params[:stop]
end
Expand Down Expand Up @@ -219,6 +219,7 @@ def custom_tabs
processed: sidekiq_stats.processed,
failed: sidekiq_stats.failed,
busy: workers_size,
processes: processes_size,
enqueued: sidekiq_stats.enqueued,
scheduled: sidekiq_stats.scheduled_size,
retries: sidekiq_stats.retry_size,
Expand Down
8 changes: 8 additions & 0 deletions lib/sidekiq/web_helpers.rb
Expand Up @@ -46,6 +46,14 @@ def workers
@workers ||= Sidekiq::Workers.new
end

def processes_size
@processes_size ||= processes.size
end

def processes
@processes ||= Sidekiq::ProcessSet.new
end

def stats
@stats ||= Sidekiq::Stats.new
end
Expand Down
6 changes: 5 additions & 1 deletion test/test_web.rb
Expand Up @@ -404,6 +404,10 @@ def perform(a, b)
assert_equal 4, @response["sidekiq"]["busy"]
end

it 'reports processes' do
assert_equal 1, @response["sidekiq"]["processes"]
end

it 'reports retries' do
assert_equal 2, @response["sidekiq"]["retries"]
end
Expand Down Expand Up @@ -568,7 +572,7 @@ def add_worker
Sidekiq.redis do |conn|
conn.multi do
conn.sadd("processes", key)
conn.hmset(key, 'busy', 4)
conn.hmset(key, 'info', Sidekiq.dump_json('hostname' => 'foo', 'started_at' => Time.now.to_f, "queues" => []), 'at', Time.now.to_f, 'busy', 4)
conn.hmset("#{key}:workers", Time.now.to_f, msg)
end
end
Expand Down
2 changes: 1 addition & 1 deletion web/views/busy.erb
Expand Up @@ -21,7 +21,7 @@
<th><%= t('Busy') %></th>
<th>&nbsp;</th>
</thead>
<% Sidekiq::ProcessSet.new.each do |process| %>
<% processes.each do |process| %>
<tr>
<td width="50%">
<%= "#{process['hostname']}:#{process['pid']}" %>
Expand Down

0 comments on commit 94fa624

Please sign in to comment.