mtr_monitor 0.10.1 → 0.10.2
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/Gemfile.lock +1 -1
- data/lib/mtr_monitor.rb +5 -43
- data/lib/mtr_monitor/hop.rb +29 -0
- data/lib/mtr_monitor/metrics.rb +28 -0
- data/lib/mtr_monitor/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 606e6226743b91f553297bb2ce378204fb59b702
|
4
|
+
data.tar.gz: fb50ea80132d8e069c3a75b2ee46cd3a9e98b2d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9437bb036a217c3fccf18098aa0da668528e30e701f9f2d1e086ad9ad9a93c621292e932f211ba985c5c3c04e92eff914bec7821f9cf48b27188330529956b7
|
7
|
+
data.tar.gz: fdc09e9ba5718bc9d5119439ea6f8aa3560c886fd872569127e9c04a0d58bfdc8a752b25fa2f887b19067e32a675870eda139ad0b0db2eaedbc6599a0a53166e
|
data/Gemfile.lock
CHANGED
data/lib/mtr_monitor.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
require "mtr_monitor/version"
|
2
1
|
require "watchman"
|
3
2
|
require "logger"
|
4
3
|
|
4
|
+
require "mtr_monitor/version"
|
5
|
+
require "mtr_monitor/hop"
|
6
|
+
require "mtr_monitor/metrics"
|
7
|
+
|
5
8
|
module MtrMonitor
|
6
9
|
#
|
7
10
|
# Runs a mtr trace toward a domain and saves the report
|
@@ -34,28 +37,8 @@ module MtrMonitor
|
|
34
37
|
run "sudo mkdir -p /var/log/mtr"
|
35
38
|
run "sudo mtr --report #{@mtr_options} #{@domain} > #{@log_path}"
|
36
39
|
run "AWS_ACCESS_KEY_ID='#{@aws_access_key_id}' AWS_SECRET_ACCESS_KEY='#{@aws_secret_access_key}' aws s3 cp #{@log_path} #{@s3_path}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def submit_metrics
|
40
|
-
logger.info "Submitting pulse: network.mtr.pulse, tags: #{[@hostname, @name]}, prefix: #{Watchman.prefix} port: #{Watchman.port}"
|
41
|
-
Watchman.submit("network.mtr.pulse", 1, :gauge, :tags => [@hostname, @name])
|
42
|
-
|
43
|
-
hops.each do |hop|
|
44
|
-
hop_name = hop.name.gsub(".", "-").gsub("?", "q")
|
45
|
-
tags = [@hostname, @name, hop_name]
|
46
|
-
|
47
|
-
Watchman.submit("network.mtr.loss", hop.loss, :gauge, :tags => tags)
|
48
|
-
Watchman.submit("network.mtr.snt", hop.snt, :gauge, :tags => tags)
|
49
|
-
Watchman.submit("network.mtr.last", hop.last, :gauge, :tags => tags)
|
50
|
-
Watchman.submit("network.mtr.avg", hop.avg, :gauge, :tags => tags)
|
51
|
-
Watchman.submit("network.mtr.best", hop.best, :gauge, :tags => tags)
|
52
|
-
Watchman.submit("network.mtr.worst", hop.worst, :gauge, :tags => tags)
|
53
|
-
Watchman.submit("network.mtr.std_dev", hop.std_dev, :gauge, :tags => tags)
|
54
|
-
end
|
55
|
-
end
|
56
40
|
|
57
|
-
|
58
|
-
`sudo cat #{@log_path}`.split("\n").map { |line| Hop.parse(line) }.compact
|
41
|
+
MtrMonitor::Metrics.submit(@log_path, @hostname, @name, @logger)
|
59
42
|
end
|
60
43
|
|
61
44
|
def run(cmd)
|
@@ -65,25 +48,4 @@ module MtrMonitor
|
|
65
48
|
end
|
66
49
|
end
|
67
50
|
|
68
|
-
class Hop
|
69
|
-
def self.parse(line)
|
70
|
-
return unless line =~ /\|--/
|
71
|
-
|
72
|
-
new(*line.split(" ")[1..-1])
|
73
|
-
end
|
74
|
-
|
75
|
-
attr_reader :name, :loss, :snt, :last, :avg, :best, :worst, :std_dev
|
76
|
-
|
77
|
-
def initialize(name, loss, snt, last, avg, best, worst, std_dev)
|
78
|
-
@name = name
|
79
|
-
@loss = loss.to_f
|
80
|
-
@snt = snt.to_i
|
81
|
-
@last = last.to_f
|
82
|
-
@avg = avg.to_f
|
83
|
-
@best = best.to_f
|
84
|
-
@worst = worst.to_f
|
85
|
-
@std_dev = std_dev.to_f
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
51
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MtrMonitor
|
2
|
+
|
3
|
+
# represents one hop in the MTR report
|
4
|
+
#
|
5
|
+
# example hop for `mtr --report github.com`:
|
6
|
+
# 12.|-- github-ic-318125-ash-b1.c 0.0% 10 136.2 136.2 135.0 140.7 1.5
|
7
|
+
|
8
|
+
class Hop
|
9
|
+
def self.parse(line)
|
10
|
+
return unless line =~ /\|--/
|
11
|
+
|
12
|
+
new(*line.split(" ")[1..-1])
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :name, :loss, :snt, :last, :avg, :best, :worst, :std_dev
|
16
|
+
|
17
|
+
def initialize(name, loss, snt, last, avg, best, worst, std_dev)
|
18
|
+
@name = name
|
19
|
+
@loss = loss.to_f
|
20
|
+
@snt = snt.to_i
|
21
|
+
@last = last.to_f
|
22
|
+
@avg = avg.to_f
|
23
|
+
@best = best.to_f
|
24
|
+
@worst = worst.to_f
|
25
|
+
@std_dev = std_dev.to_f
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MtrMonitor
|
2
|
+
module Metrics
|
3
|
+
|
4
|
+
def self.submit(log_path, hostname, name, logger)
|
5
|
+
logger.info "Submitting pulse: network.mtr.pulse, tags: #{[hostname, name]}, prefix: #{Watchman.prefix} port: #{Watchman.port}"
|
6
|
+
|
7
|
+
Watchman.submit("network.mtr.pulse", 1, :gauge, :tags => [hostname, name])
|
8
|
+
|
9
|
+
hops(log_path).each do |hop|
|
10
|
+
hop_name = hop.name.gsub(".", "-").gsub("?", "q")
|
11
|
+
tags = [hostname, name, hop_name]
|
12
|
+
|
13
|
+
Watchman.submit("network.mtr.loss", hop.loss, :gauge, :tags => tags)
|
14
|
+
Watchman.submit("network.mtr.snt", hop.snt, :gauge, :tags => tags)
|
15
|
+
Watchman.submit("network.mtr.last", hop.last, :gauge, :tags => tags)
|
16
|
+
Watchman.submit("network.mtr.avg", hop.avg, :gauge, :tags => tags)
|
17
|
+
Watchman.submit("network.mtr.best", hop.best, :gauge, :tags => tags)
|
18
|
+
Watchman.submit("network.mtr.worst", hop.worst, :gauge, :tags => tags)
|
19
|
+
Watchman.submit("network.mtr.std_dev", hop.std_dev, :gauge, :tags => tags)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.hops(log_path)
|
24
|
+
`sudo cat #{log_path}`.split("\n").map { |line| Hop.parse(line) }.compact
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/mtr_monitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtr_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RenderedText DevOps Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rt-watchman
|
@@ -88,6 +88,8 @@ files:
|
|
88
88
|
- docker-compose.yml
|
89
89
|
- exe/mtr_report
|
90
90
|
- lib/mtr_monitor.rb
|
91
|
+
- lib/mtr_monitor/hop.rb
|
92
|
+
- lib/mtr_monitor/metrics.rb
|
91
93
|
- lib/mtr_monitor/version.rb
|
92
94
|
- mtr_monitor.gemspec
|
93
95
|
homepage: https://github.com/renderedtext/mtr-monitor
|