diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-31 09:04:21 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-31 09:04:21 +0000 |
commit | a71e777bb722efdbe37b0f6bbd1a0aaef164a99f (patch) | |
tree | a6154e0cca5dd15c667f3191f20e24a8cc504c99 | |
parent | bcb0a554dd4f8754ab1d6a876edc1481e04aa711 (diff) | |
parent | fd097fa9e12a403d5f56d24b68df9a3ea5ace25c (diff) | |
download | gitlab-ce-a71e777bb722efdbe37b0f6bbd1a0aaef164a99f.tar.gz |
Merge branch 'fix_admin_monitoring_background' into 'master'
fix issue #30083 handle parsing OpenBSD ps output properly to display sidekiq
Closes #30083
See merge request !10303
-rw-r--r-- | app/controllers/admin/background_jobs_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/sidekiq_helper.rb | 6 | ||||
-rw-r--r-- | changelogs/unreleased/fix_admin_monitoring_background.yml | 4 | ||||
-rw-r--r-- | spec/helpers/sidekiq_helper_spec.rb | 8 |
4 files changed, 16 insertions, 4 deletions
diff --git a/app/controllers/admin/background_jobs_controller.rb b/app/controllers/admin/background_jobs_controller.rb index 87eb7ff4c93..5f90ad7137d 100644 --- a/app/controllers/admin/background_jobs_controller.rb +++ b/app/controllers/admin/background_jobs_controller.rb @@ -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 diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb index b5017080cfb..55f4da0ef85 100644 --- a/app/helpers/sidekiq_helper.rb +++ b/app/helpers/sidekiq_helper.rb @@ -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) diff --git a/changelogs/unreleased/fix_admin_monitoring_background.yml b/changelogs/unreleased/fix_admin_monitoring_background.yml new file mode 100644 index 00000000000..3a9a1c88672 --- /dev/null +++ b/changelogs/unreleased/fix_admin_monitoring_background.yml @@ -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 diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb index f86e496740a..117abc9c556 100644 --- a/spec/helpers/sidekiq_helper_spec.rb +++ b/spec/helpers/sidekiq_helper_spec.rb @@ -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) |