Monitor the process containing space in the process name
Monitor the process containing space in the process name
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!
-
- 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
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
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.
-
- 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
I don't have a setup to test so lets try one other before we dig further
remove quotes and escape the space
remove quotes and escape the space
Code: Select all
Prong\ app
Re: Monitor the process containing space in the process name
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??
Maybe the check_snmp_process_wizard.pl does not support the imbedded space in the process name??
-
- 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
In my test setup I created this process (process with space.sh) and then executed it.
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
ps -ef|grep "process with space.sh"
root 1324 20776 0 09:55 pts/1 00:00:00 /bin/bash ./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
@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!
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!
-
- 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
Does this work?
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 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"
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
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?
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?
-
- 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
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
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