Handle parsing OpenBSD ps output properly to display sidekiq
infos on admin->monitoring->background
This commit is contained in:
parent
bcb0a554dd
commit
fd097fa9e1
|
|
@ -1,7 +1,7 @@
|
|||
class Admin::BackgroundJobsController < Admin::ApplicationController
|
||||
def show
|
||||
ps_output, _ = Gitlab::Popen.popen(%W(ps ww -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command))
|
||||
@sidekiq_processes = ps_output.split("\n").grep(/sidekiq/)
|
||||
@sidekiq_processes = ps_output.split("\n").grep(/sidekiq \d+\.\d+\.\d+/)
|
||||
@concurrency = Sidekiq.options[:concurrency]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ module SidekiqHelper
|
|||
(?<pid>\d+)\s+
|
||||
(?<cpu>[\d\.,]+)\s+
|
||||
(?<mem>[\d\.,]+)\s+
|
||||
(?<state>[DRSTWXZNLsl\+<]+)\s+
|
||||
(?<start>.+)\s+
|
||||
(?<command>sidekiq.*\])
|
||||
(?<state>[DIEKNRSTVWXZNLpsl\+<>\/\d]+)\s+
|
||||
(?<start>.+?)\s+
|
||||
(?<command>(?:ruby\d+:\s+)?sidekiq.*\].*)
|
||||
\z/x
|
||||
|
||||
def parse_sidekiq_ps(line)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Handle parsing OpenBSD ps output properly to display sidekiq infos on admin->monitoring->background
|
||||
merge_request: 10303
|
||||
author: Sebastian Reitenbach
|
||||
|
|
@ -53,6 +53,14 @@ describe SidekiqHelper do
|
|||
expect(parts).to eq(['17725', '1.0', '12.1', 'Ssl', '19:20:15', 'sidekiq 4.2.1 gitlab-rails [0 of 25 busy]'])
|
||||
end
|
||||
|
||||
it 'parses OpenBSD output' do
|
||||
# OpenBSD 6.1
|
||||
line = '49258 0.5 2.3 R/0 Fri10PM ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'
|
||||
parts = helper.parse_sidekiq_ps(line)
|
||||
|
||||
expect(parts).to eq(['49258', '0.5', '2.3', 'R/0', 'Fri10PM', 'ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'])
|
||||
end
|
||||
|
||||
it 'does fail gracefully on line not matching the format' do
|
||||
line = '55137 10.0 2.1 S+ 2:30pm something'
|
||||
parts = helper.parse_sidekiq_ps(line)
|
||||
|
|
|
|||
Loading…
Reference in New Issue