chef-monitor
chef-monitor copied to clipboard
nagios_perfdata.rb should be robust against checks that are not reporting performance data
A failing check command like check_http (in case of port to be checked is not listening) does not necessarily have performance data appended. This results in sensu-server.log filling up with
... "extension":{"type":"extension","name":"nagios_perfdata"},"output":"undefined method `strip' for nil:NilClass","status":2}
Checking for a | in check[:output] before trying to split solves the problem
check = event[:check]
output = check[:output]
# https://www.nagios-plugins.org/doc/guidelines.html#AEN200
if output.include? '|'
perfdata = output.split('|').last.strip
...
end