city-watch 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/city_watch/util/watchman.rb +5 -1
- data/lib/city_watch/watchmen/redis.rb +6 -0
- data/lib/city_watch/watchmen.rb +2 -1
- data/lib/version.rb +1 -1
- metadata +1 -1
@@ -39,7 +39,7 @@ module Watchman
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def opts
|
42
|
-
@options ||=
|
42
|
+
@options ||= get_watchman_options
|
43
43
|
end
|
44
44
|
|
45
45
|
def options(*args)
|
@@ -63,6 +63,10 @@ module Watchman
|
|
63
63
|
@post_processors << (block_given? ? block : meth)
|
64
64
|
end
|
65
65
|
|
66
|
+
def get_watchman_options
|
67
|
+
CityWatch.config[:watchmen] && CityWatch.config[:watchmen][self.name.to_sym] ? CityWatch.config[:watchmen][self.name.to_sym] : {}
|
68
|
+
end
|
69
|
+
|
66
70
|
end
|
67
71
|
|
68
72
|
def self.included(base)
|
@@ -3,6 +3,12 @@ class Redis
|
|
3
3
|
include Watchman
|
4
4
|
|
5
5
|
def self.data
|
6
|
+
if opts[:ports]
|
7
|
+
dat = opts[:ports].map do |port|
|
8
|
+
out = `redis-cli -p #{port} info`
|
9
|
+
out.gsub(/^(#.*|$)$/,'').gsub(/(\r\n)+/,"\r\n").split("\r\n").map {|str| str.strip.split(":") }.inject({}) {|acc,(k,v)| acc[k.to_sym] = v; acc }
|
10
|
+
end
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
end
|
data/lib/city_watch/watchmen.rb
CHANGED
@@ -10,7 +10,7 @@ module Watchmen
|
|
10
10
|
|
11
11
|
def self.data
|
12
12
|
@watchmen.inject({}) do |acc,watchman|
|
13
|
-
if !CityWatch.config[:watchmen] || CityWatch.config[:watchmen]
|
13
|
+
if !CityWatch.config[:watchmen] || CityWatch.config[:watchmen][watchman.name.to_sym]
|
14
14
|
acc[watchman.name] = watchman.data
|
15
15
|
end
|
16
16
|
acc
|
@@ -41,3 +41,4 @@ require 'city_watch/watchmen/nginx'
|
|
41
41
|
require 'city_watch/watchmen/cpu_usage'
|
42
42
|
require 'city_watch/watchmen/disk_usage'
|
43
43
|
require 'city_watch/watchmen/uptime'
|
44
|
+
require 'city_watch/watchmen/redis'
|
data/lib/version.rb
CHANGED