check_ncpa.py plugin no longer working
check_ncpa.py plugin no longer working
G'day all,
I have a Nagios v4.3.4 instance running on CentOS 7 that includes usage of the check_ncpa.py plugin to monitor Windows hosts. This has been running fine for a while. We ran an update on Friday that pulled the latest NCPA plugin script from https://assets.nagios.com/downloads/ncp ... cpa.tar.gz, and it no longer works. I can see that the files have definitely changed as the new file is a bit larger in addition to the activity in GitHub. When running the plugin now I get this (which includes a return code of 127):
[libexec]$ ls -l check_ncpa.py
-rwxr-xr-x. 1 nagios nagios 10278 Feb 8 03:31 check_ncpa.py
[libexec]$ ./check_ncpa.py
: No such file or directory
Does anyone know of this issue, or can anyone provide some assistance in troubleshooting it?
Thanks
I have a Nagios v4.3.4 instance running on CentOS 7 that includes usage of the check_ncpa.py plugin to monitor Windows hosts. This has been running fine for a while. We ran an update on Friday that pulled the latest NCPA plugin script from https://assets.nagios.com/downloads/ncp ... cpa.tar.gz, and it no longer works. I can see that the files have definitely changed as the new file is a bit larger in addition to the activity in GitHub. When running the plugin now I get this (which includes a return code of 127):
[libexec]$ ls -l check_ncpa.py
-rwxr-xr-x. 1 nagios nagios 10278 Feb 8 03:31 check_ncpa.py
[libexec]$ ./check_ncpa.py
: No such file or directory
Does anyone know of this issue, or can anyone provide some assistance in troubleshooting it?
Thanks
Re: check_ncpa.py plugin no longer working
Please show us the location of check_ncpa.py
Please run this from the command line and show us the output.
Code: Select all
find / -name check_ncpa.py
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py
Re: check_ncpa.py plugin no longer working
I did include that info in my original post, though maybe I didn't present it clearly enough (probably should have formatted it better and included a pwd)
Code: Select all
[~]$ sudo find / -name check_ncpa.py
/usr/local/nagios/libexec/check_ncpa.py
[~]$ /usr/local/nagios/libexec/check_ncpa.py
: No such file or directory
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_ncpa.py plugin no longer working
Let's make sure it isn't dying right when it is looking for python
lets run
send them back to this post
lets also try
lets run
Code: Select all
ls -al /usr/bin/env
which python
lets also try
Code: Select all
cd /usr/local/nagios/libexec
python check_ncpa.py
Re: check_ncpa.py plugin no longer working
Seems like we're narrowing it down...
To add a bit more info: I have two separate environments, UAT and PROD. Both were running fine for months, and I know both are set up exactly the same as I use Ansible to configure them. A playbook was run on the UAT server the other day which pulled in a new version of the check_ncpa.py script and it hasn't worked since. PROD has not had the script updated and is still working fine. Given the outcome of the above test I checked the shebang at the top of both scripts and they are the same: #!/usr/bin/env python. The output of the commands I ran above are the same on both servers. Both servers are running Python 2.7.5.
Thanks for the assistance so far.
Code: Select all
[libexec]$ ls -al /usr/bin/env
-rwxr-xr-x. 1 root root 28992 Nov 6 2016 /usr/bin/env
[libexec]$ which python
/usr/bin/python
[libexec]$ python check_ncpa.py
Usage: check_ncpa.py [options]
...
Thanks for the assistance so far.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_ncpa.py plugin no longer working
I'm guessing this is going to work but lets try it anyways, if you replace the shebang with this, does it work?
Does it work?
And if so, we need to figure out why in this machine this doesn't return proper
Code: Select all
#!/usr/bin/python
And if so, we need to figure out why in this machine this doesn't return proper
Code: Select all
/usr/bin/env python
Re: check_ncpa.py plugin no longer working
G'Day Scott,
Thanks again for the reply. Output of your requests below:
If I copy the check_ncpa.py file from our production server - it's the previous version - it works fine. In the output below, the .bak file is the most recent file from https://assets.nagios.com/downloads/ncp ... cpa.tar.gz and the .py file is the copy from our prod system.
Thanks again,
Matt
Thanks again for the reply. Output of your requests below:
Code: Select all
[libexec]$ head -n 3 check_ncpa.py
#!/usr/bin/python
"""
SYNOPSIS
[libexec]$ ./check_ncpa.py
-bash: ./check_ncpa.py: /usr/bin/python^M: bad interpreter: No such file or directory
[libexec]$ /usr/bin/python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Code: Select all
[libexec]$ ls -l check_ncpa*
-rwxr-xr-x. 1 nagios nagios 9820 Mar 8 10:32 check_ncpa.py
-rwxr-xr-x. 1 nagios nagios 10274 Mar 8 10:27 check_ncpa.py.bak
Matt
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_ncpa.py plugin no longer working
This means however this file was edited it got windows line endings on itCode: Select all
-bash: ./check_ncpa.py: /usr/bin/python^M: bad interpreter: No such file or directory
which leads me to an interesting question, when you downloaded it, how did you get in on the server? Did you download it directly and untar it, or did you download it to a windows machine and somehow copy the text for the file over?
I would strongly suggest doing this to get the file on the server:
Code: Select all
wget https://assets.nagios.com/downloads/ncpa/check_ncpa.tar.gz
tar xzf check_ncpa.tar.gz
chmod +x check_ncpa.py
cp check_ncpa.py /usr/local/nagios/libexec/
Re: check_ncpa.py plugin no longer working
I used the Ansible unarchive command, which downloads the file from assets.nagios.com directly to the target server and uncompresses it there. My Ansible control machine is also a MacBook so there were no Windows machines involved. Perhaps the packaged file itself has Windows line endings in it? Both the UAT and PROD servers were originally set up this way and worked fine until this new file. I'll try and directly wget it again tomorrow when I'm back at work just in case but I'm pretty sure I haven't altered that file in any way.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: check_ncpa.py plugin no longer working
oh my goodness it does....
I have modified it and am attaching it here
I will contact the developer to have this adjusted
I have modified it and am attaching it here
I will contact the developer to have this adjusted
- Attachments
-
- check_ncpa.py
- (9.75 KiB) Downloaded 591 times