- fix nagios output (refactor for new event methods, etc)

This commit is contained in:
Jordan Sissel 2013-08-24 23:43:20 -07:00
parent 1bb463ae2e
commit b24d4cab8f

View file

@ -109,13 +109,12 @@ class LogStash::Outputs::Nagios < LogStash::Outputs::Base
end end
end end
cmd = "[#{Time.now.to_i}] PROCESS_SERVICE_CHECK_RESULT;#{host[0]};#{service[0]};#{level};" cmd = "[#{Time.now.to_i}] PROCESS_SERVICE_CHECK_RESULT;#{host};#{service};#{level};"
if annotation if annotation
cmd += "#{annotation[0]}: " cmd += "#{annotation}: "
end end
cmd += "#{event.source}: "
# In the multi-line case, escape the newlines for the nagios command file # In the multi-line case, escape the newlines for the nagios command file
cmd += event.message.gsub("\n", "\\n") cmd += (event["message"] || "<no message>").gsub("\n", "\\n")
@logger.debug("Opening nagios command file", :commandfile => @commandfile, @logger.debug("Opening nagios command file", :commandfile => @commandfile,
:nagios_command => cmd) :nagios_command => cmd)