sensu / sensu-processes-check

Sensu check that searches for certain running processes
MIT License
0 stars 6 forks source link

The processes check doesn't exclude it's own search in the found processes. #3

Closed jBRNDnl closed 3 years ago

jBRNDnl commented 3 years ago

The found processes are always 1 process higher than running processes on the server. It looks like it also counts the search string.

The following is setup. command: | sensu-processes-check --search '[{"search_string": "/usr/lib/postfix/sbin/master", "number": 1, "full_cmdline": true}]'

This results in when postfix is running: OK | 2 >= 1 (found >= required) evaluated true for "/usr/lib/postfix/sbin/master" Status - OK

And on the server it looks like this. So only 1 process running. root@vBG1:~# ps -aux | grep /usr/lib/postfix/sbin/master root 3805455 0.0 0.1 40180 5200 ? Ss 15:24 0:00 /usr/lib/postfix/sbin/master -w root 3805630 0.0 0.0 6316 732 pts/0 S+ 15:25 0:00 grep /usr/lib/postfix/sbin/master

nixwiz commented 3 years ago

I am unable to reproduce.

I see four /usr/sbin/smbd processes plus my grep in ps aux output:

$ ps aux | grep /usr/sbin/smbd
root        1166  0.0  0.1 316868 25788 ?        Ss   Feb20   0:14 /usr/sbin/smbd --foreground --no-process-group
root        1407  0.0  0.0 294340 10432 ?        S    Feb20   0:00 /usr/sbin/smbd --foreground --no-process-group
root        1408  0.0  0.0 294348  6040 ?        S    Feb20   0:00 /usr/sbin/smbd --foreground --no-process-group
root        1422  0.0  0.0 316852 10804 ?        S    Feb20   0:00 /usr/sbin/smbd --foreground --no-process-group
todd      832731  0.0  0.0 216216  2432 pts/0    S+   06:45   0:00 grep --color=auto /usr/sbin/smbd

Running this check with similar parameters as yours, I again see the four /usr/sbin/smbd processes

$ ./sensu-processes-check --search '[{"search_string": "/usr/sbin/smbd", "number": 1, "full_cmdline": true}]'
OK       | 4 >= 1 (found >= required) evaluated true for "/usr/sbin/smbd"
Status - OK

Also, this section of the code ensures that the running check process does not get included in the search.

nixwiz commented 3 years ago

@jBRNDnl do you have any other feedback? If not, based on my not being able to reproduce I will close this issue.

nixwiz commented 3 years ago

Closing due to a lack of reply.