lib/gitlab_exporter/cli.rb in gitlab-exporter-14.5.0 vs lib/gitlab_exporter/cli.rb in gitlab-exporter-15.0.0
- old
+ new
@@ -295,32 +295,50 @@
@target = args.shift || STDOUT
@target = File.open(@target, "a") if @target.is_a?(String)
end
- def options(args)
+ def options(args) # rubocop:disable Metrics/MethodLength
args.options do |opts|
opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]"
opts.on("--redis-url=\"redis://localhost:6379\"", "Redis URL") do |val|
@redis_url = val
end
+ opts.on("--redis-sentinel-username=\"my-sentinel-username\"", "Redis Sentinel username") do |val|
+ @redis_sentinel_username = val
+ end
+ opts.on("--redis-sentinel-password=\"my-sentinel-password\"", "Redis Sentinel password") do |val|
+ @redis_sentinel_password = val
+ end
+ opts.on("--redis-sentinels=HOST1:PORT1,HOST2:PORT2", Array, "List of Redis Sentinels") do |val|
+ @redis_sentinels = val.map { |item|
+ host, port = item.split(":")
+ { host: host, port: port.to_i }
+ }
+ end
end
end
def help
@options.help
end
def run
validate!
- ::GitLab::Exporter::SidekiqProber.new(redis_url: @redis_url)
- .probe_stats
- .probe_queues
- .probe_jobs_limit
- .probe_workers
- .probe_retries
- .write_to(@target)
+ prober = ::GitLab::Exporter::SidekiqProber.new(redis_url: @redis_url,
+ redis_sentinels: @redis_sentinels,
+ redis_sentinel_username: @redis_sentinel_username,
+ redis_sentinel_password: @redis_sentinel_password,
+ logger: Logger.new(STDERR))
+
+ prober
+ .probe_stats
+ .probe_queues
+ .probe_jobs_limit
+ .probe_workers
+ .probe_retries
+ .write_to(@target)
end
private
def validate!