lib/zabbix-ruby-client/runner.rb in zabbix-ruby-client-0.0.21 vs lib/zabbix-ruby-client/runner.rb in zabbix-ruby-client-0.0.22

- old
+ new

@@ -22,10 +22,11 @@ @logsdir = makedir(@config['logsdir'], 'logs') ZabbixRubyClient::Plugins.scan_dirs([ PLUGINDIR ] + @config['plugindirs']) ZabbixRubyClient::Log.set_logger(File.join(@logsdir, 'zrc.log'), @config['loglevel']) ZabbixRubyClient::Log.debug @config.inspect @is_22 = /v2\.2\./.match zabbix_sender_version + ZabbixRubyClient::Log.debug "zabbix sender version #{zabbix_sender_version}" end def collect @tasks.each do |plugin| @data.run_plugin(plugin['name'], plugin['args']) @@ -45,14 +46,14 @@ begin res = `#{command}` if @is_22 case $?.to_i when 0 - ZabbixRubyClient::Log.debug "zabbix-sender: Data Sent" + ZabbixRubyClient::Log.debug "zabbix-sender: Data Sent (#{$?})" when 1 @store.keepdata(file) - ZabbixRubyClient::Log.error "zabbix-sender: Sending failed" + ZabbixRubyClient::Log.error "zabbix-sender: Sending failed (#{$?})" ZabbixRubyClient::Log.error res when 256 @store.keepdata(file) ZabbixRubyClient::Log.warn "zabbix-sender: shit happens (unknown code 256)" ZabbixRubyClient::Log.warn res @@ -63,10 +64,11 @@ ZabbixRubyClient::Log.error "zabbix-sender: Something failed. #{$i}. code #{$?.to_i} was returned" ZabbixRubyClient::Log.error res end else if $?.to_i != 0 + ZabbixRubyClient::Log.warn "v2.0" @store.keepdata(file) ZabbixRubyClient::Log.error "zabbix-sender: Sending failed" ZabbixRubyClient::Log.error res else ZabbixRubyClient::Log.debug "zabbix-sender: Data Sent" @@ -86,10 +88,10 @@ FileUtils.mkdir dir unless Dir.exists? dir dir end def zabbix_sender_version - v = `#{@config['zabbix']['sender']} -V &> /dev/null | head -1` + v = `#{@config['zabbix']['sender']} -V | head -1` v.split(/\s/)[2] rescue false end