Class: GitLab::Exporter::CLI::Process
- Inherits:
-
Object
- Object
- GitLab::Exporter::CLI::Process
- Defined in:
- lib/gitlab_exporter/cli.rb
Overview
Process runner
Takes a pid and name for metrics
Constant Summary collapse
- COMMAND_NAME =
"process".freeze
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(args) ⇒ Process
constructor
A new instance of Process.
- #options(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Process
Returns a new instance of Process.
247 248 249 250 251 252 253 |
# File 'lib/gitlab_exporter/cli.rb', line 247 def initialize(args) @options = (args) @options.parse! @target = args.shift || STDOUT @target = File.open(@target, "a") if @target.is_a?(String) end |
Instance Method Details
#help ⇒ Object
273 274 275 |
# File 'lib/gitlab_exporter/cli.rb', line 273 def help @options.help end |
#options(args) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/gitlab_exporter/cli.rb', line 255 def (args) args. do |opts| opts. = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]" opts.on("--pid=123", "Process ID") do |val| @pid = val end opts.on("--pattern=worker", "Process command pattern") do |val| @pattern = val end opts.on("--name=NAME", "Process name to be used in metrics") do |val| @name = val end opts.on("--quantiles", "Return quantiles instead of exact metrics") do @quantiles = true end end end |
#run ⇒ Object
277 278 279 280 281 282 283 |
# File 'lib/gitlab_exporter/cli.rb', line 277 def run ::GitLab::Exporter::ProcessProber.new(pid_or_pattern: @pid || @pattern, name: @name, quantiles: @quantiles) .probe_stat .probe_count .probe_smaps .write_to(@target) end |