Some questions about NCPA

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.
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

lmiltchev wrote:1.

Code: Select all

grep nag /etc/group

Code: Select all

2. service iptables stop
3. Also, I wanted to see the "nagios.conf", not the "nagios.cfg". It should be in: "/etc/httpd/conf.d/nagios.conf".
1.

Code: Select all

nagios:x:501:
nagcmd:x:502:nagios,apache
2. What's the command to start them again?

Code: Select all

service iptables start
?

3.
nagios.conf
(1.64 KiB) Downloaded 153 times
<>

edit:

Okay, tried to make my own command for active checks. This survives the validation check:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Code: Select all

define command{
	command_name		check_ncpa
	command_line		/usr/local/nagios/libexec/./check_ncpa.py -H $HOSTADDRESS$ -t nagi_os_NCPA -M CPU/Percentage
	}

define service{
	use			generic-service
	host_name		winserver
	service_description	NCPA CPU Percent
	check_command		check_ncpa
	}
However it produces the following error message in the web interface:

Code: Select all

(Return code of 13 is out of bounds)
Okay, it returns a different error message now... I guess check_ncps.py returns value is not compatible to the web interface?!

Also, I've tried to use added arguments:

Code: Select all

define command{
	command_name		check_ncpa
	command_line		/usr/local/nagios/libexec/check_ncpa.py -H $HOSTADDRESS$ -t nagi_os_NCPA -M $ARG1$
	}

define service{
	use			generic-service
	host_name		winserver
	service_description	NCPA CPU Percent
	check_command		check_ncpa|CPU
	}
If I try to vertify that it returns 1 error:

Code: Select all

Error: Service check command 'check_ncpa|CPU' specified in service 'NCPA CPU Percent' for host 'winserver' not defined anywhere!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Some questions about NCPA

Post by lmiltchev »

Yes, you can start iptables by running:

Code: Select all

service iptables start
As for the command and a service definitions, can you try the following?

Code: Select all

define command{
   command_name      check_ncpa
   command_line      /usr/local/nagios/libexec/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
   }
   
define service{
   use         generic-service
   host_name      winserver
   service_description   NCPA CPU Percent
   check_command      check_ncpa!-t 'nagi_os_NCPA' -P 5693 -M cpu/percent -w 80 -c 90
   }
Let me know if this helped. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

lmiltchev wrote:As for the command and a service definitions, can you try the following?
Oh, I understand why my method was not working; I used "|", not "!", as a delimiter. Thanks.
Btw: Is two arguments the maximum?

I still get the error "(Return code of 13 is out of bounds)", though.

So, any idea how to get the NRDP server working? That's the config file of NRDP if it is of any help:
nrdp.conf
(344 Bytes) Downloaded 168 times
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Some questions about NCPA

Post by lmiltchev »

Btw: Is two arguments the maximum?
You can place whatever you want after the delimiter - it is still going to be "$ARG1$". See the plugin's usage by running:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -h
I still get the error "(Return code of 13 is out of bounds)", though.
Where do you see this error? Can you show us a screenshot? Also, show us the actual command run from the command line, along with the output of it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

lmiltchev wrote:Where do you see this error? Can you show us a screenshot? Also, show us the actual command run from the command line, along with the output of it.
Command:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.56.1 -t 'nagi_os_NCPA' -P 5693 -M cpu/percent -w 80 -c 90
Output:

Code: Select all

OK: percent was 29%,30%,33% | 'percent_0'=29%;80;90; 'percent_1'=30%;80;90; 'percent_2'=33%;80;90;
Screenshot: (the other error message can be ignored, they are using outdated code)
Web Interface Error Message.jpg
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Some questions about NCPA

Post by lmiltchev »

The good news is that your check works from the command line. Let's find out why it is failing in the web UI.

Did you restart nagios after making the changes to the "check_ncpa" command and the "NCPA CPU Percent" service definitions? Can you post these two configs along with the "winserver" host's config?
Be sure to check out our Knowledgebase for helpful articles and solutions!
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

Just to be sure I entered these two commands again:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/rc.d/init.d/nagios reload
Not really changed anything in this file except that windows.cfg should be loaded:
nagios.cfg
(43.78 KiB) Downloaded 154 times
I did not removed the old code here:
windows.cfg
(4.25 KiB) Downloaded 185 times
"winservers" host config (NCPA.cfg on the client):
ncpa.cfg
(1.11 KiB) Downloaded 170 times
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Some questions about NCPA

Post by lmiltchev »

I didn't see any issues in these configs. I would recommend removing the command definition from windows.cfg and placing it in commands.cfg (for consistency):

Code: Select all

define command{
   command_name      	check_ncpa
   command_line      	/usr/local/nagios/libexec/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
   }
Can you run the following commands and post the output:

Code: Select all

uname -a
cat /etc/*release
ls -la /usr/local/nagios/libexec/check_ncpa.py
/usr/local/nagios/libexec/check_ncpa.py -V
ps -ef | grep bin/nagios
Be sure to check out our Knowledgebase for helpful articles and solutions!
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

uname -a

Code: Select all

Linux Scientific.Linux.Server 2.6.32-573.3.1.el6.x86_64 #1 SMP Thu Aug 13 12:55:33 CDT 2015 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/*release

Code: Select all

LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Scientific Linux release 6.7 (Carbon)
Scientific Linux release 6.7 (Carbon)
ls -la /usr/local/nagios/libexec/check_ncpa.py

Code: Select all

-rwxr--r--. 1 root root 9332  8. Sep 06:25 /usr/local/nagios/libexec/check_ncpa.py
/usr/local/nagios/libexec/check_ncpa.py -V

Code: Select all

check_ncpa.py, Version 0.3.5
ps -ef | grep bin/nagios

Code: Select all

nagios    1784     1  0 Sep08 ?        00:00:43 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios    1814  1784  0 Sep08 ?        00:00:25 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root      2342  2597  0 22:28 pts/0    00:00:00 grep bin/nagios
nagios   32746  1784  0 20:14 ?        00:00:03 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios   32747  1784  0 20:14 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios   32748  1784  0 20:14 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios   32749  1784  0 20:14 ?        00:00:00 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
RandomGuy86
Posts: 21
Joined: Tue Sep 08, 2015 10:12 am

Re: Some questions about NCPA

Post by RandomGuy86 »

Solved my issue with active checks with NCPA.

If you ever encounter this "error of 13" error, the most likely cause seems to be wrongly set owner of rwx rights of a file; in my case it was the file check_ncpa.py. The user Nagios was not allowed to execute the file.

The following command fixed this issue for me:

Code: Select all

chmod o+x usr/local/nagios/libexec/check\_ncpa.py
Alternatively one could also give ownership to the user Nagios.

<>

edit:
Okay, I still have an issue with NCPA when the client is Linux.

To make sure the Nagios Server can connect to the Linux Client I've added the following line to /etc/sysconfig/iptables

Code: Select all

-A INPUT -p tcp --dport 5693 -j ACCEPT
However I cannot access the API from another machine.
When I disable iptables it works.

edit2:
Another little issue I have with NCPA:
How do I translate this URL:

Code: Select all

https://192.168.56.1:5693/api/memory/virtual?check=1?token=nagi_os_NCPA
Into a command: (in particular the ?check=1)

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 192.168.56.1 -t nagi_os_NCPA -P 5693 -M memory/virtual -n M ?check=1
<>

So, now I just have to get my passive checks working (with NRDP).
Locked