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

check pid should return CRITICAL not UNKNOWN if pid does not exist #23

Closed gbolo closed 7 years ago

gbolo commented 8 years ago

This script should assume that the pid file location provided by the admin should be correct and ALWAYS present. The absence of this pid file should be interpreted as the process is no longer functioning as intended. In it's current form, this script will only catch instances in which the application crashed or exited improperly resulting in the pid file being left behind and not cleaned up. It's my belief that if the application is shutdown gracefully (pid file being removed), it should still result in a CRITICAL state since the application is no longer running. I understand that, technically, providing only the expected pid is not enough information to to actually determine without doubt whether or not the process is running or not, hence the UNKNOWN state. However, if the application is providing a pid, we should trust it and alert critical in it's absence, or at least provide another switch which behaves in this manner.

GRACEFUL SHUTDOWN

systemctl stop monit
/opt/sensu/embedded/bin/check-process.rb -f /var/run/monit.pid
CheckProcess UNKNOWN: Could not read pid file /var/run/monit.pid

FORCED SHUTDOWN/CRASH

kill -9 `cat /var/run/monit.pid`
opt/sensu/embedded/bin/check-process.rb -f /var/run/monit.pid
CheckProcess CRITICAL: Found 0 matching processes; pid /var/run/monit.pid
codepattern commented 8 years ago

Has there been any other thoughts into this comment?

majormoses commented 7 years ago

I am thinking that should be an option --fail-on-missing-pid

majormoses commented 7 years ago

closed per #34