mtr_monitor 0.12.0 → 0.13.0

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: c561c98cc044312a97c61aa2b9db5f7cf15a26a1
4
- data.tar.gz: ed9268b1a5cf09a5b76ce641f600ce12e2bd3ede
3
+ metadata.gz: 313e99208d4a3e22b39fed0cceae8fac9bec34e6
4
+ data.tar.gz: 0c214d66e760aa1833917ae0940b0366cea67a3f
5
5
  SHA512:
6
- metadata.gz: a3675b8322277a60641263280029a66013aff8e7e31cfdd5f81debcb575deb9305c3bc9293716aa11ba28efa8f55a29a08a66da68db165d67499e5a428c7995b
7
- data.tar.gz: 772989cc12984c01892d095a859fc8b8529eca45853f7a3bb3686bb27a7f69abe25ea28c138989b772e005d0ae92db5867ad30d2255f7c0e6a2ce67b23155bc1
6
+ metadata.gz: d426393820a1028e0c6be7a7a3642a14776fe059c8f1f9a49b51b8dc9eaf14493567bf404aeaf5f14c0aa8b6b76715b417069cfe01956cb4372c1792d65ae1af
7
+ data.tar.gz: a601410b5568d9d84b997c5ead41ec99d73cd03765920fcf921e41e430af2108a1a0e99f6a6008b99cfcd70c98409a14ac01c2ff54783af97f911a2fe09447bd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mtr_monitor (0.12.0)
4
+ mtr_monitor (0.13.0)
5
5
  rt-watchman (~> 0.10.0)
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -18,6 +18,7 @@ task :deploy do
18
18
  --name mtr-monitor \
19
19
  --hostname "#{server}" \
20
20
  -v /var/log/mtr:/var/log/mtr \
21
+ -e DIG_IP_ADDRESS="#{ENV['DIG_IP_ADDRESS']}" \
21
22
  -e WATCHMAN_HOST="#{ENV['WATCHMAN_HOST']}" \
22
23
  -e NAME="#{ENV['NAME']}" \
23
24
  -e DOMAIN="#{ENV['DOMAIN']}" \
data/exe/mtr_report CHANGED
@@ -15,6 +15,7 @@ aws_access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID")
15
15
  aws_secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY")
16
16
  mtr_options = ENV.fetch("MTR_OPTIONS", "")
17
17
  sleep_time = ENV.fetch("SLEEP_TIME", "5").to_i
18
+ dig_ip_address = ENV.fetch("DIG_IP_ADDRESS", nil)
18
19
 
19
20
  Watchman.host = ENV.fetch("WATCHMAN_HOST")
20
21
  Watchman.port = ENV.fetch("WATCHMAN_PORT", 8125).to_i
@@ -27,6 +28,7 @@ loop do
27
28
  mtr_options,
28
29
  aws_access_key_id,
29
30
  aws_secret_access_key,
31
+ dig_ip_address,
30
32
  logger)
31
33
 
32
34
  logger.info "Generating report"
@@ -1,3 +1,3 @@
1
1
  module MtrMonitor
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/lib/mtr_monitor.rb CHANGED
@@ -20,7 +20,7 @@ module MtrMonitor
20
20
  attr_reader :logger
21
21
  attr_reader :host_ip_address
22
22
 
23
- def initialize(name, domain, s3_bucket, mtr_options, aws_access_key_id, aws_secret_access_key, logger = nil)
23
+ def initialize(name, domain, s3_bucket, mtr_options, aws_access_key_id, aws_secret_access_key, dig_ip_address, logger = nil)
24
24
  @name = name
25
25
  @domain = domain
26
26
  @s3_bucket = s3_bucket
@@ -29,6 +29,7 @@ module MtrMonitor
29
29
  @mtr_options = mtr_options
30
30
  @host_ip_address = `curl http://ifconfig.co`.strip.gsub(".", "-")
31
31
  @hostname = `hostname`.strip.gsub(".", "-")
32
+ @dig_ip_address = dig_ip_address
32
33
  @logger = logger || Logger.new(STDOUT)
33
34
 
34
35
  @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{@host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
@@ -47,24 +48,30 @@ module MtrMonitor
47
48
  end
48
49
 
49
50
  def generate_local_report
51
+ destination = @dig_ip_address ? dig : @domain
52
+
50
53
  run %Q(sudo mkdir -p /var/log/mtr)
51
54
  run %Q(sudo sh -c 'echo "Name: #{@name}" >> #{@log_path}')
52
55
  run %Q(sudo sh -c 'echo "Domain: #{@domain}" >> #{@log_path}')
53
56
  run %Q(sudo sh -c 'echo "Source IP: #{@host_ip_address}" >> #{@log_path}')
54
- run %Q(sudo sh -c 'echo "Target IP: #{@target_ip}" >> #{@log_path}')
57
+ run %Q(sudo sh -c 'echo "Target IP: #{destination}" >> #{@log_path}')
55
58
  run %Q(sudo sh -c 'echo "---------------------------------------" >> #{@log_path}')
56
- run %Q(sudo sh -c 'mtr --report #{@mtr_options} #{@domain} >> #{@log_path}')
59
+ run %Q(sudo sh -c 'mtr --report #{@mtr_options} #{destination} >> #{@log_path}')
57
60
  end
58
61
 
59
62
  def upload_to_s3
60
63
  run %Q(AWS_ACCESS_KEY_ID='#{@aws_access_key_id}' AWS_SECRET_ACCESS_KEY='#{@aws_secret_access_key}' aws s3 cp #{@log_path} #{@s3_path})
61
64
  end
62
65
 
66
+ def dig
67
+ logger.info "Dig #{@domain} IP address"
68
+ run("dig +short #{@domain}").split("\n").first
69
+ end
70
+
63
71
  def run(cmd)
64
72
  logger.info "Running: #{cmd}"
65
73
 
66
74
  `#{cmd}`
67
75
  end
68
76
  end
69
-
70
77
  end
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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RenderedText DevOps Team