mtr_monitor 0.10.3 → 0.11.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: 2f12fdabab86bed8fb2fb0aa71a0f982c4233eb5
4
- data.tar.gz: 77fd11168473a7774b6bf6acf99fe06de0d98cec
3
+ metadata.gz: f243ceb197f20b9d5de15bf051212a8c5a77e435
4
+ data.tar.gz: 14228fd786c832de71a24e11ef3a21cf5b040665
5
5
  SHA512:
6
- metadata.gz: 6e4d5e4a13e759a8ef0e8a3afe02137478970661b5f43704fbcc8c4c119bbb5055deba549387b31ac86d4109206e7abe2523a4fd76d0f7e9cc675cc63327d0c8
7
- data.tar.gz: bc5ade1a28b27579d3ba9a1291d972071c28b0952b8123502aaa5caba9dea4d759867c4136763bedd965ce8046e418776e826853b4fdfd08de841b5557bd1ca4
6
+ metadata.gz: 12a84d0a0a2366827312408036b06588f336416041b9431c71faaaa81b7170ebad449873654caacc1024678460fddd775c2f8df5c9eb9e79ce0bbda1fffd821c
7
+ data.tar.gz: 8307dc83389ae67865afb23ecbe6af31ee66e77d95098258e47e24cd70bff854be44e5df29ba0e6c06a08c99c020ea5935fb8893f1b3477f0a0e298df8e90177
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mtr_monitor (0.10.3)
4
+ mtr_monitor (0.11.0)
5
5
  rt-watchman (~> 0.10.0)
6
6
 
7
7
  GEM
data/exe/mtr_report CHANGED
@@ -32,6 +32,9 @@ loop do
32
32
  logger.info "Generating report"
33
33
  report.generate
34
34
 
35
+ logger.info "Running Cleaner"
36
+ MtrMonitor::Cleaner.execute(logger)
37
+
35
38
  logger.info "Sleeping for #{sleep_time} minutes"
36
39
  sleep(sleep_time * 60)
37
40
  end
data/lib/mtr_monitor.rb CHANGED
@@ -4,12 +4,16 @@ require "logger"
4
4
  require "mtr_monitor/version"
5
5
  require "mtr_monitor/hop"
6
6
  require "mtr_monitor/metrics"
7
+ require "mtr_monitor/cleaner"
7
8
 
8
9
  module MtrMonitor
9
10
  #
10
11
  # Runs a mtr trace toward a domain and saves the report
11
12
  # to /var/log/mtr/<domain>_timestamp.log , uploads to s3 and reports metrics to statsd.
12
13
  #
14
+
15
+ REPORTS_PATH = "/var/log/mtr"
16
+
13
17
  class Report
14
18
  attr_reader :log_path
15
19
  attr_reader :logger
@@ -26,7 +30,7 @@ module MtrMonitor
26
30
  @logger = logger || Logger.new(STDOUT)
27
31
 
28
32
  @log_name = "#{@name}/#{Time.now.strftime("%Y-%m-%d")}/#{@host_ip_address}/#{Time.now.strftime("%H-%M")}.log"
29
- @log_path = "/var/log/mtr/#{@log_name.gsub("/", "-")}"
33
+ @log_path = "#{MtrMonitor::REPORTS_PATH}/#{@log_name.gsub("/", "-")}"
30
34
  @s3_path = "s3://#{@s3_bucket}/#{@log_name}"
31
35
  end
32
36
 
@@ -0,0 +1,28 @@
1
+ module MtrMonitor
2
+ module Cleaner
3
+
4
+ MAX_AGE = 2 * 7 * 24 * 60 * 60 # two weeks
5
+
6
+ def self.execute(logger)
7
+ logger.info("[CLEANER] Deleting reports created more than 2 weeks ago")
8
+
9
+ old_reports.each do |filename|
10
+ logger.info("Deleting #{filename}")
11
+ `sudo rm -f #{filename}`
12
+ end
13
+
14
+ logger.info("[CLEANER] Done.")
15
+ end
16
+
17
+ def self.old_reports
18
+ all_reports.select do |filename|
19
+ File.mtime(filename) < (Time.now - MAX_AGE)
20
+ end
21
+ end
22
+
23
+ def self.all_reports
24
+ Dir.glob("#{MtrMonitor::REPORTS_PATH}/*")
25
+ end
26
+
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module MtrMonitor
2
- VERSION = "0.10.3"
2
+ VERSION = "0.11.0"
3
3
  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.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RenderedText DevOps Team
@@ -88,6 +88,7 @@ files:
88
88
  - docker-compose.yml
89
89
  - exe/mtr_report
90
90
  - lib/mtr_monitor.rb
91
+ - lib/mtr_monitor/cleaner.rb
91
92
  - lib/mtr_monitor/hop.rb
92
93
  - lib/mtr_monitor/metrics.rb
93
94
  - lib/mtr_monitor/version.rb