Class: SystemMemory
- Inherits:
-
Object
- Object
- SystemMemory
- Defined in:
- lib/pimon/probe/system_memory.rb
Class Method Summary collapse
Class Method Details
.check(type) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pimon/probe/system_memory.rb', line 3 def self.check(type) case type when :mem index = 1 when :swap index = 2 else raise "Undefined memory type: #{type}" end memory = `free -o -m`.split(/\n/)[index].split(" ") # memory[1] holds total memory # memory[2] holds used memory ((memory[2].to_f / memory[1].to_f) * 100).to_i end |