Sha256: 748afc52a27209cb1dd3c893baef2ec9317f172f41fbc8a04c72df14c27a2a15

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 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 http://localhost/nginx_status`[/^HTTP\/1.1 200/]
			active, garbage, nums, open = `curl http://localhost/nginx_status`.split("\n")
			accepts, handled, requests = nums.split
			garbage, reading, garbage, writing, garbage, waiting = open.split
			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

1 entries across 1 versions & 1 rubygems

Version Path
city-watch-0.4.9 lib/city_watch/watchmen/nginx.rb