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 +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/exe/mtr_report +2 -0
- data/lib/mtr_monitor/version.rb +1 -1
- data/lib/mtr_monitor.rb +11 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 313e99208d4a3e22b39fed0cceae8fac9bec34e6
|
4
|
+
data.tar.gz: 0c214d66e760aa1833917ae0940b0366cea67a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d426393820a1028e0c6be7a7a3642a14776fe059c8f1f9a49b51b8dc9eaf14493567bf404aeaf5f14c0aa8b6b76715b417069cfe01956cb4372c1792d65ae1af
|
7
|
+
data.tar.gz: a601410b5568d9d84b997c5ead41ec99d73cd03765920fcf921e41e430af2108a1a0e99f6a6008b99cfcd70c98409a14ac01c2ff54783af97f911a2fe09447bd
|
data/Gemfile.lock
CHANGED
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"
|
data/lib/mtr_monitor/version.rb
CHANGED
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: #{
|
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} #{
|
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
|