diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index 2e72c9d7..c48a2040 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -38,18 +38,30 @@ module Sidekiq helpers do def workers @workers ||= begin - Sidekiq.redis.smembers('workers').map do |w| - msg = Sidekiq.redis.get("worker:#{w}") - msg = MultiJson.decode(msg) if msg - [w, msg] - end.sort { |x| x[1] ? -1 : 1 } + Sidekiq.redis.with_connection do |conn| + conn.smembers('workers').map do |w| + msg = conn.get("worker:#{w}") + msg = MultiJson.decode(msg) if msg + [w, msg] + end.sort { |x| x[1] ? -1 : 1 } + end end end + def processed + Sidekiq.redis.get('stat:processed') || 0 + end + + def failed + Sidekiq.redis.get('stat:failed') || 0 + end + def queues - Sidekiq.redis.smembers('queues').map do |q| - [q, Sidekiq.redis.llen("queue:#{q}") || 0] - end.sort { |x,y| x[1] <=> y[1] } + Sidekiq.redis.with_connection do |conn| + conn.smembers('queues').map do |q| + [q, conn.llen("queue:#{q}") || 0] + end.sort { |x,y| x[1] <=> y[1] } + end end def location diff --git a/web/views/index.slim b/web/views/index.slim index 3384f229..25a973ab 100644 --- a/web/views/index.slim +++ b/web/views/index.slim @@ -1,26 +1,18 @@ .hero-unit h1 Sidekiq is #{status} + p Processed: #{processed} + p Failed: #{failed} + p Workers: #{workers.size} .tabbable ul.nav.nav-tabs li.active - a href="#queues" data-toggle="tab" Queues - li a href="#workers" data-toggle="tab" Workers + li + a href="#queues" data-toggle="tab" Queues .tab-content - #queues.tab-pane.active - table class="table table-striped table-bordered" - tr - th Queue - th Size - - queues.each do |(queue, size)| - tr - td - a href="queues/#{queue}" #{queue} - td= size - - #workers.tab-pane + #workers.tab-pane.active table class="table table-striped table-bordered" tr th Worker @@ -36,3 +28,15 @@ td= msg['payload']['args'].inspect[0..100] - else td colspan=3 Idle + + #queues.tab-pane + table class="table table-striped table-bordered" + tr + th Queue + th Size + - queues.each do |(queue, size)| + tr + td + a href="queues/#{queue}" #{queue} + td= size +