check_ncpa.py for multiple separate process is bugged

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Keystone
Posts: 28
Joined: Wed Jan 17, 2018 12:09 pm

check_ncpa.py for multiple separate process is bugged

Post by Keystone »

Hi,

Im trying to use Check_ncpa.py to create a single ncpa process check that checks multiple processes,
https://support.nagios.com/kb/article/p ... _processes
From NCPA agent GUI, Active check sample shows me

./check_ncpa.py -H Server1 -P 5666 -t '<your token>' -M 'processes' -q 'name=crond,name=rsyslogd,combiner=or'

OK: Process count for processes named crond,rsyslogd was 8 | 'process_count'=8;;; 'cpu'=0.02%;;; 'memory'=0.4%;;; 'memory_vms'=2.16GB;;; 'memory_rss'=0.11GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
1998: crond: root: 0.0 % (VMS 0.13 GB, RSS 0.00 GB): 0.00 %
2535: rsyslogd: root: 0.34 % (VMS 0.89 GB, RSS 0.11 GB): 0.02 %
3175: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %
3176: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %
3178: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %
3179: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %
3180: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %
30688: crond: root: 0.01 % (VMS 0.19 GB, RSS 0.00 GB): 0.00 %

Total Memory: 0.40 % (VMS 2.16 GB, RSS 0.11 GB)
Total CPU: 0.02 %

When executing the same command, the GUI recommends on the Nagios server , it shows only the result of Last service name [rsyslogd]

./check_ncpa.py -H server1 -P 5666 -t '<your token>' -M 'processes' -q 'name=crond,name=rsyslogd,combiner=or'
OK: Process count for processes named rsyslogd was 1 | 'process_count'=1;;; 'cpu'=0.0%;;; 'memory'=0.34%;;; 'memory_vms'=0.89GB;;; 'memory_rss'=0.11GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
2535: rsyslogd: root: 0.34 % (VMS 0.89 GB, RSS 0.11 GB): 0.00 %

Total Memory: 0.34 % (VMS 0.89 GB, RSS 0.11 GB)
Total CPU: 0.00 %

How can i make this query work so i can add a Single NCPA process check that validates 15 of my service
Last edited by Keystone on Mon Aug 19, 2019 2:41 pm, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by lmiltchev »

What is the output that you see when you run the following command?

Code: Select all

./check_ncpa.py -H server1 -P 5666 -t 'Str0ngT0k3n' -M 'processes' -q 'name=crond'
It is possible that nagios does not have the permissions to view the crond process. Do the check work if you change this:

Code: Select all

uid = nagios
gid = nagios
to this:

Code: Select all

uid = root
gid = root
in the ncpa.cfg and restart the ncpa_listener?

What is the version of the check_ncpa.py plugin and the NCPA agent that you are currently using?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Keystone
Posts: 28
Joined: Wed Jan 17, 2018 12:09 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by Keystone »

its not that nagios cant get crond task , i see this pattern for all services.
From production server, i ran -q 'name=crond,name=rsyslogd,combiner=or' , it only shows the last process , in this case rsyslogd

[svcanagios@prodserver libexec]$ ./check_ncpa.py -H devserver -P 5666 -t '<your token>' -M 'processes' -q 'name=crond,name=rsyslogd,combiner=or' -c 2:2
CRITICAL: Process count for processes named rsyslogd was 1 | 'process_count'=1;;2:2; 'cpu'=0.0%;;; 'memory'=0.68%;;; 'memory_vms'=0.88GB;;; 'memory_rss'=0.11GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
1828: rsyslogd: root: 0.68 % (VMS 0.88 GB, RSS 0.11 GB): 0.00 %

Total Memory: 0.68 % (VMS 0.88 GB, RSS 0.11 GB)
Total CPU: 0.00 %

Now i am reversing the order of my processess, -q 'name=rsyslogd,name=crond,combiner=or' , now it shows only crond

[svcanagios@prodserver libexec]$ ./check_ncpa.py -H devserver -P 5666 -t ''<your token>' -M 'processes' -q 'name=rsyslogd,name=crond,combiner=or' -c 2:2
CRITICAL: Process count for processes named crond was 101 | 'process_count'=101;;2:2; 'cpu'=0.0%;;; 'memory'=2.02%;;; 'memory_vms'=20.14GB;;; 'memory_rss'=0.0GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
2021: crond: root: 0.02 % (VMS 0.14 GB, RSS 0.00 GB): 0.00 %
10559: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
10560: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
10561: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
10562: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
10563: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
10564: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
13669: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
.
.
Last edited by Keystone on Mon Aug 19, 2019 2:44 pm, edited 1 time in total.
Keystone
Posts: 28
Joined: Wed Jan 17, 2018 12:09 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by Keystone »

Also i did the same test from my dev nagios and it works fine

[svcanagios@devserver libexec]$ ./check_ncpa.py -H devserver -P 5666 -t '<your token>' -M 'processes' -q 'name=crond,name=rsyslogd,combiner=or'
OK: Process count for processes named crond,rsyslogd was 102 | 'process_count'=102;;; 'cpu'=0.0%;;; 'memory'=2.71%;;; 'memory_vms'=21.02GB;;; 'memory_rss'=0.11GB;;;
Processes Matched
PID: Name: Username: Exe: Memory: CPU
-----------------------------------
1828: rsyslogd: root: 0.69 % (VMS 0.88 GB, RSS 0.11 GB): 0.00 %
2021: crond: root: 0.02 % (VMS 0.14 GB, RSS 0.00 GB): 0.00 %
13669: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
13670: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
13671: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %
13676: crond: root: 0.02 % (VMS 0.20 GB, RSS 0.00 GB): 0.00 %


Dev server NCPA
Agent Information
Version 2.1.6

prod server NCPA
Agent Information
Version 2.1.6

in both NCPA cnf file
uid = nagios
gid = nagios
Last edited by Keystone on Mon Aug 19, 2019 2:48 pm, edited 1 time in total.
Keystone
Posts: 28
Joined: Wed Jan 17, 2018 12:09 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by Keystone »

Found this from Github
https://github.com/NagiosEnterprises/nc ... HANGES.rst

1.1.1
Fixed sending multiple query arguments not being sent to the API

and my prod server is using 1.1.0v of check_ncpa.py

Being still new to Nagios, Can you please let me know, if i can just update the check_ncpa.py from 1.1.0 to the latest 1.1.5 and not fully fully upgrade the agent to 2.1.8
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by lmiltchev »

Open a SSH (putty) session to your Nagios XI server, and make a backup of your original check_ncpa.py plugin:

Code: Select all

mv /usr/local/nagios/libexec/check_ncpa.py /usr/local/nagios/libexec/check_ncpa.py.backup
Download the latest plugin:

Code: Select all

cd /tmp
wget https://assets.nagios.com/downloads/ncpa/check_ncpa.tar.gz
tar xvf check_ncpa.tar.gz
and copy it over to the libexec directory:

Code: Select all

cp check_ncpa.py /usr/local/nagios/libexec/
Set the correct permissions:

Code: Select all

chown apache.nagios /usr/local/nagios/libexec/check_ncpa.py
chmod 775 /usr/local/nagios/libexec/check_ncpa.py
Try your check again. Is it working now?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Keystone
Posts: 28
Joined: Wed Jan 17, 2018 12:09 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by Keystone »

Ty for this detailed information,

i am going to do this in one of our lower environment and test it, but before i proceed to Prod, wanted to confirm the below as this plugin is being used to monitor several services and processes in Production.

1) is there any compatibility issue using Version 1.1.5 of check_ncpa.py on 5.4.7 version on Nagios XI
2) will this new version of check_ncpa plugin communicate properly to servers using lower version of NCPA agent [1.8] windows/linux/AIX
3) any issues that might show up for the running checks when we upgrade to version 1.1.5
4) is there any known issue that we need to be aware off for 1.1.5 version?

thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_ncpa.py for multiple separate process is bugged

Post by lmiltchev »

1) is there any compatibility issue using Version 1.1.5 of check_ncpa.py on 5.4.7 version on Nagios XI
No, not that I am aware of.
2) will this new version of check_ncpa plugin communicate properly to servers using lower version of NCPA agent [1.8] windows/linux/AIX
It should, but keep in mind that NCPA 1.8 is VERY old. You may or may not experience issues with old checks. It is hard to say. I would recommend that you upgrade your NCPA agents as soon as you get a chance. Every Nagios XI License key is valid for 3 installs - production, test, and backup.

https://support.nagios.com/kb/article/n ... s-145.html

I would recommend that you test your upgraded plugin and/or agent in a test environment first, before applying it to production.
3) any issues that might show up for the running checks when we upgrade to version 1.1.5
The new plugin should be backwards compatible, but again, try it on your test server, before using it in production. If the new plugin doesn't work as expected, you can easily revert to using the old one, simply by running:

Code: Select all

cd /usr/local/nagios/libexec
cp -p check_ncpa.py.backup check_ncpa.py
4) is there any known issue that we need to be aware off for 1.1.5 version?
You can review all of the NCPA issues here:
https://github.com/NagiosEnterprises/ncpa/issues

Here's the changelog for the client (plugin):
https://github.com/NagiosEnterprises/nc ... HANGES.rst
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked