mtr_monitor 0.17.4 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/mtr_monitor.rb +40 -23
- data/lib/mtr_monitor/cleaner.rb +1 -1
- data/lib/mtr_monitor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a26972975a867e9e8a9510dfd32b4e24991e6c85
|
4
|
+
data.tar.gz: dea7489cce159ab1ed20271d726902b362d9f53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c6d4c4f74ef30563a2892a0ce89b5376bf4bf13e550ea72d85081585ecf54613b1c42cc3484afd66397bf469e077e550ce655c3403f872fc251c8410c54c474
|
7
|
+
data.tar.gz: d758aca42f697617530f62c0433b556109aea48ba06b5744da05945aecb8e7018dec98c9ca8b82bc5d8dfa4752e69397810b3d230e3cb2346d38603e4b4dca2a
|
data/Gemfile.lock
CHANGED
data/lib/mtr_monitor.rb
CHANGED
@@ -23,7 +23,7 @@ module MtrMonitor
|
|
23
23
|
# MTR Options: Options to pass to the mtr command line tool.
|
24
24
|
#
|
25
25
|
|
26
|
-
|
26
|
+
LOCAL_REPORTS_DIR = "/var/log/mtr"
|
27
27
|
|
28
28
|
class Report
|
29
29
|
attr_reader :log_path
|
@@ -43,30 +43,44 @@ module MtrMonitor
|
|
43
43
|
@dig_ip_address = dig_ip_address
|
44
44
|
@logger = logger || Logger.new(STDOUT)
|
45
45
|
@logdna = Logdna::Ruby.new(logdna_ingestion_key,
|
46
|
-
:ip
|
47
|
-
:app
|
48
|
-
:meta
|
46
|
+
:ip => @host_ip_address,
|
47
|
+
:app => "MTR monitor",
|
48
|
+
:meta => {
|
49
|
+
:route => @name,
|
50
|
+
:s3 => s3_url
|
51
|
+
},
|
49
52
|
:level => "DEBUG")
|
53
|
+
end
|
50
54
|
|
51
|
-
|
55
|
+
def s3_url
|
56
|
+
"https://s3.eu-central-1.amazonaws.com/#{@bucket}/#{path}"
|
57
|
+
end
|
52
58
|
|
53
|
-
|
54
|
-
|
59
|
+
def s3_uri
|
60
|
+
"s3://#{@s3_bucket}/#{path}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def local_log_path
|
64
|
+
"#{MtrMonitor::LOCAL_REPORTS_DIR}/#{path.gsub("/", "-")}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def path
|
68
|
+
"#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{@host_ip_address.gsub(".", "-")}/#{Time.now.utc.strftime("%H-%M")}.log"
|
55
69
|
end
|
56
70
|
|
57
71
|
def generate
|
58
|
-
logger.info "Local Path: #{
|
59
|
-
logger.info "S3
|
72
|
+
logger.info "Local Path: #{local_log_path}"
|
73
|
+
logger.info "S3 URI: #{s3_uri}"
|
60
74
|
|
61
75
|
generate_local_report
|
62
76
|
upload_to_s3
|
63
77
|
emit_provider_to_logdna
|
64
78
|
|
65
|
-
MtrMonitor::Metrics.submit(
|
79
|
+
MtrMonitor::Metrics.submit(local_log_path, @hostname, @name, @logger)
|
66
80
|
end
|
67
81
|
|
68
82
|
def emit_provider_to_logdna
|
69
|
-
mtr_log = File.read(
|
83
|
+
mtr_log = File.read(local_log_path)
|
70
84
|
|
71
85
|
if mtr_log.include?("telia.net")
|
72
86
|
telia
|
@@ -80,17 +94,17 @@ module MtrMonitor
|
|
80
94
|
end
|
81
95
|
|
82
96
|
def telia
|
83
|
-
@logdna.log("Telia
|
97
|
+
@logdna.log("Telia")
|
84
98
|
@logger.info("Network provider: Telia -- Emitted to LogDNA")
|
85
99
|
end
|
86
100
|
|
87
101
|
def gtt
|
88
|
-
@logdna.log("GTT
|
102
|
+
@logdna.log("GTT")
|
89
103
|
@logger.info("Network provider: GTT -- Emitted to LogDNA")
|
90
104
|
end
|
91
105
|
|
92
106
|
def ntt
|
93
|
-
@logdna.log("NTT
|
107
|
+
@logdna.log("NTT")
|
94
108
|
@logger.info("Network provider: NTT -- Emitted to LogDNA")
|
95
109
|
end
|
96
110
|
|
@@ -100,19 +114,22 @@ module MtrMonitor
|
|
100
114
|
end
|
101
115
|
|
102
116
|
def generate_local_report
|
103
|
-
destination = @dig_ip_address ? dig : @domain
|
104
|
-
|
105
117
|
run %Q(sudo mkdir -p /var/log/mtr)
|
106
|
-
run %Q(sudo sh -c 'echo "
|
107
|
-
run %Q(sudo sh -c 'echo "
|
108
|
-
run %Q(sudo sh -c 'echo "
|
109
|
-
run %Q(sudo sh -c 'echo "
|
110
|
-
run %Q(sudo sh -c 'echo "
|
111
|
-
run %Q(sudo sh -c '
|
118
|
+
run %Q(sudo sh -c 'echo "Version: #{MtrMonitor::VERSION}" >> #{local_log_path}')
|
119
|
+
run %Q(sudo sh -c 'echo "Name: #{@name}" >> #{local_log_path}')
|
120
|
+
run %Q(sudo sh -c 'echo "Domain: #{@domain}" >> #{local_log_path}')
|
121
|
+
run %Q(sudo sh -c 'echo "Source IP: #{@host_ip_address}" >> #{local_log_path}')
|
122
|
+
run %Q(sudo sh -c 'echo "Target IP: #{destination}" >> #{local_log_path}')
|
123
|
+
run %Q(sudo sh -c 'echo "---------------------------------------" >> #{local_log_path}')
|
124
|
+
run %Q(sudo sh -c 'mtr --report --report-wide #{@mtr_options} #{destination} >> #{local_log_path}')
|
125
|
+
end
|
126
|
+
|
127
|
+
def destination
|
128
|
+
@dig_ip_address ? dig : @domain
|
112
129
|
end
|
113
130
|
|
114
131
|
def upload_to_s3
|
115
|
-
run %Q(AWS_ACCESS_KEY_ID='#{@aws_access_key_id}' AWS_SECRET_ACCESS_KEY='#{@aws_secret_access_key}' aws s3 cp #{
|
132
|
+
run %Q(AWS_ACCESS_KEY_ID='#{@aws_access_key_id}' AWS_SECRET_ACCESS_KEY='#{@aws_secret_access_key}' aws s3 cp #{local_log_path} #{s3_uri})
|
116
133
|
end
|
117
134
|
|
118
135
|
def dig
|
data/lib/mtr_monitor/cleaner.rb
CHANGED
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.
|
4
|
+
version: 0.18.0
|
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: 2018-01-
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logdna
|