mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Add global stats, optimize redis usage
This commit is contained in:
parent
8345a196c0
commit
1d716a9c5c
2 changed files with 38 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue