Class: NginxStatus
Overview
Simple Ruby library to download and parse /nginx_status and return Hash of Nginx counters
Class Method Summary collapse
-
.get_status(host) ⇒ Object
Request status and send to parser.
-
.parse_status(parsed_response) ⇒ Object
Parse stub status, return Hash.
Class Method Details
.get_status(host) ⇒ Object
Request status and send to parser
10 11 12 13 |
# File 'lib/nginx_status.rb', line 10 def self.get_status(host) response = get("http://#{host}/nginx_status").parsed_response parse_status(response) end |
.parse_status(parsed_response) ⇒ Object
Parse stub status, return Hash
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nginx_status.rb', line 16 def self.parse_status(parsed_response) begin status = parsed_response.split("\n") rww = status[3].split sahr = status[2].split {:active_connections => status[0].gsub("Active connections: ", "").to_i, :accepted => sahr[0].to_i, :handled => sahr[1].to_i, :handles => sahr[2].to_i, :reading => rww[1].to_i, :writing => rww[3].to_i, :waiting => rww[5].to_i} rescue raise "ParseError" end end |