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,19 +38,31 @@ module Sidekiq
|
||||||
helpers do
|
helpers do
|
||||||
def workers
|
def workers
|
||||||
@workers ||= begin
|
@workers ||= begin
|
||||||
Sidekiq.redis.smembers('workers').map do |w|
|
Sidekiq.redis.with_connection do |conn|
|
||||||
msg = Sidekiq.redis.get("worker:#{w}")
|
conn.smembers('workers').map do |w|
|
||||||
|
msg = conn.get("worker:#{w}")
|
||||||
msg = MultiJson.decode(msg) if msg
|
msg = MultiJson.decode(msg) if msg
|
||||||
[w, msg]
|
[w, msg]
|
||||||
end.sort { |x| x[1] ? -1 : 1 }
|
end.sort { |x| x[1] ? -1 : 1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def processed
|
||||||
|
Sidekiq.redis.get('stat:processed') || 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def failed
|
||||||
|
Sidekiq.redis.get('stat:failed') || 0
|
||||||
|
end
|
||||||
|
|
||||||
def queues
|
def queues
|
||||||
Sidekiq.redis.smembers('queues').map do |q|
|
Sidekiq.redis.with_connection do |conn|
|
||||||
[q, Sidekiq.redis.llen("queue:#{q}") || 0]
|
conn.smembers('queues').map do |q|
|
||||||
|
[q, conn.llen("queue:#{q}") || 0]
|
||||||
end.sort { |x,y| x[1] <=> y[1] }
|
end.sort { |x,y| x[1] <=> y[1] }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def location
|
def location
|
||||||
Sidekiq.redis.client.location
|
Sidekiq.redis.client.location
|
||||||
|
|
|
@ -1,26 +1,18 @@
|
||||||
|
|
||||||
.hero-unit
|
.hero-unit
|
||||||
h1 Sidekiq is #{status}
|
h1 Sidekiq is #{status}
|
||||||
|
p Processed: #{processed}
|
||||||
|
p Failed: #{failed}
|
||||||
|
p Workers: #{workers.size}
|
||||||
|
|
||||||
.tabbable
|
.tabbable
|
||||||
ul.nav.nav-tabs
|
ul.nav.nav-tabs
|
||||||
li.active
|
li.active
|
||||||
a href="#queues" data-toggle="tab" Queues
|
|
||||||
li
|
|
||||||
a href="#workers" data-toggle="tab" Workers
|
a href="#workers" data-toggle="tab" Workers
|
||||||
|
li
|
||||||
|
a href="#queues" data-toggle="tab" Queues
|
||||||
.tab-content
|
.tab-content
|
||||||
#queues.tab-pane.active
|
#workers.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
|
|
||||||
table class="table table-striped table-bordered"
|
table class="table table-striped table-bordered"
|
||||||
tr
|
tr
|
||||||
th Worker
|
th Worker
|
||||||
|
@ -36,3 +28,15 @@
|
||||||
td= msg['payload']['args'].inspect[0..100]
|
td= msg['payload']['args'].inspect[0..100]
|
||||||
- else
|
- else
|
||||||
td colspan=3 Idle
|
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