class Malsh::HostMetrics::Base
Public Class Methods
all_keys?(metrics)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 31 def all_keys?(metrics) resources.all? {|k| metrics.keys.include?(k) } end
check(hosts)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 4 def check(hosts) to = Time.now.to_i # 7 = 1week from = to - (Malsh.options[:past_date] || 7) * 86400 if Malsh.options[option_name] Parallel.map(hosts) do |h| value = get_max_usage(h, from, to) if h h if value && lower?(value) end || [] else hosts end end
get_host_metrics(host, from, to)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 49 def get_host_metrics(host, from, to) resources.each_with_object(Hash.new { |h,k| h[k] = {} }) do |name,hash| Malsh.host_metrics(host["id"], name, from, to).metrics.each do |v| hash[v.time][name] = v.value end end end
get_max_usage(host, from, to)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 43 def get_max_usage(host, from, to) host_metrics = get_host_metrics(host, from, to) max = get_max_value(host_metrics) if host_metrics normalize_result(max, host) if max end
get_max_value(host_metrics)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 23 def get_max_value(host_metrics) [] end
lower?(value)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 35 def lower?(value) value < Malsh.options[option_name] end
normalize_result(max, host)
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 27 def normalize_result(max, host) [] end
option_name()
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 39 def option_name nil end
resources()
click to toggle source
# File lib/malsh/host_metrics/base.rb, line 19 def resources [] end