sensu-plugins / sensu-plugins-haproxy

This plugin provides native HAProxy instrumentation for monitoring and metrics collection, including: service health and backend server metrics.
http://sensu-plugins.io
MIT License
11 stars 37 forks source link

Add config flag to use SSL #25

Closed Evesy closed 7 years ago

Evesy commented 7 years ago

Pull Request Checklist

RE https://github.com/sensu-plugins/sensu-plugins-haproxy/issues/12

General

Purpose

As per linked issue check-haproxy.rb does not currently provide an option to use SSL, unlike metrics-haproxy.rb which already does.

This change copies the implementation found in metrics-haproxy.rb

Known Compatability Issues

None, SSL is disabled by default.

Evesy commented 7 years ago

Hopefully some reassurance this change works!

http only stats endpoint:

[root@haproxy ~]# /opt/sensu/embedded/bin/check-haproxy.rb -S <domain> -P 1936 -s .* -q stats -u <user> -p <pass>
CheckHAProxy OK: UP: 100% of 1 /./ services

[root@haproxy ~]# /opt/sensu/embedded/bin/check-haproxy.rb -S <domain> -P 1936 -s .* -q stats -u <user> -p <pass> --use-ssl
Check failed to run: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol, ["/opt/sensu/embedded/lib/ruby/2.4.0/net/protocol.rb:44:in `connect_nonblock'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/protocol.rb:44:in `ssl_socket_connect'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:948:in `connect'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:887:in `do_start'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:876:in `start'", "/opt/sensu/embedded/lib/ruby/2.4.0/net/http.rb:608:in `start'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-haproxy-1.2.0/bin/check-haproxy.rb:209:in `acquire_services'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-haproxy-1.2.0/bin/check-haproxy.rb:139:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]

https only stats endpoint:

[root@haproxy ~]# /opt/sensu/embedded/bin/check-haproxy.rb -S <domain> -P 1936 -s .* -q stats -u <user> -p <pass>
Check failed to run: end of file reached, []

[root@haproxy ~]# /opt/sensu/embedded/bin/check-haproxy.rb -S <domain> -P 1936 -s .* -q stats -u <user> -p <pass> --use-ssl
CheckHAProxy OK: UP: 100% of 1 /./ services
majormoses commented 7 years ago

released: https://rubygems.org/gems/sensu-plugins-haproxy/versions/1.3.0