summaryrefslogtreecommitdiff
path: root/app/helpers/sidekiq_helper.rb
blob: 37650ca642b586c99b689dcbbd3432c858d3de95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module SidekiqHelper
  SIDEKIQ_PS_REGEXP = /\A([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+(.+)\s+(sidekiq.*\])\s+\z/

  SIDEKIQ_PS_REGEXP = /\A
  (?<pid>\d+)\s+
  (?<cpu>[\d\.,]+)\s+
  (?<mem>[\d\.,]+)\s+
  (?<state>[DRSTWXZNLsl\+<]+)\s+
  (?<start>.+)\s+
  (?<command>sidekiq.*\])\s+
  \z/x

  def parse_sidekiq_ps(line)
    match = line.match(SIDEKIQ_PS_REGEXP)
    if match
      match[1..6]
    else
      %w[? ? ? ? ? ?]
    end
  end
end