ring-sqa 0.3.1 → 0.4.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/ring/sqa/alarm/collector.rb +2 -1
- data/lib/ring/sqa/alarm/email.rb +4 -2
- data/lib/ring/sqa/analyzer.rb +1 -1
- data/lib/ring/sqa/database/model.rb +1 -12
- data/lib/ring/sqa/database.rb +11 -1
- data/lib/ring/sqa/graphite.rb +11 -5
- data/ring-sqa.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d4bb0c179ebb868730fb900f75518d5475cde5
|
4
|
+
data.tar.gz: 13b35934016270da0ba4c922080dae1d55261d59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10269a86e695073359afc15d363290ac7ceba9ea6e14d9d109f8bb76ad15049f34ca474a3d166d8bd177a529842da3a6dc5d1ed1ab6fb432908abf87bc60e9e3
|
7
|
+
data.tar.gz: cbcaf39e26af0800637519579576f9c7c0d70a7601470dac8bc7789783fd1b5801a321332cf4d670e2184a33319737d9fd5982d691d36ec5315c53fd7846a09d
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
data/lib/ring/sqa/alarm/email.rb
CHANGED
@@ -5,13 +5,15 @@ class SQA
|
|
5
5
|
class Alarm
|
6
6
|
|
7
7
|
class Email
|
8
|
-
SERVER
|
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: ' +
|
33
|
+
mail << 'List-Id: ' + @list_id
|
32
34
|
mail << 'X-Mailer: ' + 'ring-sqa'
|
33
35
|
mail << ''
|
34
36
|
mail = mail.join("\n")
|
data/lib/ring/sqa/analyzer.rb
CHANGED
@@ -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
|
data/lib/ring/sqa/database.rb
CHANGED
@@ -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
|
data/lib/ring/sqa/graphite.rb
CHANGED
@@ -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}.#{
|
16
|
+
"#{ROOT}.#{host}.#{nodecc}.#{nodename}.state" => record.result
|
13
17
|
}
|
14
|
-
if record.result
|
15
|
-
hash["#{ROOT}.#{
|
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
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.
|
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:
|
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.
|
168
|
+
rubygems_version: 2.5.2
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: NLNOG Ring SQA
|