ring-sqa 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57b1933a179c8194ef549fcfe674b233bf2e3f83
4
- data.tar.gz: 6bc6c19ca66549c89dbd638cb27521134690c8e1
3
+ metadata.gz: 39d4bb0c179ebb868730fb900f75518d5475cde5
4
+ data.tar.gz: 13b35934016270da0ba4c922080dae1d55261d59
5
5
  SHA512:
6
- metadata.gz: c26570ab7f40dbf8499efbbce3d857f725b28fe7bd8baaddf1732a2c22186615587984859c804334a1ec5c3cdc5a7fd7026738237ca2aadb480218d764c0d68b
7
- data.tar.gz: 301fa5c8c8e9b794c6c318a05bab9130afab3e6df50da83cbf8653476e4a940e88ac4cbd7fe57e0904d99140e82634483338028ddc6116d1e4c73c4c06e62e01
6
+ metadata.gz: 10269a86e695073359afc15d363290ac7ceba9ea6e14d9d109f8bb76ad15049f34ca474a3d166d8bd177a529842da3a6dc5d1ed1ab6fb432908abf87bc60e9e3
7
+ data.tar.gz: cbcaf39e26af0800637519579576f9c7c0d70a7601470dac8bc7789783fd1b5801a321332cf4d670e2184a33319737d9fd5982d691d36ec5315c53fd7846a09d
data/CHANGELOG.md CHANGED
@@ -4,3 +4,9 @@
4
4
 
5
5
  # 0.1.0
6
6
  - wooo
7
+
8
+ # 0.4.0
9
+ - Graphite support added with country code (rinsekloek)
10
+
11
+ # 0.4.1
12
+ - Version bump
@@ -9,6 +9,7 @@ class Alarm
9
9
  URL = 'http://sqa-collector.infra.ring.nlnog.net/'
10
10
  TIMEOUT = 10
11
11
  def send opts
12
+ @url = CFG.collector.url? ? CFG.collector.url : URL
12
13
  json = JSON.pretty_generate( {
13
14
  :alarm_buffer => opts[:alarm_buffer].exceeding_nodes,
14
15
  :nodes => opts[:nodes].all,
@@ -28,7 +29,7 @@ class Alarm
28
29
  Thread.new do
29
30
  begin
30
31
  Timeout::timeout(TIMEOUT) do
31
- uri = URI.parse URL
32
+ uri = URI.parse @url
32
33
  http = Net::HTTP.new uri.host, uri.port
33
34
  http.use_ssl = true if uri.scheme == 'https'
34
35
  http.post uri.path, json
@@ -5,13 +5,15 @@ class SQA
5
5
  class Alarm
6
6
 
7
7
  class Email
8
- SERVER = 'localhost'
8
+ SERVER = 'localhost'
9
+ LIST_ID = 'ring-sqa <sqa.ring.nlnog.net>'
9
10
 
10
11
  def send opts
11
12
  short, long = opts[:short], opts[:long]
12
13
  @from = CFG.email.from
13
14
  @to = [CFG.email.to].flatten
14
15
  prefix = CFG.email.prefix? ? CFG.email.prefix : ''
16
+ @list_id = CFG.email.list_id? ? CFG.email.list_id : LIST_ID
15
17
  @subject = prefix + short
16
18
  @reply_to = CFG.email.reply_to? ? CFG.email.reply_to : @from
17
19
  @body = long
@@ -28,7 +30,7 @@ class Alarm
28
30
  mail << 'To: ' + @to.join(', ')
29
31
  mail << 'Reply-To: ' + @reply_to
30
32
  mail << 'Subject: ' + @subject
31
- mail << 'List-Id: ' + 'ring-sqa <sqa.ring.nlnog.net>'
33
+ mail << 'List-Id: ' + @list_id
32
34
  mail << 'X-Mailer: ' + 'ring-sqa'
33
35
  mail << ''
34
36
  mail = mail.join("\n")
@@ -45,7 +45,7 @@ class SQA
45
45
 
46
46
  def graphite
47
47
  require_relative 'graphite'
48
- Graphite.new
48
+ Graphite.new @nodes
49
49
  end
50
50
 
51
51
  end
@@ -1,18 +1,7 @@
1
1
  module Ring
2
2
  class SQA
3
3
  class Database
4
-
5
- class Ping < Sequel::Model
6
- set_schema do
7
- primary_key :id
8
- Fixnum :time
9
- String :peer
10
- Fixnum :latency
11
- String :result
12
- end
13
- create_table unless table_exists?
14
- end
15
-
4
+ class Ping < Sequel::Model; end
16
5
  end
17
6
  end
18
7
  end
@@ -43,7 +43,6 @@ class SQA
43
43
  private
44
44
 
45
45
  def initialize
46
- Sequel::Model.plugin :schema
47
46
  sequel_opts = { max_connections: 1, pool_timout: 60 }
48
47
  if CFG.ram_database?
49
48
  @db = Sequel.sqlite sequel_opts
@@ -53,8 +52,19 @@ class SQA
53
52
  File.unlink file rescue nil # delete old database
54
53
  @db = Sequel.sqlite file, sequel_opts
55
54
  end
55
+ create_db
56
56
  require_relative 'database/model.rb'
57
57
  end
58
+
59
+ def create_db
60
+ @db.create_table?(:pings) do
61
+ primary_key :id
62
+ Fixnum :time
63
+ String :peer
64
+ Fixnum :latency
65
+ String :result
66
+ end
67
+ end
58
68
  end
59
69
 
60
70
  end
@@ -7,21 +7,27 @@ class SQA
7
7
  ROOT = "nlnog.ring_sqa.#{CFG.afi}"
8
8
 
9
9
  def add records
10
+ host = @hostname.split(".").first
11
+ node = @nodes.all
10
12
  records.each do |record|
13
+ nodename = noderec = node[record.peer][:name].split(".").first
14
+ nodecc = noderec = node[record.peer][:cc].downcase
11
15
  hash = {
12
- "#{ROOT}.#{record.peer}.state" => record.result
16
+ "#{ROOT}.#{host}.#{nodecc}.#{nodename}.state" => record.result
13
17
  }
14
- if record.result == 'success'
15
- hash["#{ROOT}.#{record.peer}.latency"] = record.latency
18
+ if record.result != 'no response'
19
+ hash["#{ROOT}.#{host}.#{nodecc}.#{nodename}.latency"] = record.latency
16
20
  end
17
21
  @client.metrics hash, record.time
18
22
  end
19
23
  end
20
24
 
21
25
  private
22
-
23
- def initialize server=CFG.graphite
26
+
27
+ def initialize nodes, server=CFG.graphite
24
28
  @client = GraphiteAPI.new graphite: server
29
+ @hostname = Ring::SQA::CFG.host.name
30
+ @nodes = nodes
25
31
  end
26
32
  end
27
33
 
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.3.1'
3
+ s.version = '0.4.1'
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.3.1
4
+ version: 0.4.1
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: 2016-11-01 00:00:00.000000000 Z
12
+ date: 2019-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project: ring-sqa
168
- rubygems_version: 2.5.1
168
+ rubygems_version: 2.5.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: NLNOG Ring SQA