Class: Sidekiq::Monitor::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/monitor.rb

Defined Under Namespace

Classes: QUEUE_STRUCT

Constant Summary collapse

VALID_SECTIONS =
%w[all version overview processes queues]
COL_PAD =
2

Instance Method Summary collapse

Instance Method Details

#allObject



38
39
40
41
42
43
44
45
46
# File 'lib/sidekiq/monitor.rb', line 38

def all
  version
  puts
  overview
  puts
  processes
  puts
  queues
end

#display(section = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sidekiq/monitor.rb', line 26

def display(section = nil)
  section ||= "all"
  unless VALID_SECTIONS.include? section
    puts "I don't know how to check the status of '#{section}'!"
    puts "Try one of these: #{VALID_SECTIONS.join(", ")}"
    return
  end
  send(section)
rescue => e
  puts "Couldn't get status: #{e}"
end

#overviewObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/sidekiq/monitor.rb', line 53

def overview
  puts "---- Overview ----"
  puts "  Processed: #{delimit stats.processed}"
  puts "     Failed: #{delimit stats.failed}"
  puts "       Busy: #{delimit stats.workers_size}"
  puts "   Enqueued: #{delimit stats.enqueued}"
  puts "    Retries: #{delimit stats.retry_size}"
  puts "  Scheduled: #{delimit stats.scheduled_size}"
  puts "       Dead: #{delimit stats.dead_size}"
end

#processesObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/sidekiq/monitor.rb', line 64

def processes
  puts "---- Processes (#{process_set.size}) ----"
  process_set.each_with_index do |process, index|
    puts "#{process["identity"]} #{tags_for(process)}"
    puts "  Started: #{Time.at(process["started_at"])} (#{time_ago(process["started_at"])})"
    puts "  Threads: #{process["concurrency"]} (#{process["busy"]} busy)"
    puts "   Queues: #{split_multiline(process["queues"].sort, pad: 11)}"
    puts "" unless (index + 1) == process_set.size
  end
end

#queuesObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/sidekiq/monitor.rb', line 75

def queues
  puts "---- Queues (#{queue_data.size}) ----"
  columns = {
    name: [:ljust, (["name"] + queue_data.map(&:name)).map(&:length).max + COL_PAD],
    size: [:rjust, (["size"] + queue_data.map(&:size)).map(&:length).max + COL_PAD],
    latency: [:rjust, (["latency"] + queue_data.map(&:latency)).map(&:length).max + COL_PAD],
  }
  columns.each { |col, (dir, width)| print col.to_s.upcase.public_send(dir, width) }
  puts
  queue_data.each do |q|
    columns.each do |col, (dir, width)|
      print q.send(col).public_send(dir, width)
    end
    puts
  end
end

#versionObject



48
49
50
51
# File 'lib/sidekiq/monitor.rb', line 48

def version
  puts "Sidekiq #{Sidekiq::VERSION}"
  puts Time.now.utc
end