Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make log directory and thresholds configurable.

  • Loading branch information...
commit c2bdb3edd65b0fbbe27b927d70a0fe3969fc7e71 1 parent 20ac0cb
@watsonian authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/mem_watcher.rb
View
9 lib/mem_watcher.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.