ring-sqa 0.0.20 → 0.0.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caa9122c18e3a803a62729778308c5af962fdfab
4
- data.tar.gz: 877437aef04803f4baf0f9603e938f46b886445d
3
+ metadata.gz: 6768fa2c6c13c430f0f704ded317746fccce1aa9
4
+ data.tar.gz: f136b1e93986fc855081a347fd5ef8647b75ff6c
5
5
  SHA512:
6
- metadata.gz: b0fde0350ff73add7549347cb05b493a01bdb98f8cac9669616c10c4c53045ac32ed8e4e52c63654d1470810bf50d1260556503b0bc95376a1648b67fc2f290a
7
- data.tar.gz: bded7fb091e59c8706412efabe163ccb7e72516fe6feaf0ef6b9eeb1a469561d7afe05f1da09a32fed4b34e5d82752fabf777e6706f4ccfd1b75a9fa04811756
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'.
@@ -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 = ''
@@ -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 = max_size
43
- @median_of = median_of
44
- init_nodes = Array.new nodes_count * 2, ''
45
- @array = Array.new max_size, init_nodes
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.ipv6 = @opts.ipv6?
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]
@@ -43,7 +43,7 @@ class SQA
43
43
  if CFG.ram_database?
44
44
  @db = Sequel.sqlite sequel_opts
45
45
  else
46
- file = CFG.ipv6? ? 'ipv6.db' : 'ipv4.db'
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
@@ -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.ipv6? ? node['ipv6'] : node['ipv4']
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
@@ -5,16 +5,15 @@ class SQA
5
5
  MAX_READ = 500
6
6
 
7
7
  def address
8
- #CFG.ipv6? ? CFG.host.ipv6 : CFG.host.ipv4
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? ? UDPSocket.new(Socket::AF_INET6) : UDPSocket.new
16
+ CFG.afi == "ipv6" ? UDPSocket.new(Socket::AF_INET6) : UDPSocket.new
18
17
  end
19
18
  end
20
19
 
data/ring-sqa.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ring-sqa'
3
- s.version = '0.0.20'
3
+ s.version = '0.0.21'
4
4
  s.licenses = %w( Apache-2.0 )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti', 'Job Snijders' ]
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.20
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-25 00:00:00.000000000 Z
12
+ date: 2014-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop