check_ncpa.py broken on Centos 7 epel repo install FIXED

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_ncpa.py broken on Centos 7 epel repo install FIXED

Postby Guyver1 » Sat Aug 10, 2019 4:01 pm

NOTE: I have this working on a separate Centos 7 minimal install but I installed nagios from source so something is not the same when installing as below:

Fresh minimal Centos install (with developer tools and sysadmin tools installation options ticked)
yum install epel-release
yum install nagios nagios-plugins-all
systemctl start nagios.service
systemctl start httpd.service
systemctl enable nagios
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload


Logged in to nagios web page successfully and confirmed localhost checks were working and returning OK.

[root@nagios-yum tmp]# whereis nagios
nagios: /usr/sbin/nagios /usr/lib64/nagios /etc/nagios /usr/share/nagios

Nagios Plugins Folder:
/usr/lib64/nagios/plugins

Tested ./check_ups --help and this worked as expected.

wget https://assets.nagios.com/downloads/ncp ... cpa.tar.gz
tar zxf check_ncpa.tar.gz
chown nagios:nagios check_ncpa.py
chmod 775 check_ncpa.py
cp check_ncpa.py /usr/lib64/nagios/plugins
cd /usr/lib64/nagios/plugins
./check_ncpa.py -V
: No such file or directory

[root@nagios-yum plugins]# python
Python 2.7.5 (default, Jun 20 2019, 20:27:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[root@nagios-yum plugins]# which python
/usr/bin/python
[root@nagios-yum plugins]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz


Modified shebang in check_ncpa.py to #!/usr/bin python
[root@nagios-yum plugins]# ./check_ncpa.py -V
-bash: ./check_ncpa.py: /usr/bin: bad interpreter: Permission denied


I noticed that all other plugins have 3 whereas check_ncpa.py has 10:
ls -al /usr/lib64/nagios/plugins
-rwxr-xr-x. 1 nagios nagios 49664 Jan 3 2019 check_mrtgtraf
-rwxr-xr-x. 1 nagios nagios 62528 Jan 3 2019 check_mysql
-rwxr-xr-x. 1 nagios nagios 58208 Jan 3 2019 check_mysql_query
-rwxr-xr-x. 1 nagios nagios 53768 Jan 3 2019 check_nagios
-rwxr-xr-x. 1 nagios nagios 10563 Aug 10 21:41 check_ncpa.py
lrwxrwxrwx. 1 nagios nagios 9 Aug 10 21:29 check_nntp -> check_tcp
lrwxrwxrwx. 1 nagios nagios 9 Aug 10 21:29 check_nntps -> check_tcp
-rwxr-xr-x. 1 nagios nagios 66336 Jan 3 2019 check_nt
-rwxr-xr-x. 1 nagios nagios 14360 Jan 3 2019 check_ntp
-rwxr-xr-x. 1 nagios nagios 62536 Jan 3 2019 check_ntp_peer
-rwxr-xr-x. 1 nagios nagios 14360 Jan 3 2019 check_ntp.pl



Am i missing something?? Is anyone able to help me get the check_ncpa.py plugin working??

Thanks in advance.
Last edited by Guyver1 on Mon Aug 12, 2019 9:06 am, edited 1 time in total.
Guyver1
 
Posts: 16
Joined: Tue Apr 16, 2019 4:43 am

Re: check_ncpa.py broken on Fresh Centos 7 epel repo install

Postby Guyver1 » Sun Aug 11, 2019 8:06 am

So I have fixed this but my fix means there may be something wrong with the check_npca.tar.gz file currently available on the nagios website.

SOLUTION:
I copied the check_ncpa.py file from my working nagios server (source installation type) as I noticed it was a different size to the file downloaded last night on my repo installation server.

Working check_ncpa.py file:
-rwxr-xr-x. 1 root root 10264 Aug 11 14:01 check_ncpa.py

NON-WORKING file downloaded last night from nagios website using wget:
wget https://assets.nagios.com/downloads/ncp ... cpa.tar.gz
tar zxf check_ncpa.tar.gz
-rwxrwxrwx. 1 root root 10567 May 1 20:21 check_ncpa.py

I believe the issue is with the file currently available from the nagios website.

Since copying the working file, my repo installed nagios is now reporting the correct result:
[root@nagios-yum plugins]# ./check_ncpa.py -V
check_ncpa.py, Version 1.1.5
Guyver1
 
Posts: 16
Joined: Tue Apr 16, 2019 4:43 am

Re: check_ncpa.py broken on Fresh Centos 7 epel repo install

Postby Guyver1 » Sun Aug 11, 2019 11:23 am

ok so I thought I'd fixed it but a separate issue has appeared now that I have migrated my config files over and I'm monitoring my hosts.

any check_ncpa.py check on a remote host is failing with:
[1565539496] Warning: Return code of 13 for check of service 'Host Time Zone' on host 'V-ADC-001' was out of bounds.

Logged in as root I can run successfully:
[root@nagios-yum plugins]# ./check_ncpa.py -H 192.168.150.133 -P 5693 -t 'thisismytoken' -M 'disk/logical/C:|/used_percent' -w 90 -c 95 -u Gi
OK: Used_percent was 24.80 % | 'used_percent'=24.80%;90;95;

but it appears that the nagios user cannot successfully run check_ncpa.py ??

I have checked my working nagios server against the new repo installed server and the nagios user does have diffferences:
source installed:
[root@V-NAGIOS-01 objects]# cat /etc/passwd
nagios:x:1001:1001::/home/nagios:/bin/bash

repo installed:
[root@nagios-yum nagios]# cat /etc/passwd
nagios:x:997:995::/var/spool/nagios:/sbin/nologin

would this cause an error 13 out of bounds?
Anything else I need to check?
Guyver1
 
Posts: 16
Joined: Tue Apr 16, 2019 4:43 am

Re: check_ncpa.py broken on Fresh Centos 7 epel repo install

Postby Guyver1 » Sun Aug 11, 2019 2:54 pm

changed nagios in passwd to /bin/bash

su nagios

bash-4.2$ ./check_ncpa.py -H 192.168.150.133 -P 5693 -t 'thisismytoken' -M 'disk/logical/C:|/used_percent' -w 90 -c 95 -u Gi
OK: Used_percent was 24.80 % | 'used_percent'=24.80%;90;95;


so it works from the command line when running under nagios and root

[root@nagios-yum private]# cat resource.cfg
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib64/nagios/plugins

my command:
### NCPA AGENT ###
define command {
command_name check_ncpa
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ -t 'thisismytoken' -P 5693 $ARG1$
}


I'm a bit stumped now :(
Guyver1
 
Posts: 16
Joined: Tue Apr 16, 2019 4:43 am

Re: check_ncpa.py broken on Centos 7 epel repo install FIXED

Postby Guyver1 » Mon Aug 12, 2019 9:07 am

seems the check_ncpa.py file had windows line endings and the people looking after it on github have uploaded a correct verison.

deleted my VM and spun up a new one and installed nagios from epel repo fresh and check_ncpa.py checks now working as expected.
Guyver1
 
Posts: 16
Joined: Tue Apr 16, 2019 4:43 am

Re: check_ncpa.py broken on Centos 7 epel repo install FIXED

Postby scottwilkerson » Mon Aug 12, 2019 9:57 am

Good to hear it is resolved!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 7 guests