sensu-plugins / sensu-plugins-process-checks

This plugin provides native process instrumentation for monitoring and metrics collection, including: process status, uptime, thread count, and others.
http://sensu-plugins.io
MIT License
20 stars 55 forks source link

Failure on OSX #29

Open shmul opened 8 years ago

shmul commented 8 years ago

Hi,

Just tried to run version 1.0.0 on OSX (check-process.rb -p redis) and it immediately failed with Check failed to run: undefined method 'exitstatus' for nil:NilClass, ["/Library/Ruby/Gems/2.0.0/gems/sensu-plugins-process-checks-1.0.0/bin/check-process.rb:205 ...

I simply added $CHILD_STATUS && to the check.

def on_cygwin?
    # #YELLOW
    `ps -W 2>&1`; $CHILD_STATUS && $CHILD_STATUS.exitstatus == 0 # rubocop:disable Semicolon
  end

Not really worth a pull request :)

Cheers, Shmul

thisisjaid commented 8 years ago

Ran into same today, was going to do a PR with something a bit more complicated, but your fix seems adequate as I can't really imagine any instance in which you'd actually need to read that status if you're on OSX anyway. Thanks for posting it.