ring-sqa 0.4.3 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ee3dfdbdc7f5a62e8914c040f4b8faf4a1399aea
4
- data.tar.gz: '08532368f08e2f50829e72d82797f2b970f127c9'
2
+ SHA256:
3
+ metadata.gz: b8e0281751b7bbeb995272e08dbbba6ec20f7a98a6fc8fce6bb86778793f7b1c
4
+ data.tar.gz: 14550791b8b22b8b7a5f919c842d25bfab891ca790bd20affceec37291e6d09d
5
5
  SHA512:
6
- metadata.gz: eafdd5b92b00b977289ceff26e10ea033ab28b10c0482a75ef0f751ff877f1996ba00ce8a5dbbdf6e59eb6b7301c6ee6130be6b50b6020728b4ab992b8fd5a75
7
- data.tar.gz: e3e32c3604b216b1e3b7f5b6c5a8e43f366dcd5c3bf3cf8317029d1412fc374a8f14b92b0bdcb621785e05df734a6c3d8f28e522027ec66e289f74ba8859f937
6
+ metadata.gz: d0f0e475e4d86437e4d3ffc27cf3df26ec91ec6ad338160284bc69d4d9db77597b92ba63f5b1fb4b149d9ad6dd51cfabdef425dc58af7720c1d3bea0545c5a1f
7
+ data.tar.gz: 7f38decb372c600c7e77ad25a99dadb13768dc93f8bb28b18a3703b561d957a883a5f76c1c1f869344c6a0356d2cfc80ed7de8dc17a5012e00c578165a503ca0
data/CHANGELOG.md CHANGED
@@ -16,3 +16,6 @@
16
16
 
17
17
  # 0.4.3
18
18
  - Update to new Sequel API (fixes #21)
19
+
20
+ # 0.4.4
21
+ - InfluxDB support added
@@ -16,6 +16,7 @@ class SQA
16
16
  sleep INFLIGHT_WAIT
17
17
  records = records.all
18
18
  @graphite.add @db.id_range(first_id, @db_id_seen).all if @graphite
19
+ @influxdb.add @db.id_range(first_id, @db_id_seen).all if @influxdb
19
20
  @buffer.push records.map { |record| record.peer }
20
21
  @buffer.exceed_median? ? @alarm.set(@buffer) : @alarm.clear(@buffer)
21
22
  delay = INTERVAL-(Time.now-start)
@@ -41,6 +42,7 @@ class SQA
41
42
  @buffer = AnalyzeBuffer.new @nodes.all.size
42
43
  @db_id_seen = 0
43
44
  @graphite = graphite if CFG.graphite?
45
+ @influxdb = influxdb if CFG.influxdb?
44
46
  end
45
47
 
46
48
  def graphite
@@ -48,6 +50,12 @@ class SQA
48
50
  Graphite.new @nodes
49
51
  end
50
52
 
53
+ def influxdb
54
+ require_relative 'influxdb'
55
+ InfluxDBWriter.new @nodes
56
+ end
57
+
58
+
51
59
  end
52
60
 
53
61
  class AnalyzeBuffer
@@ -18,7 +18,11 @@ class SQA
18
18
  if record.result != 'no response'
19
19
  hash["#{ROOT}.#{host}.#{nodecc}.#{nodename}.latency"] = record.latency
20
20
  end
21
- @client.metrics hash, record.time
21
+ begin
22
+ @client.metrics hash, record.time
23
+ rescue
24
+ Log.error "Failed to write metrics to Graphite."
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -0,0 +1,44 @@
1
+ require 'influxdb-client'
2
+
3
+ module Ring
4
+ class SQA
5
+ class InfluxDBWriter
6
+ ROOT = "nlnog.ring_sqa.#{CFG.afi}"
7
+
8
+ def add(records)
9
+ host = @hostname.split(".").first
10
+ node = @nodes.all
11
+ data = []
12
+
13
+ records.each do |record|
14
+ nodename = nodecc = node[record.peer][:name].split(".").first
15
+ nodecc = node[record.peer][:cc].downcase
16
+
17
+ point = InfluxDB2::Point.new(name: 'ring-sqa_measurements')
18
+ .add_tag('afi', CFG.afi)
19
+ .add_tag('dst_node', nodename)
20
+ .add_tag('dst_cc', nodecc)
21
+ .add_tag('src_node', host)
22
+ .add_tag('dst_lat', node[record.peer][:geo].split(",")[0])
23
+ .add_tag('dst_lon', node[record.peer][:geo].split(",")[1])
24
+ .add_field('latency', record.latency)
25
+ .add_field('state', record.result == 'no response' ? 0 : 1)
26
+
27
+ @write_api.write(data: point)
28
+ rescue => e
29
+ Log.error "Failed to write metrics to InfluxDB: #{e.message}"
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def initialize(nodes)
36
+ @client = InfluxDB2::Client.new(CFG.influxdb.url, CFG.influxdb.token, bucket: CFG.influxdb.bucket, org: CFG.influxdb.org, use_ssl: false, precision: InfluxDB2::WritePrecision::NANOSECOND)
37
+ @write_api = @client.create_write_api # ✅ Fix write_api issue
38
+ @hostname = Ring::SQA::CFG.host.name
39
+ @nodes = nodes
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -63,6 +63,7 @@ class SQA
63
63
  ip: ip,
64
64
  as: json['asn'],
65
65
  cc: json['countrycode'],
66
+ geo: json['geo'],
66
67
  }
67
68
  next if CFG.host.name == node[:name]
68
69
  nodes[ip] = node
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.4.3'
3
+ s.version = '0.4.4'
4
4
  s.licenses = %w( Apache-2.0 )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti', 'Job Snijders' ]
@@ -13,11 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.executables = %w( ring-sqad )
14
14
  s.require_path = 'lib'
15
15
 
16
- s.required_ruby_version = '>= 1.9.3'
17
- s.add_runtime_dependency 'slop', '~> 3.5'
18
- s.add_runtime_dependency 'rb-inotify', '~> 0.9'
19
- s.add_runtime_dependency 'sequel', '~> 4.12'
20
- s.add_runtime_dependency 'sqlite3', '~> 1.3'
21
- s.add_runtime_dependency 'asetus', '~> 0.1', '>= 0.1.2'
22
- s.add_runtime_dependency 'graphite-api', '~> 0.1', '>= 0.1.6'
16
+ s.required_ruby_version = '>= 1.9.3'
17
+ s.add_runtime_dependency 'slop', '~> 3.5'
18
+ s.add_runtime_dependency 'rb-inotify', '~> 0.9'
19
+ s.add_runtime_dependency 'sequel', '~> 4.12'
20
+ s.add_runtime_dependency 'sqlite3', '~> 1.3'
21
+ s.add_runtime_dependency 'asetus', '~> 0.3'
22
+ s.add_runtime_dependency 'graphite-api', '~> 0.1.0'
23
+ s.add_runtime_dependency 'influxdb-client', '>= 0.1', '<= 3.2.0'
23
24
  end
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.3
4
+ version: 0.4.4
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: 2019-10-09 00:00:00.000000000 Z
12
+ date: 2025-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
@@ -73,40 +73,48 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.1'
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: 0.1.2
76
+ version: '0.3'
80
77
  type: :runtime
81
78
  prerelease: false
82
79
  version_requirements: !ruby/object:Gem::Requirement
83
80
  requirements:
84
81
  - - "~>"
85
82
  - !ruby/object:Gem::Version
86
- version: '0.1'
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 0.1.2
83
+ version: '0.3'
90
84
  - !ruby/object:Gem::Dependency
91
85
  name: graphite-api
92
86
  requirement: !ruby/object:Gem::Requirement
93
87
  requirements:
94
88
  - - "~>"
95
89
  - !ruby/object:Gem::Version
96
- version: '0.1'
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: 0.1.6
90
+ version: 0.1.0
100
91
  type: :runtime
101
92
  prerelease: false
102
93
  version_requirements: !ruby/object:Gem::Requirement
103
94
  requirements:
104
95
  - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.1.0
98
+ - !ruby/object:Gem::Dependency
99
+ name: influxdb-client
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
105
103
  - !ruby/object:Gem::Version
106
104
  version: '0.1'
105
+ - - "<="
106
+ - !ruby/object:Gem::Version
107
+ version: 3.2.0
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
107
112
  - - ">="
108
113
  - !ruby/object:Gem::Version
109
- version: 0.1.6
114
+ version: '0.1'
115
+ - - "<="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.2.0
110
118
  description: gets list of nodes and pings from each to each storing results
111
119
  email:
112
120
  - saku@ytti.fi
@@ -136,6 +144,7 @@ files:
136
144
  - lib/ring/sqa/database.rb
137
145
  - lib/ring/sqa/database/model.rb
138
146
  - lib/ring/sqa/graphite.rb
147
+ - lib/ring/sqa/influxdb.rb
139
148
  - lib/ring/sqa/log.rb
140
149
  - lib/ring/sqa/mtr.rb
141
150
  - lib/ring/sqa/nodes.rb
@@ -164,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
173
  - !ruby/object:Gem::Version
165
174
  version: '0'
166
175
  requirements: []
167
- rubyforge_project: ring-sqa
168
- rubygems_version: 2.5.2
176
+ rubygems_version: 3.0.3.1
169
177
  signing_key:
170
178
  specification_version: 4
171
179
  summary: NLNOG Ring SQA