Skip to content

Instantly share code, notes, and snippets.

@krhitoshi
Created January 21, 2016 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krhitoshi/63e487ffa9f835851ceb to your computer and use it in GitHub Desktop.
Save krhitoshi/63e487ffa9f835851ceb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
uri = "http://localhost/nginx_status"
lines = nil
open(uri) do |f|
lines = f.read.split("\n")
end
active_connections = lines[0].gsub("Active connections:", "").strip
(_, reading, _, writing, _, waiting) = lines[3].split
(accepts, handled, requests) = lines[2].split
case ARGV[0]
when "active_connections"
puts active_connections
when "reading"
puts reading
when "writing"
puts writing
when "waiting"
puts waiting
when "accepts"
puts accepts
when "handled"
puts handled
when "requests"
puts requests
else
raise "Unknown Argument: #{ARGV[0]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment