Commit 189194b3 authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Count git process count manually

parent 93d3e26e
Pipeline #23616 passed with stage
in 1 minute and 33 seconds
PATH PATH
remote: . remote: .
specs: specs:
gitlab-monitor (0.0.15) gitlab-monitor (0.0.16)
pg (~> 0.18.4) pg (~> 0.18.4)
quantile (~> 0.2.0) quantile (~> 0.2.0)
redis-namespace (~> 1.5.2) redis-namespace (~> 1.5.2)
......
...@@ -91,14 +91,19 @@ module GitLab ...@@ -91,14 +91,19 @@ module GitLab
end end
def probe_git # rubocop:disable Metrics/MethodLength def probe_git # rubocop:disable Metrics/MethodLength
counts = Hash.new(0)
Utils.pgrep("^git ").each do |pid| Utils.pgrep("^git ").each do |pid|
process_cmd = File.read("/proc/#{pid}/cmdline") process_cmd = File.read("/proc/#{pid}/cmdline")
subcommand = self.class.extract_subcommand(process_cmd) subcommand = self.class.extract_subcommand(process_cmd)
next unless subcommand # Unlikely, but just to be safe next unless subcommand # Unlikely, but just to be safe
name = "git #{subcommand}"
counts[name] += 1
prober = ProcessProber.new( prober = ProcessProber.new(
{ {
name: "git #{subcommand}", name: name,
pid_or_pattern: pid, pid_or_pattern: pid,
quantiles: @opts[:quantiles] quantiles: @opts[:quantiles]
}, },
...@@ -108,7 +113,10 @@ module GitLab ...@@ -108,7 +113,10 @@ module GitLab
prober prober
.probe_memory .probe_memory
.probe_age .probe_age
.probe_count end
counts.each do |name, count|
@metrics.add("process_count", count, name: name)
end end
self self
......
module GitLab module GitLab
module Monitor module Monitor
VERSION = "0.0.15".freeze VERSION = "0.0.16".freeze
end end
end end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment