Class: IPVSLitmus::Metric::AvailableMemory
- Inherits:
-
Object
- Object
- IPVSLitmus::Metric::AvailableMemory
- Defined in:
- lib/ipvs_litmus/metric/available_memory.rb
Constant Summary collapse
- MULTIPLIER =
{ "GB" => 1024*1024*1024, "MB" => 1024*1024, "KB" => 1024 }
Instance Method Summary collapse
- #current_health ⇒ Object
-
#initialize(weight, facter = Facter) ⇒ AvailableMemory
constructor
A new instance of AvailableMemory.
- #memory_free ⇒ Object
- #memory_total ⇒ Object
Constructor Details
#initialize(weight, facter = Facter) ⇒ AvailableMemory
Returns a new instance of AvailableMemory.
10 11 12 13 |
# File 'lib/ipvs_litmus/metric/available_memory.rb', line 10 def initialize(weight, facter = Facter) @weight = weight @facter = facter end |
Instance Method Details
#current_health ⇒ Object
15 16 17 |
# File 'lib/ipvs_litmus/metric/available_memory.rb', line 15 def current_health @weight * memory_free / memory_total end |
#memory_free ⇒ Object
26 27 28 29 |
# File 'lib/ipvs_litmus/metric/available_memory.rb', line 26 def memory_free size, scale = @facter.value('memoryfree').split(' ') size.to_i * MULTIPLIER[scale] end |
#memory_total ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ipvs_litmus/metric/available_memory.rb', line 19 def memory_total return @memory_total unless @memory_total.nil? size, scale = @facter.value('memorytotal').split(' ') @memory_total = size.to_i * MULTIPLIER[scale] end |