lib/zabbix-ruby-client/runner.rb in zabbix-ruby-client-0.0.20 vs lib/zabbix-ruby-client/runner.rb in zabbix-ruby-client-0.0.21
- old
+ new
@@ -21,11 +21,10 @@
@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'), @config['loglevel'])
ZabbixRubyClient::Log.debug @config.inspect
- zabbix_sender_version = `zabbix_sender -V | head -1`.split(/\s/)[2]
@is_22 = /v2\.2\./.match zabbix_sender_version
end
def collect
@tasks.each do |plugin|
@@ -51,10 +50,14 @@
ZabbixRubyClient::Log.debug "zabbix-sender: Data Sent"
when 1
@store.keepdata(file)
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
when 512
ZabbixRubyClient::Log.warn "zabbix-sender: Some values failed"
ZabbixRubyClient::Log.warn res
else
ZabbixRubyClient::Log.error "zabbix-sender: Something failed. #{$i}. code #{$?.to_i} was returned"
@@ -80,9 +83,16 @@
def makedir(configdir, defaultdir)
dir = configdir || defaultdir
FileUtils.mkdir dir unless Dir.exists? dir
dir
+ end
+
+ def zabbix_sender_version
+ v = `#{@config['zabbix']['sender']} -V &> /dev/null | head -1`
+ v.split(/\s/)[2]
+ rescue
+ false
end
end
end