Page 1 of 3

Monitor the process containing space in the process name

Posted: Mon Jul 30, 2018 10:43 am
by xlin125
On a Nagios XI 5.2.3, we use check_snmp_process_wizard.pl to determine/check (SNMP query) the total number instance of a process running on a Redhad 7.x server. This process name contains a space in between, e.g., the process name is 'Prong app". The result is no process matching this process name. Does this script support the process monitoring that the process name contains a space? If yes, what is the script syntax that can handle this case? Thanks!

Re: Monitor the process containing space in the process name

Posted: Mon Jul 30, 2018 4:25 pm
by scottwilkerson
I believe if you wrap the service name in a single quote it will work such as

Code: Select all

'Prong app'

Re: Monitor the process containing space in the process name

Posted: Mon Jul 30, 2018 5:02 pm
by xlin125
Before I posted this question, I did try to wrap the process name in a single quote such as 'Prong app', it did not work.

Re: Monitor the process containing space in the process name

Posted: Mon Jul 30, 2018 5:09 pm
by scottwilkerson
I don't have a setup to test so lets try one other before we dig further
remove quotes and escape the space

Code: Select all

Prong\ app

Re: Monitor the process containing space in the process name

Posted: Tue Jul 31, 2018 4:55 pm
by xlin125
Removing quotes and escaping the space do not work either.

Maybe the check_snmp_process_wizard.pl does not support the imbedded space in the process name??

Re: Monitor the process containing space in the process name

Posted: Wed Aug 01, 2018 10:04 am
by scottwilkerson
In my test setup I created this process (process with space.sh) and then executed it.

Code: Select all

ps -ef|grep "process with space.sh"
root      1324 20776  0 09:55 pts/1    00:00:00 /bin/bash ./process with space.sh
It showed up as a bash process with arguments of "process with space.sh"

so when I ran this, it found it correctly

Code: Select all

/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n bash -f -A "process with space.sh"

Re: Monitor the process containing space in the process name

Posted: Fri Aug 10, 2018 1:02 pm
by xlin125
@scottwilkerson,
Thanks for spending the time to run a test setup. However, I am still having trouble to match a process name that contains a space or multiple spaces in between, even I tried to follow your example. Here are two real process names that I am trying to match using check_snmp_process_wizard.pl:
$ ps -ef | grep Pronghorn
prongho+ 12963 1 0 Jun29 ? 00:09:03 Pronghorn core
prongho+ 12977 12963 0 Jun29 ? 00:08:12 Pronghorn NSO Adapter

Can you take a look at it and see what command/script arguments I should use/add to make the script matching these process names? Thanks again!

Re: Monitor the process containing space in the process name

Posted: Fri Aug 10, 2018 1:53 pm
by scottwilkerson
Does this work?

Code: Select all

/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n Pronghorn -f -A "core"
/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n Pronghorn -f -A "NSO Adapter"
If not, how about this

Code: Select all

/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n "" -f -A "Pronghorn core"
/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n "" -f -A "Pronghorn NSO Adapter"

Re: Monitor the process containing space in the process name

Posted: Fri Aug 10, 2018 4:21 pm
by xlin125
Either way does not work as expected:
1) only matched "Pronghorn" while trying to match the process name "Pronghorn core". The result should match 1 "Pronghorn core"
/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 --v2c -C public -n Pronghorn -f -A "core" -w 0,100 -c 0,100
3 process matching Pronghorn (> 0) (<= 100):OK

2) It does not specify what process is matched, and the result is incorrect
/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 --v2c -C public -n "" -f -A "Pronghorn core" -w 0,100 -c 0,100
4 process matching (> 0) (<= 100):OK

Does this perl script check_snmp_process_wizard.pl support the string (process name) match that contains one or more spaces?

Re: Monitor the process containing space in the process name

Posted: Fri Aug 10, 2018 4:32 pm
by scottwilkerson
according to the Docs it is supposed to do a regex match on the process name. I don't have any processes with spaces to test.

We could try forcing without the regex -r

Code: Select all

/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n "Pronghorn core" -r
/usr/local/nagios/libexec/check_snmp_process_wizard.pl -H 127.0.0.1 -C public -2 -n "Pronghorn NSO Adapter" -r