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

Avoid false alert due to rapidly changing /proc/{pid}: metrics-per-process.py #25

Closed jaykumar-jnpr closed 8 years ago

jaykumar-jnpr commented 8 years ago

Not an issue with the script itself, but in an environment with rapidly changing /proc/{pid}, for example on a system were multiple process are spawned every minute, the script fails with following "expected" error.

/opt/sensu/embedded/bin/metrics-per-process.py -n sensu-client -s servers.$(hostname --short).sensu-client Traceback (most recent call last): File "/opt/sensu/embedded/bin/metrics-per-process.py", line 219, in main() File "/opt/sensu/embedded/bin/metrics-per-process.py", line 211, in main pids = find_pids_from_name(options.process_name) File "/opt/sensu/embedded/bin/metrics-per-process.py", line 97, in find_pids_from_name if 'comm' in os.listdir(path): OSError: [Errno 2] No such file or directory: '/proc/17088'

This is reproducible even with a simple bash command;

$ cat /proc/{1..9}*/comm | grep sensu-client cat: /proc/20229/comm: No such file or directory cat: /proc/20234/comm: No such file or directory cat: /proc/20238/comm: No such file or directory cat: /proc/20239/comm: No such file or directory cat: /proc/20242/comm: No such file or directory sensu-client

Any workaround for this problem? Ofcourse, I can use pid file in this context (sensu-client), but it might not be a possibility in all environments.