mtr_monitor 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -18
- data/docker-compose.yml +5 -0
- data/exe/mtr_report +25 -37
- data/lib/mtr_monitor.rb +13 -4
- data/lib/mtr_monitor/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f4fc19a4c802efd3bc96fca5ca2f737c0147eb0
|
4
|
+
data.tar.gz: df11b7d5705fdc2a086702889bec29cf3bcc4c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb342e7429f1018777e1e98e1e198f31df57e084709f5229686da3937c94a28fb81a93766907c6a9485a7a2f25be2196a24cec23f7dc3462508b9248c64518f
|
7
|
+
data.tar.gz: 980bb3e934e45d20f729f47710f770e0f5ee8dacf4b14f7a5775ffb047257cf24f6f2874cec3874fc6a27b32371812ffe2b9250bef0639a3dee39477f86c2fc4
|
data/Dockerfile
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,34 +1,26 @@
|
|
1
1
|
# MtrMonitor
|
2
2
|
|
3
|
-
|
4
|
-
and collects statsd metrics.
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/renderedtext/mtr-monitor/branches/master/badge.svg)](https://semaphoreci.com/renderedtext/mtr-monitor)
|
5
4
|
|
6
|
-
## Installation
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
gem 'mtr_monitor'
|
12
|
-
```
|
6
|
+
Generates a MTR report, uploads the report to S3, and finally parses the report
|
7
|
+
and collects statsd metrics.
|
13
8
|
|
14
|
-
|
9
|
+
### Run mtr_monitor as a docker container
|
15
10
|
|
16
11
|
``` bash
|
17
|
-
|
12
|
+
docker run -d -v /var/log/mtr:/var/log/mtr -e NAME=<> -e DOMAIN=<> -e MTR_OPTIONS=<> -e S3_BUCKET=<> -e AWS_ACCESS_KEY_ID=<> -e AWS_SECRET_ACCESS_KEY=<> -e SLEEP_TIME=<> renderedtext/mtr_monitor
|
18
13
|
```
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
### Generate an MTR report from the CLI
|
15
|
+
### Generate an MTR report from Ruby
|
23
16
|
|
24
|
-
|
25
|
-
export AWS_ACCESS_KEY_ID=<XXX>
|
26
|
-
export AWS_SECRET_ACCESS_KEY=<YYY>
|
17
|
+
Install mtr_monitor as a gem:
|
27
18
|
|
28
|
-
|
19
|
+
```ruby
|
20
|
+
gem 'mtr_monitor'
|
29
21
|
```
|
30
22
|
|
31
|
-
|
23
|
+
Invoke mtr generation:
|
32
24
|
|
33
25
|
``` ruby
|
34
26
|
name = "google"
|
data/docker-compose.yml
ADDED
data/exe/mtr_report
CHANGED
@@ -1,41 +1,29 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "mtr_monitor"
|
4
|
-
require "optparse"
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
report = MtrMonitor::Report.new(name,
|
32
|
-
domain,
|
33
|
-
s3_bucket,
|
34
|
-
aws_access_key_id,
|
35
|
-
aws_secret_access_key)
|
36
|
-
|
37
|
-
puts "Generating report"
|
38
|
-
report.generate
|
39
|
-
|
40
|
-
puts "Submiting metrics"
|
41
|
-
report.submit_metrics
|
5
|
+
name = ENV.fetch("NAME")
|
6
|
+
domain = ENV.fetch("DOMAIN")
|
7
|
+
s3_bucket = ENV.fetch("S3_BUCKET")
|
8
|
+
aws_access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID")
|
9
|
+
aws_secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY")
|
10
|
+
mtr_options = ENV.fetch("MTR_OPTIONS", "")
|
11
|
+
sleep_time = ENV.fetch("SLEEP_TIME", "5").to_i
|
12
|
+
|
13
|
+
loop do
|
14
|
+
report = MtrMonitor::Report.new(name,
|
15
|
+
domain,
|
16
|
+
s3_bucket,
|
17
|
+
mtr_options,
|
18
|
+
aws_access_key_id,
|
19
|
+
aws_secret_access_key)
|
20
|
+
|
21
|
+
puts "Generating report"
|
22
|
+
report.generate
|
23
|
+
|
24
|
+
puts "Submiting metrics"
|
25
|
+
report.submit_metrics
|
26
|
+
|
27
|
+
puts "Sleeping for #{sleep_time} minutes"
|
28
|
+
sleep(sleep_time * 60)
|
29
|
+
end
|
data/lib/mtr_monitor.rb
CHANGED
@@ -8,12 +8,13 @@ module MtrMonitor
|
|
8
8
|
#
|
9
9
|
class Report
|
10
10
|
|
11
|
-
def initialize(name, domain, s3_bucket, aws_access_key_id, aws_secret_access_key)
|
11
|
+
def initialize(name, domain, s3_bucket, mtr_options, aws_access_key_id, aws_secret_access_key)
|
12
12
|
@name = name
|
13
13
|
@domain = domain
|
14
14
|
@s3_bucket = s3_bucket
|
15
15
|
@aws_access_key_id = aws_access_key_id
|
16
16
|
@aws_secret_access_key = aws_secret_access_key
|
17
|
+
@mtr_options = mtr_options
|
17
18
|
|
18
19
|
@log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
|
19
20
|
@log_path = "/var/log/mtr/#{@log_name.gsub("/", "-")}"
|
@@ -24,9 +25,9 @@ module MtrMonitor
|
|
24
25
|
puts "Local Path : #{@log_path}"
|
25
26
|
puts "S3 Path : #{@s3_path}"
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
run "sudo mkdir -p /var/log/mtr"
|
29
|
+
run "sudo sh -c 'mtr --report #{@mtr_options} #{@domain} > #{@log_path}'"
|
30
|
+
run "AWS_ACCESS_KEY_ID='#{@aws_access_key_id}' AWS_SECRET_ACCESS_KEY='#{@aws_secret_access_key}' aws s3 cp #{@log_path} #{@s3_path}"
|
30
31
|
end
|
31
32
|
|
32
33
|
def submit_metrics
|
@@ -51,6 +52,14 @@ module MtrMonitor
|
|
51
52
|
def host_ip_address
|
52
53
|
`/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1`.strip.gsub(".", "-")
|
53
54
|
end
|
55
|
+
|
56
|
+
def log_path
|
57
|
+
@log_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def run(cmd)
|
61
|
+
`#{cmd}`
|
62
|
+
end
|
54
63
|
end
|
55
64
|
|
56
65
|
class Hop
|
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.5.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: 2017-12-
|
11
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rt-watchman
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
79
|
- CODE_OF_CONDUCT.md
|
80
|
+
- Dockerfile
|
80
81
|
- Gemfile
|
81
82
|
- Gemfile.lock
|
82
83
|
- LICENSE.txt
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- Rakefile
|
85
86
|
- bin/console
|
86
87
|
- bin/setup
|
88
|
+
- docker-compose.yml
|
87
89
|
- exe/mtr_report
|
88
90
|
- lib/mtr_monitor.rb
|
89
91
|
- lib/mtr_monitor/version.rb
|
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
110
|
version: '0'
|
109
111
|
requirements: []
|
110
112
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.6.14
|
112
114
|
signing_key:
|
113
115
|
specification_version: 4
|
114
116
|
summary: Generate, parse, and collect MTR reports
|