portertech / chef-monitor

An OpsCode Chef cookbook for monitoring services, wrapping the Sensu cookbook.
http://community.opscode.com/cookbooks/monitor
84 stars 102 forks source link

nagios_perfdata.rb should be robust against checks that are not reporting performance data #21

Open cruschke opened 10 years ago

cruschke commented 10 years ago

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