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