city-watch 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/city_watch/watchmen/nginx.rb +16 -1
- data/lib/city_watch/watchmen/unicorns.rb +4 -1
- data/lib/version.rb +1 -1
- metadata +1 -1
@@ -12,7 +12,22 @@ class Nginx
|
|
12
12
|
end
|
13
13
|
acc
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
require 'net/http'
|
17
|
+
require 'net/https'
|
18
|
+
uri = URI.parse("http://localhost/nginx_status")
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
+
req = Net::HTTP::Get.new(uri.path)
|
21
|
+
resp = http.request(req)
|
22
|
+
case resp
|
23
|
+
when Net::HTTPSuccess
|
24
|
+
active, garbage, nums, open = resp.read_body.split("\n")
|
25
|
+
accepts, handled, requests = nums.split
|
26
|
+
garbage, reading, garbage, writing, garbage, waiting = open.split
|
27
|
+
out.merge({:active_connections => active.gsub(/.*:/,''), :accepted => accepts, :handled => handled, :requests => requests, :reading => reading, :writing => writing, :waiting => waiting})
|
28
|
+
end
|
29
|
+
|
30
|
+
out.merge({:num_masters => out[:masters].count, :num_workers => out[:workers].count, :summary => [:num_masters, :num_workers, :active_connections]})
|
16
31
|
end
|
17
32
|
|
18
33
|
end
|
@@ -3,13 +3,16 @@ class Unicorns
|
|
3
3
|
include Watchman
|
4
4
|
|
5
5
|
def self.data
|
6
|
-
out = PS.data.inject({:masters => [], :workers => []}) do |acc,line|
|
6
|
+
out = PS.data.inject({:masters => [], :workers => [], :master_memory => 0, :worker_memory => 0, :total_memory => 0}) do |acc,line|
|
7
7
|
if line[:command][/^start master/]
|
8
8
|
acc[:masters] << line
|
9
|
+
acc[:master_memory] += line[:rss].to_i
|
9
10
|
end
|
10
11
|
if line[:command][/^start worker/]
|
11
12
|
acc[:workers] << line
|
13
|
+
acc[:worker_memory] += line[:rss].to_i
|
12
14
|
end
|
15
|
+
acc[:total_memory] += line[:rss].to_i
|
13
16
|
acc
|
14
17
|
end
|
15
18
|
out.merge({:num_masters => out[:masters].count, :num_workers => out[:workers].count, :summary => [:num_masters, :num_workers]})
|
data/lib/version.rb
CHANGED