Sha256: 0bf68e41349dffb62afb12b9492901ccb19a483ebca64a056548097666925b59
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require "zabbix-ruby-client/logger" require "zabbix-ruby-client/plugins" module ZabbixRubyClient class Data def initialize(host) @discover = {} @items = [] @host = host end def run_plugin(plugin, args = nil) Plugins.load(plugin) || ZabbixRubyClient::Log.error( "Plugin #{plugin} not found.") if Plugins.loaded[plugin] begin if Plugins.loaded[plugin].respond_to?(:collect) @items += Plugins.loaded[plugin].send(:collect, @host, *args) end if Plugins.loaded[plugin].respond_to?(:discover) key, value = Plugins.loaded[plugin].send(:discover, *args) @discover[key] ||= [] @discover[key] << [ value ] end rescue Exception => e ZabbixRubyClient::Log.fatal "Oops" ZabbixRubyClient::Log.fatal e.message ZabbixRubyClient::Log.fatal e.backtrace.join("\n") end end end def merge time = Time.now.to_i @discover.reduce([]) do |a,(k,v)| a << "#{@host} #{k} #{time} { \"data\": [ #{v.join(', ')} ] }" a end + @items end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zabbix-ruby-client-0.1.3 | lib/zabbix-ruby-client/data.rb |
zabbix-ruby-client-0.1.2 | lib/zabbix-ruby-client/data.rb |
zabbix-ruby-client-0.1.1 | lib/zabbix-ruby-client/data.rb |