2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-06 15:40:49 -04:00
|
|
|
module SidekiqHelper
|
2018-01-27 00:35:53 -05:00
|
|
|
SIDEKIQ_PS_REGEXP = %r{\A
|
2016-09-08 13:41:25 -04:00
|
|
|
(?<pid>\d+)\s+
|
|
|
|
(?<cpu>[\d\.,]+)\s+
|
|
|
|
(?<mem>[\d\.,]+)\s+
|
2018-01-27 00:35:53 -05:00
|
|
|
(?<state>[DIEKNRSTVWXZNLpsl\+<>/\d]+)\s+
|
2017-03-28 17:29:49 -04:00
|
|
|
(?<start>.+?)\s+
|
|
|
|
(?<command>(?:ruby\d+:\s+)?sidekiq.*\].*)
|
2018-01-27 00:35:53 -05:00
|
|
|
\z}x
|
2016-09-08 09:30:16 -04:00
|
|
|
|
2016-09-06 15:40:49 -04:00
|
|
|
def parse_sidekiq_ps(line)
|
2016-11-22 05:31:01 -05:00
|
|
|
match = line.strip.match(SIDEKIQ_PS_REGEXP)
|
|
|
|
match ? match[1..6] : Array.new(6, '?')
|
2016-09-06 15:40:49 -04:00
|
|
|
end
|
|
|
|
end
|