sensu-plugins / sensu-plugins-network-checks

This plugin provides native network instrumentation for monitoring and metrics collection, including: hardware, TCP response, RBLs, whois, port status, and more.
http://sensu-plugins.io
MIT License
30 stars 76 forks source link

Handle whois errors better #31

Closed eheydrick closed 8 years ago

eheydrick commented 8 years ago

Add timeout option and increase to 10 seconds - whois gem defaults to 5 seconds, which is too short for some whois servers. Also retry connection errors.

Before:

/opt/sensu/embedded/bin/check-whois-domain-expiration-multi.rb -d ... -w 30 -c 7
Check failed to run: Errno::ECONNRESET: Connection reset by peer, ["/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/socket_handler.rb:40:in `rescue in call'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/socket_handler.rb:38:in `call'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/adapters/base.rb:175:in `query'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/adapters/verisign.rb:33:in `request'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/adapters/base.rb:107:in `block in lookup'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/adapters/base.rb:143:in `buffer_start'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/server/adapters/base.rb:106:in `lookup'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/client.rb:94:in `block in lookup'", "/opt/sensu/embedded/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout'", "/opt/sensu/embedded/lib/ruby/2.2.0/timeout.rb:32:in `block in catch'", "/opt/sensu/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'", "/opt/sensu/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'", "/opt/sensu/embedded/lib/ruby/2.2.0/timeout.rb:103:in `timeout'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois/client.rb:91:in `lookup'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/whois-3.6.3/lib/whois.rb:42:in `lookup'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/check-whois-domain-expiration-multi.rb:76:in `block in expiration_results'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/check-whois-domain-expiration-multi.rb:75:in `each'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/check-whois-domain-expiration-multi.rb:75:in `expiration_results'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-network-checks-0.1.4/bin/check-whois-domain-expiration-multi.rb:90:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]

After:

/opt/sensu/embedded/bin/check-whois-domain-expiration-multi.rb -d ... -w 30 -c 7
WhoisDomainExpirationCheck OK: No domains expire in the near term

Pull Request Checklist

Is this in reference to an existing issue?

General

eheydrick commented 8 years ago

@analytically @sstarcher @mattyjones ready for review and merge