mtr_monitor 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 216fbb219b4e25dc96db100a8e3301567a7f35ca
4
- data.tar.gz: 0c868a8045186925f324d54ab9e734641d518193
3
+ metadata.gz: d7d1959c271eaaf0c608b691382a9312e0390c40
4
+ data.tar.gz: f42a91701e3bc65d6968cebf76fea2e0c648815d
5
5
  SHA512:
6
- metadata.gz: 8c36f4e0fcb3dc1542992bc661561ea13c2b8bc1172bf5feabe525382f62cbbd3f411197a08e54338be6bf64f0fad6ce121790619af0fe7abeea5bd2d5e46523
7
- data.tar.gz: 58114a469cd54fb63a7b8568367fc4355aaf2c5a39bfe5fea2c2ba6d650533ba09a24772a74c3e9d3b9b99abde00c1ee80a8748be1df18a41f6300b95e0bf49c
6
+ metadata.gz: dbb9814cd4ce652c631444690cd30f633c0e7585449267cb3ea5abddcc6f69d26ffb81f334b56ab61c58ea117a8bf7822c39d65f6527a4dd22746482051759a8
7
+ data.tar.gz: 01bef7c769e2dfa144b2eb1682b5fef0301aecbf969006c2038bfc8cad80ed91d4a8683edb043f738fd4ee4898584a50614482a087219e9e221d1a65cb467e01
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mtr_monitor (1.0.0)
4
+ mtr_monitor (1.0.1)
5
5
  logdna
6
6
  rt-watchman (~> 0.10.0)
7
7
 
data/Makefile CHANGED
@@ -22,7 +22,7 @@ http-endpoint-push: http-endpoint-build
22
22
  docker push renderedtext/mtr-nginx
23
23
 
24
24
  deploy-us-east-1:
25
- DIG_IP_ADDRESS=yes \
25
+ DIG_IP_ADDRESS=no \
26
26
  SLEEP_TIME=5 \
27
27
  NAME="us-east-1-to-hetzner" \
28
28
  SERVER="ec2.mtr-monitor.us-east-1.semaphoreci.com" \
@@ -32,7 +32,7 @@ deploy-us-east-1:
32
32
  bundle exec rake deploy
33
33
 
34
34
  deploy-us-west-1:
35
- DIG_IP_ADDRESS=yes \
35
+ DIG_IP_ADDRESS=no \
36
36
  SLEEP_TIME=5 \
37
37
  NAME="us-west-1-to-hetzner" \
38
38
  SERVER="ec2.mtr-monitor.us-west-1.semaphoreci.com" \
@@ -42,7 +42,7 @@ deploy-us-west-1:
42
42
  bundle exec rake deploy
43
43
 
44
44
  deploy-us-west-2:
45
- DIG_IP_ADDRESS=yes \
45
+ DIG_IP_ADDRESS=no \
46
46
  SLEEP_TIME=5 \
47
47
  NAME="us-west-2-to-hetzner" \
48
48
  SERVER="ec2.mtr-monitor.us-west-2.semaphoreci.com" \
data/docker-compose.yml CHANGED
@@ -8,7 +8,7 @@ services:
8
8
  - /var/log/mtr:/var/log/mtr
9
9
  environment:
10
10
  - LOGDNA_INGESTION_KEY
11
- - DOMAIN
11
+ - MTR_TARGET_DOMAIN
12
12
  - WATCHMAN_HOST
13
13
  - SLEEP_TIME
14
14
  - AWS_SECRET_ACCESS_KEY
@@ -0,0 +1,42 @@
1
+ module MtrMonitor
2
+ class Tier1Logger
3
+
4
+ def self.submit(*args)
5
+ new(*args).submit
6
+ end
7
+
8
+ def initialize(route_name, logdna_ingestion_key, host_ip_address, local_log_path, s3_url, logger)
9
+ config = {
10
+ :ip => host_ip_address,
11
+ :app => "MTR monitor",
12
+ :meta => { :route => route_name, :s3 => s3_url },
13
+ :level => "DEBUG"
14
+ }
15
+
16
+ @logdna = Logdna::Ruby.new(logdna_ingestion_key, config)
17
+ @mtr_log = File.read(local_log_path)
18
+ end
19
+
20
+ def submit
21
+ logdna.log(tier1_provider)
22
+ logger.info("Network provider: #{tier1_provider} -- Emitted to LogDNA")
23
+ end
24
+
25
+ private
26
+
27
+ def tier1_provider
28
+ @tier1_provider ||= if @mtr_log.include?("telia.net")
29
+ "Telia"
30
+ elsif @mtr_log.include?("gtt.net")
31
+ "GTT"
32
+ elsif @mtr_log.include?("ntt.net")
33
+ "NTT"
34
+ elsif @mtr_log.include?("core-backbone.com")
35
+ "Core Backbone"
36
+ else
37
+ "Unknown network provider"
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module MtrMonitor
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/mtr_monitor.rb CHANGED
@@ -5,6 +5,7 @@ require "logdna"
5
5
  require "mtr_monitor/version"
6
6
  require "mtr_monitor/hop"
7
7
  require "mtr_monitor/metrics"
8
+ require "mtr_monitor/tier1_logger"
8
9
  require "mtr_monitor/cleaner"
9
10
 
10
11
  module MtrMonitor
@@ -43,14 +44,6 @@ module MtrMonitor
43
44
  @dig_ip_address = dig_ip_address
44
45
  @logger = logger || Logger.new(STDOUT)
45
46
  @created_at = Time.now.utc
46
- @logdna = Logdna::Ruby.new(logdna_ingestion_key,
47
- :ip => @host_ip_address,
48
- :app => "MTR monitor",
49
- :meta => {
50
- :route => @name,
51
- :s3 => s3_url
52
- },
53
- :level => "DEBUG")
54
47
  end
55
48
 
56
49
  def s3_url
@@ -75,52 +68,11 @@ module MtrMonitor
75
68
 
76
69
  generate_local_report
77
70
  upload_to_s3
78
- emit_provider_to_logdna
79
71
 
72
+ MtrMonitor::Tier1Logger.submit(@name, @logdna_ingestion_key, local_log_path, @host_ip_address, s3_uri, @logger)
80
73
  MtrMonitor::Metrics.submit(local_log_path, @hostname, @name, @logger)
81
74
  end
82
75
 
83
- def emit_provider_to_logdna
84
- mtr_log = File.read(local_log_path)
85
-
86
- if mtr_log.include?("telia.net")
87
- telia
88
- elsif mtr_log.include?("gtt.net")
89
- gtt
90
- elsif mtr_log.include?("ntt.net")
91
- ntt
92
- elsif mtr_log.include?("core-backbone.com")
93
- core_backbone
94
- else
95
- unknown
96
- end
97
- end
98
-
99
- def telia
100
- @logdna.log("Telia")
101
- @logger.info("Network provider: Telia -- Emitted to LogDNA")
102
- end
103
-
104
- def gtt
105
- @logdna.log("GTT")
106
- @logger.info("Network provider: GTT -- Emitted to LogDNA")
107
- end
108
-
109
- def ntt
110
- @logdna.log("NTT")
111
- @logger.info("Network provider: NTT -- Emitted to LogDNA")
112
- end
113
-
114
- def core_backbone
115
- @logdna.log("Core Backbone")
116
- @logger.info("Network provider: Core Backbone -- Emitted to LogDNA")
117
- end
118
-
119
- def unknown
120
- @logdna.log("Unknown network provider ")
121
- @logger.info("Network provider: Unknown -- Emitted to LogDNA")
122
- end
123
-
124
76
  def generate_local_report
125
77
  run %Q(sudo mkdir -p /var/log/mtr)
126
78
  run %Q(sudo sh -c 'echo "Version: #{MtrMonitor::VERSION}" >> #{local_log_path}')
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RenderedText DevOps Team
@@ -111,6 +111,7 @@ files:
111
111
  - lib/mtr_monitor/cleaner.rb
112
112
  - lib/mtr_monitor/hop.rb
113
113
  - lib/mtr_monitor/metrics.rb
114
+ - lib/mtr_monitor/tier1_logger.rb
114
115
  - lib/mtr_monitor/version.rb
115
116
  - mtr_monitor.gemspec
116
117
  homepage: https://github.com/renderedtext/mtr-monitor