Permalink
Browse files

Make log directory and thresholds configurable.

  • Loading branch information...
1 parent 20ac0cb commit c2bdb3edd65b0fbbe27b927d70a0fe3969fc7e71 @watsonian committed Sep 4, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/mem_watcher.rb
View
@@ -8,12 +8,13 @@
class MemWatcher < Sinatra::Base
set :views, File.join(File.dirname(settings.root), "/views")
set :public_folder, File.join(File.dirname(settings.root), "/public")
+ set :log_dir, ENV['MEMWATCHER_LOG_DIR'] || File.join(File.dirname(settings.root), "/log/procs")
- @@memory_threshold = 50000
+ @@memory_threshold = (ENV['MEMWATCHER_MEMORY_THRESHOLD'] || 50000).to_i
@@max_memused = @@memory_threshold
@@num_checks = 0
- @@max_checks = 6
- @@logs_to_keep = 25
+ @@max_checks = (ENV['MEMWATCHER_MAX_CHECKS'] || 6).to_i
+ @@logs_to_keep = (ENV['MEMWATCHER_LOGS_TO_KEEP'] || 25).to_i
#####
# Actions
@@ -72,7 +73,7 @@ def update_max_memused!(cur_meminfo)
end
def save_process_list!(cur_meminfo)
- FileUtils.mkdir_p("./log/procs")
+ FileUtils.mkdir_p(settings.log_dir)
system("ps auxf > log/procs/`date \"+%Y%m%d_%H%M%S-#{@@max_memused}-#{cur_meminfo.memused}\"`.snapshot.out")
end

0 comments on commit c2bdb3e

Please sign in to comment.