Page 1 of 2

Nagios and NCPA

Posted: Tue Jun 06, 2017 5:26 am
by cerino
Hi guys,
I've problem with Nagios Core and the plugin NCPA, that's the error:
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_ncpa.py, ...) failed. errno is 2: No such file or directory

ans that's the scenario:

Nagios Core 4.3.2 On CentOS 6.9
More than 40 Wiondow Server monitored by Nagios and NSCP succesfully

Client NCPA installed on a ContOS 6.9
Web UI run perfectly and port 5693 is open


NAGIOS CONFIGURATION

COMMAND DEFIN. CFG
define command {
command_name check_ncpa
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ -p 5693 $ARG1$
}

TEMPLATE DEF CFG
define host {
name ncpa
hostgroups ncpa
use generic-host
check_command check_ncpa
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contacts nagiosadmin
notification_interval 60
notification_period 24x7
notifications_enabled 1
register 0
}

SERVER FOLDER CONTAIN THIS CFG

define hostgroup{
hostgroup_name ncpa ; The name of the hostgroup
alias NCPA ; Long name of the group
}

define host{
use ncpa ; Inherit default values from a template
host_name ftp-server ; The name we're giving to this host
alias FTP-SERVER ; A longer name associated with the host
address 10.1.3.4 ; IP address of the host
}

define service{
use generic-service
host_name ftp-server
service_description Agent Version
check_command check_ncpa!-t 'mytoken' -P 5693 -M system/agent_version
}

define service{
use generic-service
host_name ftp-server
service_description CPU Usage
check_command check_ncpa!-t 'topconsult' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
}


RESOURCE CFG
$USER1$=/usr/local/nagios/libexec


Python is installed, version 2.6.6
...but something sounds bad, when I try to run this check (inside folder libexec where i copy check_ncpa.py)
./check_ncpa.py -H 10.1.3.4 -t mytoken -M 'memory/virtual/percent'
console give me an error: No such file or direcotry

Plugin check_ncpa.py version 1.1.1 is in folder /usr/local/nagios/libexec with 755 permission for the user "nagios".


Any suggestion?
I've a big headache

Thanks man!

Re: Nagios and NCPA

Posted: Tue Jun 06, 2017 12:31 pm
by lmiltchev
Can you run the following commands on the remote box (10.1.3.4), and show the output?

Code: Select all

/etc/init.d/ncpa_listener restart
/etc/init.d/ncpa_listener status
/etc/init.d/ncpa_passive restart
/etc/init.d/ncpa_passive status
Also, re-run the command below from the CLI on the Nagios server with increased verbosity, and show the output:

Code: Select all

./check_ncpa.py -H 10.1.3.4 -t mytoken -M 'memory/virtual/percent' -vvv

Re: Nagios and NCPA

Posted: Tue Jun 06, 2017 12:37 pm
by tgriep
In addition to what @lmiltchev asked for, can you run the following on the Nagios server as root and post the output?

Code: Select all

which env
which python
ls -l /usr/bin/env
python -V

Re: Nagios and NCPA

Posted: Wed Jun 07, 2017 3:58 am
by cerino
/etc/init.d/ncpa_listener restart
Stopping NCPA Listener: [ OK ]
Starting NCPA Listener: [ OK ]

/etc/init.d/ncpa_listener status
NCPA Listener: Service is running. (pid 32552)

/etc/init.d/ncpa_passive restart
Stopping NCPA Passive: [ OK ]
Starting NCPA Passive: [ OK ]

/etc/init.d/ncpa_passive status
NCPA Passive: Service is running. (pid 32610)


./check_ncpa.py -H 10.1.3.4 -t mytoken -M 'memory/virtual/percent' -vvv
-bash: ./check_ncpa.py: /usr/bin/python^M: bad interpreter: No such file or directory


which env
/bin/env

which python
/usr/bin/python

ls -l /usr/bin/env
lrwxrwxrwx 1 root root 13 May 4 08:45 /usr/bin/env -> ../../bin/env

python -V
Python 2.6.6

Re: Nagios and NCPA

Posted: Wed Jun 07, 2017 10:47 am
by lmiltchev
-bash: ./check_ncpa.py: /usr/bin/python^M: bad interpreter: No such file or directory
Hmm, I wonder if you have a DOS EOL... Try running the following command on the Nagios box:

Code: Select all

yum install dos2unix -y && dos2unix /usr/local/nagios/libexec/check_ncpa.py
Next, try again:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 10.1.3.4 -t mytoken -M 'memory/virtual/percent' -vvv

Re: Nagios and NCPA

Posted: Thu Jun 08, 2017 5:15 am
by cerino
Yes!!! Solve the problem for me!
Thank you very much

yum install dos2unix -y && dos2unix /usr/local/nagios/libexec/check_ncpa.py
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: it.centos.contactlab.it
* epel: pkg.adfinis-sygroup.ch
* extras: it.centos.contactlab.it
* remi-safe: mirror.23media.de
* updates: it.centos.contactlab.it
Resolving Dependencies
--> Running transaction check
---> Package dos2unix.x86_64 0:3.1-37.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================
Installing:
dos2unix x86_64 3.1-37.el6 base 16 k

Transaction Summary
============================================================================================================================================
Install 1 Package(s)

Total download size: 16 k
Installed size: 18 k
Downloading Packages:
dos2unix-3.1-37.el6.x86_64.rpm | 16 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : dos2unix-3.1-37.el6.x86_64 1/1
Verifying : dos2unix-3.1-37.el6.x86_64 1/1

Installed:
dos2unix.x86_64 0:3.1-37.el6

Complete!
dos2unix: converting file /usr/local/nagios/libexec/check_ncpa.py to UNIX format ...
[root@tc-monitor ~]# /usr/local/nagios/libexec/check_ncpa.py -H 10.1.3.4 -t mytoken -M 'memory/virtual/percent' -vvv
Connecting to: https://10.1.3.4:5693/api/memory/virtua ... lt&check=1
File returned contained:
{
"returncode": 0,
"stdout": "OK: Percent was 45.90 % | 'percent'=45.90%;;;"
}
OK: Percent was 45.90 % | 'percent'=45.90%;;

Re: Nagios and NCPA

Posted: Thu Jun 08, 2017 5:39 am
by cerino
Now I have another question about check command syntax.
As you can see in the attached screen capture probably there's something wrong in the definition service I wrote in Nagios Config file:

define service{
use generic-service
host_name ftp-server
service_description Disk Usage
check_command check_ncpa!-t 'mytoken' -P 5693 -M disk/logical/C:| -w 80 -c 90
}

My goal is to monitor all disk partitions and send an alert message when 80% of disk usage is reached or a critical alert when 90% of disk usage is reached.

Thank you for your patient!

Re: Nagios and NCPA

Posted: Thu Jun 08, 2017 9:02 am
by lmiltchev
I am glad I could help, cerino! For the second problem, try changing this:
define service{
use generic-service
host_name ftp-server
service_description Disk Usage
check_command check_ncpa!-t 'mytoken' -P 5693 -M disk/logical/C:| -w 80 -c 90
}
to this:
define service{
use generic-service
host_name ftp-server
service_description Disk Usage
check_command check_ncpa!-t 'mytoken' -P 5693 -M 'disk/logical/C:|/used_percent' -w 80 -c 90
}
Let me know if this helped.

Re: Nagios and NCPA

Posted: Thu Jun 08, 2017 10:02 am
by cerino
...now is in UNKNOWN Status, as you can see.

Re: Nagios and NCPA

Posted: Thu Jun 08, 2017 10:41 am
by lmiltchev
Can you run the following commands from the command line on the Nagios server, and show the output?

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H 10.1.3.4 -P 5693 -t mytoken -M 'disk/logical/C:|/used_percent' -w 80 -c 90
/usr/local/nagios/libexec/check_ncpa.py -H 10.1.3.4 -P 5693 -t mytoken -M 'disk/logical/C:|/used_percent' -w 80 -c 90 -vvv
Also, show us the service definition of the "Disk Usage" service on the "ftp-server" host. Thanks!