mtr_monitor 0.5.4 → 0.9.9

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: 92fd8474c303a47832df58c0e42882ea691e3ed8
4
- data.tar.gz: b25e2265fb85fb8ba2e2c94cf87d89b9efc1e4fa
3
+ metadata.gz: 91b53ce8ac5bb956e5ea9e42f90cd9a446d22be7
4
+ data.tar.gz: 53166733f7d76fe2be5ce76fca2b480c64dc7697
5
5
  SHA512:
6
- metadata.gz: 16966ca4a380502bbba35277e6000f4dee30e286222f89bbc76610d42eee20baf0b6beccc5187f038e682ee77bb8f3733fa909556a23968333263682d922ce41
7
- data.tar.gz: e33d5400124b160f54c64c1e2ca5e47c7515ce1deb6fbff648774e9aafeb6a3152ef1bb1c889d67dce870ddac4f25155af10efabee06576bfa3084db0523876d
6
+ metadata.gz: bf94120283fa6d17e06996c8004497e671b42f49ba389b4735cde5aa1da1e1f5d738c84e4e7b0447ede38065b0e463fa9eb4cf2f4ee135412818fb9cd5cbcfd8
7
+ data.tar.gz: cd653d78dc67a762e6cf955874a7c7bc41f3091347d03ec1f7846cf9d62f1edfba70caea9b1474fbd20460ca1479e86b480f72e0f9c51ebc58a1ded2c1408c7d
data/Dockerfile CHANGED
@@ -1,9 +1,8 @@
1
1
  FROM ubuntu:14.04
2
2
 
3
- RUN apt-get update && apt-get install -y mtr ruby python-pip
3
+ RUN apt-get update && apt-get install -y curl mtr ruby python-pip
4
4
 
5
- RUN pip install awscli --upgrade --user
6
- RUN echo "export PATH=~/.local/bin:\$PATH" >> ~/.bashrc
5
+ RUN pip install awscli
7
6
 
8
7
  RUN gem install mtr_monitor
9
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mtr_monitor (0.5.4)
4
+ mtr_monitor (0.9.9)
5
5
  rt-watchman (~> 0.10.0)
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -4,3 +4,31 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ desc "Deploys mtr-monitor to servers"
9
+ task :deploy do
10
+ server = ENV.fetch("SERVER")
11
+
12
+ output =
13
+ `ssh -o StrictHostKeychecking=no ubuntu@#{server} <<'ENDSSH'
14
+ docker stop mtr-monitor || true
15
+ docker rm mtr-monitor || true
16
+ docker pull renderedtext/mtr-monitor
17
+ docker run -d \
18
+ --name mtr-monitor \
19
+ --hostname "#{server}" \
20
+ -v /var/log/mtr:/var/log/mtr \
21
+ -e WATCHMAN_HOST="#{ENV['WATCHMAN_HOST']}" \
22
+ -e NAME="#{ENV['NAME']}" \
23
+ -e DOMAIN="#{ENV['DOMAIN']}" \
24
+ -e MTR_OPTIONS="#{ENV['MTR_OPTIONS']}" \
25
+ -e S3_BUCKET="#{ENV['S3_BUCKET']}" \
26
+ -e AWS_ACCESS_KEY_ID="#{ENV['AWS_ACCESS_KEY_ID']}" \
27
+ -e AWS_SECRET_ACCESS_KEY="#{ENV['AWS_SECRET_ACCESS_KEY']}" \
28
+ -e SLEEP_TIME="#{ENV['SLEEP_TIME']}" \
29
+ renderedtext/mtr-monitor
30
+ ENDSSH`
31
+
32
+ puts output
33
+ exit 1 if $?.exitstatus != 0
34
+ end
data/exe/mtr_report CHANGED
@@ -13,6 +13,10 @@ aws_secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY")
13
13
  mtr_options = ENV.fetch("MTR_OPTIONS", "")
14
14
  sleep_time = ENV.fetch("SLEEP_TIME", "5").to_i
15
15
 
16
+ Watchman.host = ENV.fetch("WATCHMAN_HOST")
17
+ Watchman.port = ENV.fetch("WATCHMAN_PORT", 8125).to_i
18
+ Watchman.prefix = "mtr-monitor.prod"
19
+
16
20
  loop do
17
21
  report = MtrMonitor::Report.new(name,
18
22
  domain,
@@ -1,3 +1,3 @@
1
1
  module MtrMonitor
2
- VERSION = "0.5.4"
2
+ VERSION = "0.9.9"
3
3
  end
data/lib/mtr_monitor.rb CHANGED
@@ -7,16 +7,19 @@ module MtrMonitor
7
7
  # to /var/log/mtr/<domain>_timestamp.log , uploads to s3 and reports metrics to statsd.
8
8
  #
9
9
  class Report
10
+ attr_reader :log_path
10
11
 
11
12
  def initialize(name, domain, s3_bucket, mtr_options, aws_access_key_id, aws_secret_access_key)
12
- @name = name
13
- @domain = domain
14
- @s3_bucket = s3_bucket
15
- @aws_access_key_id = aws_access_key_id
13
+ @name = name
14
+ @domain = domain
15
+ @s3_bucket = s3_bucket
16
+ @aws_access_key_id = aws_access_key_id
16
17
  @aws_secret_access_key = aws_secret_access_key
17
- @mtr_options = mtr_options
18
+ @mtr_options = mtr_options
19
+ @host_ip_address = `curl http://ifconfig.co`.strip.gsub(".", "-")
20
+ @hostname = `hostname`.strip.gsub(".", "-")
18
21
 
19
- @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
22
+ @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{@host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
20
23
  @log_path = "/var/log/mtr/#{@log_name.gsub("/", "-")}"
21
24
  @s3_path = "s3://#{@s3_bucket}/#{@log_name}"
22
25
  end
@@ -31,9 +34,11 @@ module MtrMonitor
31
34
  end
32
35
 
33
36
  def submit_metrics
37
+ Watchman.submit("network.mtr.pulse", 1, :gauge, :tags => [@hostname, @name])
38
+
34
39
  hops.each do |hop|
35
40
  hop_name = hop.name.gsub(".", "-").gsub("?", "q")
36
- tags = [`hostname`.strip, @name, hop_name]
41
+ tags = [@hostname, @name, hop_name]
37
42
 
38
43
  Watchman.submit("network.mtr.loss", hop.loss, :gauge, :tags => tags)
39
44
  Watchman.submit("network.mtr.snt", hop.snt, :gauge, :tags => tags)
@@ -49,14 +54,6 @@ module MtrMonitor
49
54
  `sudo cat #{@log_path}`.split("\n").map { |line| Hop.parse(line) }.compact
50
55
  end
51
56
 
52
- def host_ip_address
53
- `/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1`.strip.gsub(".", "-")
54
- end
55
-
56
- def log_path
57
- @log_path
58
- end
59
-
60
57
  def run(cmd)
61
58
  `#{cmd}`
62
59
  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.5.4
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - RenderedText DevOps Team