Class: EventedBluepill::ProcessConditions::MemUsage
Constant Summary
collapse
- KB =
1024.0
- MB =
KB ** 2
- FORMAT_STR =
"%.1f%s"
- MB_LABEL =
"MB"
- KB_LABEL =
"KB"
Instance Attribute Summary
#every, #fires, #logger, #name, #process, #process_condition
Instance Method Summary
collapse
#clear_history!, #to_s
Constructor Details
#initialize(name, process, options = {}) ⇒ MemUsage
Returns a new instance of MemUsage.
17
18
19
20
21
|
# File 'lib/evented_bluepill/process_conditions/mem_usage.rb', line 17
def initialize(name, process, options = {})
@below = options[:below]
super
end
|
Instance Method Details
#check(value) ⇒ Object
28
29
30
|
# File 'lib/evented_bluepill/process_conditions/mem_usage.rb', line 28
def check(value)
value < @below
end
|
32
33
34
35
36
37
38
|
# File 'lib/evented_bluepill/process_conditions/mem_usage.rb', line 32
def format_value(value)
if value >= MB
FORMAT_STR % [(value / MB), MB_LABEL]
else
FORMAT_STR % [(value / KB), KB_LABEL]
end
end
|
#run ⇒ Object
23
24
25
26
|
# File 'lib/evented_bluepill/process_conditions/mem_usage.rb', line 23
def run
EventedBluepill::System.memory_usage(process.actual_pid).to_f.kilobytes
end
|