Class: Malsh::HostMetrics::Memory

Inherits:
Base
  • Object
show all
Defined in:
lib/malsh/host_metrics/memory.rb

Class Method Summary collapse

Methods inherited from Base

all_keys?, check, get_host_metrics, get_max_usage, lower?

Class Method Details

.get_max_value(host_metrics) ⇒ Object



8
9
10
11
12
13
# File 'lib/malsh/host_metrics/memory.rb', line 8

def get_max_value(host_metrics)
  host_metrics.max_by do |time,memory|
    resources.map { |name| memory[name] }.inject(:+) if all_keys?(memory)
    (memory["memory.used"] + memory["memory.cached"]) / memory["memory.total"] * 100 if all_keys?(memory)
  end
end

.normalize_result(max, host) ⇒ Object



15
16
17
# File 'lib/malsh/host_metrics/memory.rb', line 15

def normalize_result(max, host)
  (max.last["memory.used"] + max.last["memory.cached"]) / max.last["memory.total"] * 100
end

.option_nameObject



19
20
21
# File 'lib/malsh/host_metrics/memory.rb', line 19

def option_name
  :memory_threshold
end

.resourcesObject



4
5
6
# File 'lib/malsh/host_metrics/memory.rb', line 4

def resources
  %w(memory.total memory.used memory.cached)
end