sensu-plugins-http icon indicating copy to clipboard operation
sensu-plugins-http copied to clipboard

metrics-http-json.rb HTTP basic auth

Open noahbailey opened this issue 5 years ago • 4 comments

Extracting metrics from an api endpoint that requires authentication fails in a strange way. When the --url parameter is formatted like "user:pass@localhost:8080" the check fails with this output:

Check failed to run: Failed to open TCP connection to http:80 (getaddrinfo: Name or service not known), ["/usr/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'", "/usr/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'", "/usr/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'", "/usr/lib/ruby/2.3.0/timeout.rb:101:in `timeout'", "/usr/lib/ruby/2.3.0/net/http.rb:878:in `connect'", "/usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'", "/usr/lib/ruby/2.3.0/net/http.rb:852:in `start'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'", "/var/lib/gems/2.3.0/gems/sensu-plugins-http-5.1.1/bin/metrics-http-json.rb:91:in `run'", "/var/lib/gems/2.3.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:59:in `block in <class:CLI>'"]

Of course, the request is not for port 80, making this failure perplexing.

noahbailey avatar Jul 12 '19 17:07 noahbailey

let me take a look at this and see if I can figure it out. Ping here again on Monday if you haven't seen a response from me.

jspaleta avatar Jul 12 '19 19:07 jspaleta

I suppose another way to go about it would be to add the --username and --password flags from the check-http-json.rb script.

noahbailey avatar Jul 15 '19 13:07 noahbailey

Hey, @jspaleta any updates on this? If it helps at all, I'll be using this plugin to grab metrics from the CouchDB api, so it does need to have HTTP basic auth on a high port (5984/5986) Let me know if you need more info, cheers!

noahbailey avatar Aug 19 '19 17:08 noahbailey

Yeah let's implement the username and password flags. I'll prioritize this right now and see if I can get this implemented.

jspaleta avatar Aug 26 '19 18:08 jspaleta