Monitor the process containing space in the process name

This board serves as an open discussion and support collaboration point for Nagios XI. NOTE: Nagios XI customers should use the Customer Support forum to obtain expedited support.

Monitor the process containing space in the process name

Postby xlin125 » Mon Jul 30, 2018 10:43 am

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!
xlin125
 
Posts: 134
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Postby scottwilkerson » Mon Jul 30, 2018 4:25 pm

I believe if you wrap the service name in a single quote it will work such as
Code: Select all
'Prong app'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12048
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Monitor the process containing space in the process name

Postby xlin125 » Mon Jul 30, 2018 5:02 pm

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.
xlin125
 
Posts: 134
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Postby scottwilkerson » Mon Jul 30, 2018 5:09 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12048
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Monitor the process containing space in the process name

Postby xlin125 » Tue Jul 31, 2018 4:55 pm

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??
xlin125
 
Posts: 134
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Postby scottwilkerson » Wed Aug 01, 2018 10:04 am

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"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12048
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Monitor the process containing space in the process name

Postby xlin125 » Fri Aug 10, 2018 1:02 pm

@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!
xlin125
 
Posts: 134
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Postby scottwilkerson » Fri Aug 10, 2018 1:53 pm

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"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12048
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Monitor the process containing space in the process name

Postby xlin125 » Fri Aug 10, 2018 4:21 pm

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?
xlin125
 
Posts: 134
Joined: Mon Jan 19, 2015 6:01 pm

Re: Monitor the process containing space in the process name

Postby scottwilkerson » Fri Aug 10, 2018 4:32 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12048
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Next

Return to Nagios XI

Who is online

Users browsing this forum: No registered users and 16 guests