bin/metrics-nginx.rb in sensu-plugins-nginx-0.0.6 vs bin/metrics-nginx.rb in sensu-plugins-nginx-1.0.0

- old
+ new

@@ -13,11 +13,12 @@ # # DEPENDENCIES: # gem: sensu-plugin # # USAGE: -# #YELLOW +# metrics-nginx.rb -h hostname -p port -q status_path +# metrics-nginx.rb -u http://hostname:port/status_path # # NOTES: # # LICENSE: # Copyright 2012 Pete Shima <me@peteshima.com> @@ -40,14 +41,15 @@ description: 'Full URL to nginx status page, example: https://yoursite.com/nginx_status This ignores ALL other options EXCEPT --scheme' option :hostname, short: '-h HOSTNAME', long: '--host HOSTNAME', - description: 'Nginx hostname' + description: 'Nginx hostname', + default: 'localhost' option :port, - short: '-P PORT', + short: '-p PORT', long: '--port PORT', description: 'Nginx port', default: '80' option :path, @@ -62,11 +64,11 @@ long: '--scheme SCHEME', default: "#{Socket.gethostname}.nginx" # Main function # - def run # rubocop:disable all + def run found = false attempts = 0 until found || attempts >= 10 attempts += 1 if config[:url] @@ -90,10 +92,10 @@ end end end # #YELLOW - response.body.split(/\r?\n/).each do |line| # rubocop:disable Style/Next + response.body.split(/\r?\n/).each do |line| if line.match(/^Active connections:\s+(\d+)/) connections = line.match(/^Active connections:\s+(\d+)/).to_a output "#{config[:scheme]}.active_connections", connections[1] end if line.match(/^\s+(\d+)\s+(\d+)\s+(\d+)/)