murakumo 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/misc/murakumo_const.rb +1 -1
- data/lib/srv/murakumo_health_check_context.rb +45 -28
- metadata +3 -3
data/lib/misc/murakumo_const.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'net/smtp'
|
3
|
+
require 'net/telnet'
|
3
4
|
require 'socket'
|
4
5
|
|
5
6
|
require 'misc/murakumo_const'
|
@@ -26,7 +27,7 @@ module Murakumo
|
|
26
27
|
end
|
27
28
|
|
28
29
|
# HTTPチェッカー
|
29
|
-
def http_get(path, statuses = [200], host = '127.0.0.1'
|
30
|
+
def http_get(path, statuses = [200], port = 80, host = '127.0.0.1')
|
30
31
|
res = Net::HTTP.start('127.0.0.1', 80) do |http|
|
31
32
|
http.read_timeout = @options['timeout']
|
32
33
|
http.get(path)
|
@@ -46,8 +47,18 @@ module Murakumo
|
|
46
47
|
return false
|
47
48
|
end
|
48
49
|
|
49
|
-
#
|
50
|
-
|
50
|
+
# memcachedチェッカー
|
51
|
+
def memcached_check(port = 11211, host = '127.0.0.1')
|
52
|
+
telnet = Net::Telnet.new('Host' => host, 'Port' => port)
|
53
|
+
!!telnet.cmd('String' => 'stats', 'Match' => /END/i, 'Timeout' => @options['timeout'])
|
54
|
+
rescue =>e
|
55
|
+
@logger.debug("#{@name}: #{e.message}")
|
56
|
+
return false
|
57
|
+
ensure
|
58
|
+
if telnet
|
59
|
+
telnet.close rescue nil
|
60
|
+
end
|
61
|
+
end
|
51
62
|
|
52
63
|
begin
|
53
64
|
require 'mysql'
|
@@ -68,37 +79,43 @@ module Murakumo
|
|
68
79
|
@logger.debug("#{@name}: #{e.message}")
|
69
80
|
return false
|
70
81
|
ensure
|
71
|
-
|
82
|
+
if my
|
83
|
+
my.close rescue nil
|
84
|
+
end
|
72
85
|
end
|
73
86
|
rescue LoadError
|
74
87
|
end
|
75
88
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
unless defined?(:mysql_check)
|
90
|
+
begin
|
91
|
+
require 'mysql2'
|
92
|
+
|
93
|
+
def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
|
94
|
+
opts = {}
|
95
|
+
opts[:username] = user
|
96
|
+
opts[:password] = passwd if passwd
|
97
|
+
opts[:host] = host if host
|
98
|
+
opts[:database] = db if db
|
99
|
+
|
100
|
+
if port_sock.kind_of?(Integer)
|
101
|
+
opts[:port] = port_sock
|
102
|
+
else
|
103
|
+
opts[:socket] = port_sock
|
104
|
+
end
|
105
|
+
|
106
|
+
my = Mysql2::Client.new(opts)
|
107
|
+
my.ping
|
108
|
+
rescue => e
|
109
|
+
@logger.debug("#{@name}: #{e.message}")
|
110
|
+
return false
|
111
|
+
ensure
|
112
|
+
if my
|
113
|
+
my.close rescue nil
|
114
|
+
end
|
90
115
|
end
|
91
|
-
|
92
|
-
my = Mysql2::Client.new(opts)
|
93
|
-
my.ping
|
94
|
-
rescue => e
|
95
|
-
@logger.debug("#{@name}: #{e.message}")
|
96
|
-
return false
|
97
|
-
ensure
|
98
|
-
my.close if my
|
116
|
+
rescue LoadError
|
99
117
|
end
|
100
|
-
|
101
|
-
end
|
118
|
+
end # unless defined?(:mysql_check)
|
102
119
|
|
103
120
|
end # HealthCheckContext
|
104
121
|
|
metadata
CHANGED