Class: Salus::ZabbixCacheRenderer

Inherits:
BaseRenderer show all
Defined in:
lib/salus/cli/zabbix.rb

Constant Summary collapse

ZABBIX_DEFAULT_TTL =
60

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRenderer

descendants, inherited, #initialize, #iterate

Methods included from Logging

#log

Constructor Details

This class inherits a constructor from Salus::BaseRenderer

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/salus/cli/zabbix.rb', line 6

def data
  @data
end

Instance Method Details

#render(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/salus/cli/zabbix.rb', line 8

def render(data)
  @data = {}
  iterate(data) do |name, metric|
    name  = name.gsub(/\.\[/, '[')
    value = metric.value
    # Metric cache TTL is a half of real metric TTL
    ttl   = metric.ttl.nil? ? ZABBIX_DEFAULT_TTL : (metric.ttl / 2)
    @data[name] = {timestamp: metric.timestamp, cache_ttl: ttl, value: value}
  end
end