check pid should return CRITICAL not UNKNOWN if pid does not exist
gbolo opened this issue · comments
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
Has there been any other thoughts into this comment?
I am thinking that should be an option --fail-on-missing-pid
closed per #34