Class: Bluepill::ProcessConditions::MemUsage
- Inherits:
-
ProcessCondition
- Object
- ProcessCondition
- Bluepill::ProcessConditions::MemUsage
- Defined in:
- lib/bluepill/process_conditions/mem_usage.rb
Constant Summary collapse
- MB =
1024 ** 2
- FORMAT_STR =
"%d%s"
- MB_LABEL =
"MB"
- KB_LABEL =
"KB"
Instance Method Summary collapse
- #check(value) ⇒ Object
- #format_value(value) ⇒ Object
-
#initialize(options = {}) ⇒ MemUsage
constructor
A new instance of MemUsage.
- #run(pid) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MemUsage
Returns a new instance of MemUsage.
10 11 12 |
# File 'lib/bluepill/process_conditions/mem_usage.rb', line 10 def initialize( = {}) @below = [:below] end |
Instance Method Details
#check(value) ⇒ Object
19 20 21 |
# File 'lib/bluepill/process_conditions/mem_usage.rb', line 19 def check(value) value.kilobytes < @below end |
#format_value(value) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/bluepill/process_conditions/mem_usage.rb', line 23 def format_value(value) if value.kilobytes >= MB FORMAT_STR % [(value / 1024).round, MB_LABEL] else FORMAT_STR % [value, KB_LABEL] end end |
#run(pid) ⇒ Object
14 15 16 17 |
# File 'lib/bluepill/process_conditions/mem_usage.rb', line 14 def run(pid) # rss is on the 5th col System.memory_usage(pid).to_f end |