Sha256: 9ef0230b830c24ebc92475994f33f3c761a1fcc19c27712b76ac6af3ea93cbbd

Contents?: true

Size: 954 Bytes

Versions: 29

Compression:

Stored size: 954 Bytes

Contents

class Nginx
	
	include Watchman
	
	def self.data
		out = PS.data.inject({:masters => [], :workers => []}) do |acc,line|
			if line[:command][/^nginx: master/]
				acc[:masters] << line
			end
			if line[:command][/^nginx: worker/]
				acc[:workers] << line
			end
			acc
		end
		
		if `curl -I -silent http://localhost/nginx_status`[/^HTTP\/1.1 200/]
			active, garbage, nums, open = `curl -silent http://localhost/nginx_status`.split("\n")
			accepts, handled, requests = nums.split
			garbage, reading, garbage, writing, garbage, waiting = open.split
			out = out.merge({:active_connections => active.gsub(/.*:/,'').to_i, :accepted => accepts.to_i, :handled => handled.to_i, :requests => requests.to_i, :reading => reading.to_i, :writing => writing.to_i, :waiting => waiting.to_i})
		end
		
		out.merge({:num_masters => out[:masters].count, :num_workers => out[:workers].count, :summary => [:num_masters, :num_workers, :active_connections]})
	end
	
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
city-watch-0.5.9 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.8 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.7 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.6 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.5 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.4 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.3 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.2 lib/city_watch/watchmen/nginx.rb
city-watch-0.5.1 lib/city_watch/watchmen/nginx.rb