Class: Malsh::HostMetrics::Cpu
- Inherits:
-
Base
- Object
- Base
- Malsh::HostMetrics::Cpu
show all
- Defined in:
- lib/malsh/host_metrics/cpu.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
|
# File 'lib/malsh/host_metrics/cpu.rb', line 8
def get_max_value(host_metrics)
host_metrics.max_by do |time,cpu|
resources.map { |name| cpu[name] }.inject(:+) if all_keys?(cpu)
end
end
|
.normalize_result(max, host) ⇒ Object
14
15
16
|
# File 'lib/malsh/host_metrics/cpu.rb', line 14
def normalize_result(max, host)
resources.map { |name| max.last[name] }.inject(:+) / host["meta"]["cpu"].size
end
|
.option_name ⇒ Object
18
19
20
|
# File 'lib/malsh/host_metrics/cpu.rb', line 18
def option_name
:cpu_threshold
end
|
.resources ⇒ Object
4
5
6
|
# File 'lib/malsh/host_metrics/cpu.rb', line 4
def resources
%w(cpu.user.percentage cpu.iowait.percentage cpu.system.percentage)
end
|