Sha256: e5e9550469740b3c0dc83dd40a9de5d7a8c86f528166f0e2e82e52bb0dec0bf4
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
require "zabbix-ruby-client/logger" module ZabbixRubyClient class Data def initialize(host) @discover = {} @items = [] @host = host end def run_plugin(plugin, args = nil) Plugins.load(plugin) || logger.error( "Plugin #{plugin} not found.") if Plugins.loaded[plugin] begin @items += Plugins.loaded[plugin].send(:collect, @host, *args) if Plugins.loaded[plugin].respond_to?(:discover) key, value = Plugins.loaded[plugin].send(:discover, *args) @discover[key] ||= [] @discover[key] << [ value ] end rescue Exception => e Log.fatal "Oops" Log.fatal e.message 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zabbix-ruby-client-0.0.16 | lib/zabbix-ruby-client/data.rb |