ring-sqa 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ring/sqa/alarm/message.rb +1 -1
- data/lib/ring/sqa/alarm.rb +2 -1
- data/lib/ring/sqa/analyzer.rb +5 -4
- data/lib/ring/sqa/cli.rb +3 -1
- data/lib/ring/sqa/database.rb +1 -1
- data/lib/ring/sqa/nodes.rb +3 -2
- data/lib/ring/sqa/poller.rb +3 -4
- data/ring-sqa.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6768fa2c6c13c430f0f704ded317746fccce1aa9
|
4
|
+
data.tar.gz: f136b1e93986fc855081a347fd5ef8647b75ff6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b8e6ad533c6be0771fb467ddae3cc23c431e5a91c3fd03a2cd3cb0ecd7205a1e09b3f0488103468593623dffc05c0aee2ada8f5047bd162b584b68f8f31987
|
7
|
+
data.tar.gz: aacca386783c1df76ca9226a243e701ef6bc7af86d5f6730d6dd925296ac98ee41f1806bc0e3200f3fa9865a13c41d14e031ca78b30e1e30a6e33173393e0ef8
|
@@ -4,7 +4,7 @@ class SQA
|
|
4
4
|
class Alarm
|
5
5
|
def message nodes_list, mtr_list, buffer_list
|
6
6
|
"
|
7
|
-
Regarding: #{Ring::SQA::CFG.host.name}
|
7
|
+
Regarding: #{Ring::SQA::CFG.host.name} #{Ring::SQA::CFG.afi}
|
8
8
|
|
9
9
|
This is an automated alert from the distributed partial outage
|
10
10
|
monitoring system 'RING SQA'.
|
data/lib/ring/sqa/alarm.rb
CHANGED
@@ -36,12 +36,13 @@ class SQA
|
|
36
36
|
@methods << Email.new if CFG.email.to?
|
37
37
|
@methods << UDP2IRC.new if CFG.irc.password?
|
38
38
|
@hostname = Ring::SQA::CFG.host.name
|
39
|
+
@afi = Ring::SQA::CFG.afi
|
39
40
|
@alarm = false
|
40
41
|
end
|
41
42
|
|
42
43
|
def compose_message alarm_buffer
|
43
44
|
exceeding_nodes = alarm_buffer.exceeding_nodes
|
44
|
-
msg = {short: "#{@hostname}: raising alarm - #{exceeding_nodes.size} new nodes down"}
|
45
|
+
msg = {short: "#{@hostname}: raising #{@afi} alarm - #{exceeding_nodes.size} new nodes down"}
|
45
46
|
exceeding_nodes = exceeding_nodes.map { |node| @nodes.get node }
|
46
47
|
|
47
48
|
nodes_list = ''
|
data/lib/ring/sqa/analyzer.rb
CHANGED
@@ -39,10 +39,11 @@ class SQA
|
|
39
39
|
class AnalyzeBuffer
|
40
40
|
attr_reader :array
|
41
41
|
def initialize nodes_count, max_size=30, median_of=27
|
42
|
-
@max_size
|
43
|
-
@median_of
|
44
|
-
|
45
|
-
|
42
|
+
@max_size = max_size
|
43
|
+
@median_of = median_of
|
44
|
+
nodes_count = CFG.fake? ? 0 : nodes_count
|
45
|
+
init_nodes = Array.new nodes_count * 2, ''
|
46
|
+
@array = Array.new max_size, init_nodes
|
46
47
|
end
|
47
48
|
def push e
|
48
49
|
@array.shift
|
data/lib/ring/sqa/cli.rb
CHANGED
@@ -22,7 +22,8 @@ class SQA
|
|
22
22
|
def initialize
|
23
23
|
_args, @opts = opts_parse
|
24
24
|
CFG.debug = @opts.debug?
|
25
|
-
CFG.
|
25
|
+
CFG.afi = @opts.ipv6? ? "ipv6" : "ipv4"
|
26
|
+
CFG.fake = @opts.fake?
|
26
27
|
require_relative 'log'
|
27
28
|
Log.level = Logger::DEBUG if @opts.debug?
|
28
29
|
run
|
@@ -33,6 +34,7 @@ class SQA
|
|
33
34
|
banner 'Usage: ring-sqad [options]'
|
34
35
|
on 'd', '--debug', 'turn on debugging'
|
35
36
|
on '6', '--ipv6', 'use ipv6 instead of ipv4'
|
37
|
+
on '--fake', 'initialize analyzebuffer with 0 nodes'
|
36
38
|
on '--daemonize', 'run in background'
|
37
39
|
end
|
38
40
|
[slop.parse!, slop]
|
data/lib/ring/sqa/database.rb
CHANGED
@@ -43,7 +43,7 @@ class SQA
|
|
43
43
|
if CFG.ram_database?
|
44
44
|
@db = Sequel.sqlite sequel_opts
|
45
45
|
else
|
46
|
-
file =
|
46
|
+
file = '%s.db' % CFG.afi
|
47
47
|
file = File.join CFG.directory, file
|
48
48
|
File.unlink file rescue nil # delete old database
|
49
49
|
@db = Sequel.sqlite file, sequel_opts
|
data/lib/ring/sqa/nodes.rb
CHANGED
@@ -46,7 +46,7 @@ class SQA
|
|
46
46
|
nodes = {}
|
47
47
|
json = JSON.load File.read(file)
|
48
48
|
json['results']['nodes'].each do |node|
|
49
|
-
addr = CFG.
|
49
|
+
addr = node[CFG.afi]
|
50
50
|
next unless ips.include? addr
|
51
51
|
nodes[addr] = node
|
52
52
|
end
|
@@ -70,13 +70,14 @@ class SQA
|
|
70
70
|
|
71
71
|
|
72
72
|
def entry_skip? entry
|
73
|
+
# skip ipv4 entries if we are running in ipv6 mode, and vice versa
|
73
74
|
return true unless entry.size > 2
|
74
75
|
return true if entry.first.match(/^\s*#/)
|
75
76
|
return true if CFG.hosts.ignore.any? { |re| entry[2].match Regexp.new(re) }
|
76
77
|
return true unless CFG.hosts.load.any? { |re| entry[2].match Regexp.new(re) }
|
77
78
|
|
78
79
|
address = IPAddr.new(entry.first) rescue (return true)
|
79
|
-
if CFG.ipv6
|
80
|
+
if CFG.afi == "ipv6"
|
80
81
|
return true if address.ipv4?
|
81
82
|
return true if address == IPAddr.new(CFG.host.ipv6)
|
82
83
|
else
|
data/lib/ring/sqa/poller.rb
CHANGED
@@ -5,16 +5,15 @@ class SQA
|
|
5
5
|
MAX_READ = 500
|
6
6
|
|
7
7
|
def address
|
8
|
-
|
9
|
-
CFG.ipv6? ? '::' : '0.0.0.0' # NAT 1:1 does not have expected address where we can bind
|
8
|
+
CFG.afi == "ipv6" ? '::' : '0.0.0.0' # NAT 1:1 does not have expected address where we can bind
|
10
9
|
end
|
11
10
|
|
12
11
|
def port
|
13
|
-
CFG.port.to_i
|
12
|
+
CFG.port.to_i + ( CFG.afi == 'ipv6' ? 6 : 0 )
|
14
13
|
end
|
15
14
|
|
16
15
|
def udp_socket
|
17
|
-
CFG.ipv6
|
16
|
+
CFG.afi == "ipv6" ? UDPSocket.new(Socket::AF_INET6) : UDPSocket.new
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
data/ring-sqa.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ring-sqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saku Ytti
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slop
|