Sha256: cd945b86bf16e1d3f8b69b55a5961599c86d3a7a931a91f93363532fdcf6b4e0
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module ZabbixRubyClient class Runner def initialize(config, tasks) @config = config @tasks = tasks @store = ZabbixRubyClient::Store.new( @config['datadir'], @config['zabbix']['host'], @config['taskfile'], @config['keepdata'] ) @data = ZabbixRubyClient::Data.new(@config['host']) @logsdir = makedir(@config['logsdir'], 'logs') ZabbixRubyClient::Plugins.scan_dirs([ PLUGINDIR ] + @config['plugindirs']) ZabbixRubyClient::Log.set_logger(File.join(@logsdir, 'zrc.log'), 'info') ZabbixRubyClient::Log.debug @config.inspect end def collect @tasks.each do |plugin| @data.run_plugin(plugin['name'], plugin['args']) end end def show @data.merge.each do |line| puts line end end def upload file = @store.record(@data.merge) begin res = `#{@config['zabbix']['sender']} -z #{@config['zabbix']['host']} -p #{@config['zabbix']['port']} -T -i #{file}` if $?.to_i != 0 @store.keepdata(file) end rescue Exception => e @store.keepdata(file) logger.error "Sending failed." logger.error e.message end end private def makedir(configdir, defaultdir) dir = configdir || defaultdir FileUtils.mkdir dir unless Dir.exists? dir dir 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/runner.rb |