module NginxUtils::Status
Public Class Methods
get(options={})
click to toggle source
# File lib/nginx_utils/status.rb, line 6 def get(options={}) host = options.fetch(:host, "localhost") port = options.fetch(:port, 80) path = options.fetch(:path, "/nginx_status") req = Net::HTTP::Get.new(path) res = Net::HTTP.start(host, port){|http| http.request(req)} parse res.body.split("\n").map{|l| l.split} end
Private Class Methods
formexp(args)
click to toggle source
# File lib/nginx_utils/status.rb, line 27 def formexp(args) { active_connections: args[0], accepts: args[1], handled: args[2], requests: args[3], reading: args[4], writing: args[5], waiting: args[6] } end
parse(spbody)
click to toggle source
# File lib/nginx_utils/status.rb, line 17 def parse(spbody) formexp([ spbody[0].last, spbody[2], spbody[3].select{|i| /^[0-9]*$/ =~ i} ].flatten.map{|i| i.to_i}) rescue raise "Parse error" end