Module: MtrMonitor::Cleaner
- Defined in:
- lib/mtr_monitor/cleaner.rb
Constant Summary collapse
- MAX_AGE =
two weeks
2 * 7 * 24 * 60 * 60
Class Method Summary collapse
Class Method Details
.all_reports ⇒ Object
23 24 25 |
# File 'lib/mtr_monitor/cleaner.rb', line 23 def self.all_reports Dir.glob("#{MtrMonitor::LOCAL_REPORTS_DIR}/*") end |
.execute(logger) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mtr_monitor/cleaner.rb', line 6 def self.execute(logger) logger.info("[CLEANER] Deleting reports created more than 2 weeks ago") old_reports.each do |filename| logger.info("Deleting #{filename}") `sudo rm -f #{filename}` end logger.info("[CLEANER] Done.") end |
.old_reports ⇒ Object
17 18 19 20 21 |
# File 'lib/mtr_monitor/cleaner.rb', line 17 def self.old_reports all_reports.select do |filename| File.mtime(filename) < (Time.now - MAX_AGE) end end |