Class: LogStash::Filters::Zabbix::Cache
- Inherits:
-
Object
- Object
- LogStash::Filters::Zabbix::Cache
- Defined in:
- lib/logstash/filters/zabbix/cache.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #end ⇒ Object
- #fetch ⇒ Object
-
#initialize(logger, options) ⇒ Cache
constructor
A new instance of Cache.
- #start ⇒ Object
Constructor Details
#initialize(logger, options) ⇒ Cache
Returns a new instance of Cache.
10 11 12 13 14 |
# File 'lib/logstash/filters/zabbix/cache.rb', line 10 def initialize(logger, ) @logger = logger @options = @items = {} end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/logstash/filters/zabbix/cache.rb', line 8 def items @items end |
Instance Method Details
#end ⇒ Object
27 28 29 |
# File 'lib/logstash/filters/zabbix/cache.rb', line 27 def end @wt.kill end |
#fetch ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/logstash/filters/zabbix/cache.rb', line 31 def fetch() zbx = ZabbixApi.connect(@options) response = zbx.query( method: 'host.get', params: { groupids: @options[:group_id], output: ['hostid', 'host'], selectItems: ['itemid', 'key_', 'formula'], selectInterfaces: ['ip'], }); @items = parse(response, @options[:keys]) @logger.info("Got zabbix items", :size => @items.keys.size) @items end |
#start ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/logstash/filters/zabbix/cache.rb', line 16 def start self.fetch() @wt = Thread.new do # update zabbix hosts every 6 hours while true sleep(@options[:interval] || REFRSH_INTERVAL) self.fetch() end end end |