Class: GitLab::Monitor::CLI::DatabaseTupleStats
- Inherits:
-
Object
- Object
- GitLab::Monitor::CLI::DatabaseTupleStats
- Defined in:
- lib/gitlab_monitor/cli.rb
Overview
Database tuple stats runner.
It will take a database connection string and print results to STDOUT
Constant Summary collapse
- COMMAND_NAME =
"db-tuple-stats".freeze
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(args) ⇒ DatabaseTupleStats
constructor
A new instance of DatabaseTupleStats.
- #options(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ DatabaseTupleStats
Returns a new instance of DatabaseTupleStats.
85 86 87 88 89 90 91 |
# File 'lib/gitlab_monitor/cli.rb', line 85 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
102 103 104 |
# File 'lib/gitlab_monitor/cli.rb', line 102 def help @options.help end |
#options(args) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/gitlab_monitor/cli.rb', line 93 def (args) args. do |opts| opts. = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]" opts.on("--db-conn=\"dbname=test port=5432\"", "Database connection string") do |val| @db_connection_string = val end end end |
#run ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/gitlab_monitor/cli.rb', line 106 def run validate! ::GitLab::Monitor::Database::TuplesProber.new(connection_string: @db_connection_string) .probe_db .write_to(@target) end |