mtr_monitor 0.3.0 → 0.4.0

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
2
  SHA1:
3
- metadata.gz: da110fa521f48a26244e927226377ee5694e0682
4
- data.tar.gz: 53a4f624724aee1c393966e4ee5da27f5f4e2deb
3
+ metadata.gz: b7c84d43ef8922804d7c968ef44e7e07ef2932d8
4
+ data.tar.gz: 42686ab91ceacd16256c2a2e4df95e28bfb8508a
5
5
  SHA512:
6
- metadata.gz: 5bb114fdcf143e637c1467b68fa70adc2be00cbba64f1018647dd627971b0e678a2fe032af0fe3316bb44e691514d97a966a53c338e7a5ef68244e6f7b0152c9
7
- data.tar.gz: 6658288209c3fd5d73c9cc11d2d2a3af46cde4ce3681f40dad523720c7fa30ce039d720b7fa1bce712a6e61840ba4d8ccc7415118a0484f07f10bc68f7c32dc7
6
+ metadata.gz: 635b63e1f77e8827b94a2036de0b52ad88474c9be644979af57f693f4ef0be2ad4ac36767212f048552910a08da48fa134ae16ffaf8b0549789296e4498aadcd
7
+ data.tar.gz: 5c086be79a78aba1059b01221242a39c43f4afff795ca03f75ab8aedb77604092068dfe5b8f125bd9caa54d13375430eb49a882c1026f98bf80465e674c4b5d0
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mtr_monitor (0.3.0)
4
+ mtr_monitor (0.4.0)
5
+ rt-watchman (~> 0.10.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -21,6 +22,9 @@ GEM
21
22
  diff-lcs (>= 1.2.0, < 2.0)
22
23
  rspec-support (~> 3.4.0)
23
24
  rspec-support (3.4.1)
25
+ rt-watchman (0.10.0)
26
+ statsd-ruby (~> 1.3.0)
27
+ statsd-ruby (1.3.0)
24
28
 
25
29
  PLATFORMS
26
30
  ruby
data/README.md CHANGED
@@ -17,17 +17,18 @@ Or install it on your system:
17
17
  gem install mtr_monitor
18
18
  ```
19
19
 
20
- ## Generate an MTR report from the CLI
20
+ ## Usage
21
+
22
+ ### Generate an MTR report from the CLI
21
23
 
22
24
  ``` bash
23
- export S3_BUCKET=<>
24
- export AWS_ACCESS_KEY_ID=<>
25
- export AWS_SECRET_ACCESS_KEY=<>
25
+ export AWS_ACCESS_KEY_ID=<XXX>
26
+ export AWS_SECRET_ACCESS_KEY=<YYY>
26
27
 
27
- mtr_report "google" "google.com"
28
+ mtr_report --name "test" --domain "google.com" --bucket "bucket-aaa"
28
29
  ```
29
30
 
30
- ## Generate an MTR report from Ruby
31
+ ### Generate an MTR report from Ruby
31
32
 
32
33
  ``` ruby
33
34
  name = "google"
@@ -1,11 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "mtr_monitor"
4
+ require "optparse"
4
5
 
5
- name = ARGV[0]
6
- domain = ARGC[1]
6
+ options = {}
7
+
8
+ OptionParser.new do |opts|
9
+
10
+ opts.on("--domain [DOMAIN]", "Domain to Test") do |domain|
11
+ options[:domain] = domain
12
+ end
13
+
14
+ opts.on("--name [NAME]", "Name of the Report") do |name|
15
+ options[:name] = name
16
+ end
17
+
18
+ opts.on("--bucket [BUCKET]", "Name of the S3 Bucket") do |bucket|
19
+ options[:bucket] = bucket
20
+ end
21
+
22
+ end.parse!
23
+
24
+ name = options.fetch(:name)
25
+ domain = options.fetch(:domain)
26
+ s3_bucket = options.fetch(:bucket)
7
27
 
8
- s3_bucket = ENV["S3_BUCKET"]
9
28
  aws_access_key_id = ENV["AWS_ACCESS_KEY_ID"]
10
29
  aws_secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
11
30
 
@@ -1,4 +1,5 @@
1
1
  require "mtr_monitor/version"
2
+ require "watchman"
2
3
 
3
4
  module MtrMonitor
4
5
  #
@@ -14,7 +15,7 @@ module MtrMonitor
14
15
  @aws_access_key_id = aws_access_key_id
15
16
  @aws_secret_access_key = aws_secret_access_key
16
17
 
17
- @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{@host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
18
+ @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
18
19
  @log_path = "/var/log/mtr/#{@log_name.gsub("/", "-")}"
19
20
  @s3_path = "s3://#{@s3_bucket}/#{@log_name}"
20
21
  end
@@ -29,9 +30,7 @@ module MtrMonitor
29
30
  end
30
31
 
31
32
  def submit_metrics
32
- report = `sudo cat #{@log_path}`
33
-
34
- Mtr.parse(report).each do |hop|
33
+ hops.each do |hop|
35
34
  hop_name = hop.name.gsub(".", "-").gsub("?", "q")
36
35
  tags = [`hostname`.strip, @name, hop_name]
37
36
 
@@ -45,8 +44,8 @@ module MtrMonitor
45
44
  end
46
45
  end
47
46
 
48
- def self.parse(report)
49
- report.split("\n").map { |line| Hop.parse(line) }.compact
47
+ def hops
48
+ `sudo cat #{@log_path}`.split("\n").map { |line| Hop.parse(line) }.compact
50
49
  end
51
50
 
52
51
  def host_ip_address
@@ -1,3 +1,3 @@
1
1
  module MtrMonitor
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "mtr_monitor/version"
@@ -20,6 +19,8 @@ Gem::Specification.new do |spec|
20
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
20
  spec.require_paths = ["lib"]
22
21
 
22
+ spec.add_dependency "rt-watchman", "~> 0.10.0"
23
+
23
24
  spec.add_development_dependency "bundler", "~> 1.16"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
25
26
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtr_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RenderedText DevOps Team
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rt-watchman
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement