NCPA and processes check.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tonyk
Posts: 3
Joined: Thu Oct 30, 2014 4:22 am

NCPA and processes check.

Post by tonyk »

Hi,

I have been banging my head into the wall with the following problem:

My goal is to make a processes service check with ncpa that excludes one or some processes.

I can make it work on the command line as follows:

nagios@nagios4:~$ /usr/lib64/nagios/plugins/check_ncpa.py -q 'name=^((?!kworker).)*$,match=regex' -T 15 -H server -t token -M processes
OK: Process count for processes named ^((?!kworker).)*$ was 148 | 'process_count'=148;;; 'cpu'=22.64%;;; 'memory'=81.24%;;; 'memory_vms'=45.0GB;;; 'memory_rss'=13.51GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
1: systemd: root: 0.03 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
2: kthreadd: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.00 %
.
.


But I can't make it work in nagios because of the "!" which is the delimiter in nagios.

Any ideas?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NCPA and processes check.

Post by benjaminsmith »

Hello Tony,

Please post the check command from your nagios config file that is not working for us to review. Thanks.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
tonyk
Posts: 3
Joined: Thu Oct 30, 2014 4:22 am

Re: NCPA and processes check.

Post by tonyk »

Well I have tried different things, but this is the basic one:

define service {
check_period 24X7
active_checks_enabled 1
notification_interval 0
notification_period 24x7
check_command check_ncpa_processes!xxxxxxx!processes -q 'name=^((?!kworker).)*$,match=regex'
host_name host
check_interval 7
process_perf_data 1
service_description Check_Processes_test
max_check_attempts 3
notification_options w,c,r,u
}

define command {
command_line $USER1$/check_ncpa.py -T $ARG3$ -H $HOSTADDRESS$ -t $ARG1$ -M $ARG2$
command_name check_ncpa_processes
}

And the output for this is:

No data received on stdout
Plugin output (standard error)
/bin/sh: -c: line 0: syntax error near unexpected token `)'
/bin/sh: -c: line 0: `/usr/lib64/nagios/plugins/check_ncpa.py -T kworker).)*$,match=regex' -H host -t xxxxxxxx -M processes -q 'name=^((?'

Which I totally understand, because the delimiter is "!". But I don't know how to work around this.

Actually I just found a way. I have to add the -q 'name=^((?!kworker).)*$,match=regex' directly to the command. That should work...

define command {
command_line $USER1$/check_ncpa.py -T $ARG3$ -H $HOSTADDRESS$ -t $ARG1$ -M $ARG2$ -q 'name=^((?!kworker).)*$,match=regex'
command_name check_ncpa_processes_exclude
}

But it doesn't. I use adagios and if i try to test the command with the check plugin command it works ok:

OK: Process count for processes named ^((?!kworker).)*$ was 156 | 'process_count'=156;;; 'cpu'=24.0%;;; 'memory'=77.18%;;; 'memory_vms'=66.07GB;;; 'memory_rss'=12.82GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
1: systemd: root: 0.03 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
2: kthreadd: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.00 %
6: ksoftirqd/0: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.00 %
7: migration/0: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.00 %
8: rcu_bh: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.00 %
9: rcu_sched: root: 0.0 % (VMS 0.00 GB, RSS 0.00 GB): 0.01 %
...

Adn if I run the command shown by adagios - Status - Service - Information - Check Command:

/usr/lib64/nagios/plugins/check_ncpa.py -T 15 -H host -t xxxxxx -M processes -q 'name=^((?!kworker).)*$,match=regex'

That runs ok and shows the correct output as above.

But when it is running in nagios itself, the regexp does not seem to work as the output is:

OK: Process count for processes named ^((?!kworker).)*$ was 0

Darn...Of course this would be easily solved if there was a match=negate possibility in check_ncpa.py itself...
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NCPA and processes check.

Post by mbellerue »

tonyk wrote:/usr/lib64/nagios/plugins/check_ncpa.py -T 15 -H host -t xxxxxx -M processes -q 'name=^((?!kworker).)*$,match=regex'
/usr/local/nagios/plugins/check_ncpa.py -H 192.168.145.90 -t 'ASecretToken' -M 'processes' -q 'name=^((?!kworker).)*$,match=regex'

So this is strange, I've got this working, though granted it's Nagios XI.
Of course this would be easily solved if there was a match=negate possibility in check_ncpa.py itself...
I can throw that in as a feature request. However, for the moment, would the negate plugin be useful here? Here's the documentation, it's Nagios XI branded, but I believe negate ships with Core.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
tonyk
Posts: 3
Joined: Thu Oct 30, 2014 4:22 am

Re: NCPA and processes check.

Post by tonyk »

I don't see how the negate plugin woiuld help here. I do use it for some plugins, but it is only useful to change the state output to something else.

I did however manage to make a workaround for this problem.

I checked the ncpa_listener.log for the problem and noticed, that if I run the check through nagios I get an extra "%24" in the end of the GET http line. If i run it from the command line it doesn't and the check works.

DId not find out how to fix that directly so I tried to do this with a wrapper script:

Code: Select all

#!/bin/sh
/usr/lib64/nagios/plugins/check_ncpa.py -q 'name=^((?!kworke).)*$,match=regex' $* 
exit
And changing the command to use this instead of check_ncpa.py. And finally it is working!!! :geek:
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NCPA and processes check.

Post by scottwilkerson »

tonyk wrote:And finally it is working!!!
Great!

Glad to see you have it working!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked