Monitor the process containing space in the process name

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Monitor the process containing space in the process name

Post 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!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor the process containing space in the process name

Post by scottwilkerson »

I believe if you wrap the service name in a single quote it will work such as

Code: Select all

'Prong app'
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor the process containing space in the process name

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Post 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??
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor the process containing space in the process name

Post 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"
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Post 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!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor the process containing space in the process name

Post 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"
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitor the process containing space in the process name

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked