Created
January 21, 2016 07:26
-
-
Save krhitoshi/63e487ffa9f835851ceb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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