It appears that the global event handler command is not triggering in my setup. This problem has been driving me crazy for the last few days. It shows up in the log at the appropriate time, but nothing happens. To me it feels like a permissions issue, but from everything I can see, it looks fine. The script is set as 777 owned by nagios:nagios. It runs fine manually when run by the nagios user. I've tried to just have the command echo into a temporary log file (i.e. command_line echo "test123" >> test.log) and that doesn't work either, although, again it shows in the log with no errors. I have all alerts on, with verbosity maxed out and the below is all I get in the log relating to the event handler.
Anyone have any ideas? Thanks in advance.
nagios.cfg
Code: Select all
log_event_handlers=1
global_host_event_handler=hpov_host_eventhandler
global_service_event_handler=hpov_service_eventhandler
enable_event_handlers=1
debug_level=-1
debug_verbosity=2
Code: Select all
define command {
command_name hpov_service_eventhandler
command_line /usr/share/nagios3/plugins/eventhandlers/hpov_eventhandler.rb service $LASTSERVICECHECK$ $HOSTNAME$ "$SERVICESTATE$" "$SERVICEOUTPUT$" "$SERVICEDESC$"
}
define command {
command_name hpov_host_eventhandler
command_line /usr/share/nagios3/plugins/eventhandlers/hpov_eventhandler.rb host $LASTHOSTCHECK$ "$HOSTNAME$" "$HOSTSTATE$" "$HOSTOUTPUT$"
}
Code: Select all
#!/usr/bin/env ruby
type = ARGV[0]
lastcheck = ARGV[1]
host = ARGV[2]
status = ARGV[3]
statustext = ARGV[4]
service = ARGV[5]
logfile = "/usr/share/nagios3/plugins/eventhandlers/hpov_eventhandler.log"
debug = true
hpovstatus = nil
hpovobject = nil
time1 = Time.new
puts "I was passed: "
ARGV.each do |value|
puts value
end
debug = true
hpovstatus = nil
hpovobject = nil
time1 = Time.new
logfile = "/usr/share/nagios3/plugins/eventhandlers/hpov_eventhandler.log"
if type == "service"
hpovobject = service
if status == 'CRITICAL'
hpovstatus = 'warning'
elsif status == 'WARNING'
hpovstatus = 'warning'
elsif status == 'UNKNOWN'
hpovstatus = 'minor'
elsif status =="OK"
hpovstatus = 'normal'
else
hpovstatus = 'minor'
end
elsif type == "host"
hpovobject = "redacted"
if status == 'DOWN'
hpovstatus = 'warning'
elsif status == 'UNREACHABLE'
hpovstatus = 'warning'
elsif status == 'UNKNOWN'
hpovstatus = 'minor'
elsif status =="UP"
hpovstatus = 'normal'
else
hpovstatus = 'minor'
end
else
hpovstatus = 'error'
end
open(logfile, 'a') { |f|
f << "Time: " + time1.inspect + "\n"
f << "I was passed: \n"
ARGV.each do |value|
f << value + "\n"
end
f << "Command Line: /opt/OV/bin/OpC/opcmsg severity=\"#{hpovstatus}\" application=redacted object=#{hpovobject} msg_text=\"Host: #{host}, Message: #{statustext}\"\n"
f << "___________________________________________________________\n\n"
}
exec "/opt/OV/bin/OpC/opcmsg severity=\"#{hpovstatus}\" application=redacted object=#{hpovobject} msg_text=\"Host: #{host}, Message: #{statustext}\""
Code: Select all
Oct 30 11:48:46 redacted nagios3: GLOBAL SERVICE EVENT HANDLER: redacted;Check Puppet Agent;CRITICAL;SOFT;1;hpov_service_eventhandler
Oct 30 11:49:46 redacted nagios3: GLOBAL SERVICE EVENT HANDLER: redacted;Check Puppet Agent;CRITICAL;HARD;2;hpov_service_eventhandler
Oct 30 13:47:49 redacted nagios3: GLOBAL SERVICE EVENT HANDLER: redacted;Check Puppet Agent;OK;HARD;2;hpov_service_eventhandler