check_slony 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/check_slony +13 -6
- data/lib/check_slony.rb +1 -1
- metadata +3 -3
data/bin/check_slony
CHANGED
@@ -4,15 +4,19 @@ require 'rubygems'
|
|
4
4
|
require 'pg'
|
5
5
|
require 'optparse'
|
6
6
|
require 'timeout'
|
7
|
+
require 'ruby-debug'
|
7
8
|
|
8
9
|
|
9
10
|
pgoptions=''
|
10
11
|
pgtty=''
|
11
12
|
@result=''
|
12
13
|
@problems = 0
|
14
|
+
@event = 10
|
15
|
+
@lagtime = 20
|
13
16
|
@timeout = 10
|
14
17
|
|
15
18
|
OptionParser.new do |opt|
|
19
|
+
|
16
20
|
opt.on("-H","--host=DBHOSTNAME", String, "Specify the DBHOSTNAME"){|h| @hostname = h }
|
17
21
|
opt.on("-P","--port=PORTNUMBER", Integer, "Specify the DB port number"){|p| @port = p }
|
18
22
|
opt.on("-u","--username=DBUSER", String, "Specify the DB user name"){|u| @user = u }
|
@@ -22,7 +26,7 @@ OptionParser.new do |opt|
|
|
22
26
|
opt.on("-e","--events=EVENTS", Integer, "Specify the Event Counts"){|e| @event = e }
|
23
27
|
opt.on("-l","--lagtime=LAGTIME", Integer, "Specify the LAGTIME"){|l| @lagtime = l }
|
24
28
|
opt.on("-t","--timeout=TIMEOUT", Integer, "Specify the TIMEOUT"){|t| @timeout = t }
|
25
|
-
|
29
|
+
|
26
30
|
begin
|
27
31
|
opt.parse!(ARGV)
|
28
32
|
rescue OptionParser::ParseError => err
|
@@ -31,7 +35,7 @@ OptionParser.new do |opt|
|
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
begin
|
38
|
+
begin
|
35
39
|
timeout(@timeout){
|
36
40
|
# sleep 3 # for debug
|
37
41
|
con = PGconn.new(@hostname, @port, pgoptions, pgtty, @dbname, @user, @password)
|
@@ -52,14 +56,14 @@ begin
|
|
52
56
|
|
53
57
|
@result += "SUBSCRIBER " + node + " ON ORIGIN " + master + " : EVENT LAG=" + lag
|
54
58
|
if (lag.to_i > 0) && (@event < lag.to_i)
|
55
|
-
|
56
|
-
|
59
|
+
@result = @result + " (BEHIND " + (lag.to_i - @event).to_s + ") ";
|
60
|
+
@problems += 1
|
57
61
|
end
|
58
62
|
@result = @result + " TIME LAG=" + round + "s";
|
59
63
|
|
60
64
|
if (@lagtime > 0) && (@lagtime < round.to_i)
|
61
|
-
|
62
|
-
|
65
|
+
@result = @result + " (BEHIND " + (round.to_i - @lagtime).to_s + "s) ";
|
66
|
+
@problems += 1
|
63
67
|
end
|
64
68
|
@result = @result + " || ";
|
65
69
|
|
@@ -87,5 +91,8 @@ rescue => ex
|
|
87
91
|
exit 3
|
88
92
|
end
|
89
93
|
|
94
|
+
|
95
|
+
|
96
|
+
|
90
97
|
exit;
|
91
98
|
abort "you need to write me"
|
data/lib/check_slony.rb
CHANGED
metadata
CHANGED