Class: Salus::ZabbixCacheRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Salus::ZabbixCacheRenderer
- Defined in:
- lib/salus/cli/zabbix.rb
Constant Summary collapse
- ZABBIX_DEFAULT_TTL =
60
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
Methods inherited from BaseRenderer
descendants, inherited, #initialize, #iterate
Methods included from Logging
Constructor Details
This class inherits a constructor from Salus::BaseRenderer
Instance Attribute Details
#data ⇒ Object (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., cache_ttl: ttl, value: value} end end |