NCPA.py Issue on Ubuntu Server 18.04

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.
Locked
rgoddard
Posts: 1
Joined: Thu May 30, 2019 2:55 pm

NCPA.py Issue on Ubuntu Server 18.04

Post by rgoddard »

When trying to test ncpa.py passive checks against a windows server using ./check_ncpa.py -H hostname -t 'token' -M 'disk/logical/C:|' --units G im getting this error:

/usr/bin/env: ‘python\r’: No such file or directory

I have tried googling the issue but havent really found anything. Can anyone help with this?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: NCPA.py Issue on Ubuntu Server 18.04

Post by npolovenko »

Hello, @rgoddard. This looks like an active check to me.
But the reason why you're seeing the error is because the check_ncpa script starts with:

Code: Select all

#!/usr/bin/env python
It's looking for the python environment variable and it can't find it.

Please run these commands on the server where this command fails and show me the output:

Code: Select all

which python

Code: Select all

/usr/bin/env
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NCPA.py Issue on Ubuntu Server 18.04

Post by mcapra »

The \r implies there may have been some copying+pasting or general file transfer between a Unix and Windows machine that junked-up the line endings. More info:
http://www.cs.toronto.edu/~krueger/csc2 ... dings.html

I'd double-check your file to make sure it's not being run on a Unix system with Windows line-endings. dos2unix is a handy utility to convert those line endings to Unix-friendly ones and may be a good first step.

Code: Select all

yum install dos2unix
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: NCPA.py Issue on Ubuntu Server 18.04

Post by scottwilkerson »

mcapra wrote:The \r implies there may have been some copying+pasting or general file transfer between a Unix and Windows machine that junked-up the line endings. More info:
http://www.cs.toronto.edu/~krueger/csc2 ... dings.html

I'd double-check your file to make sure it's not being run on a Unix system with Windows line-endings. dos2unix is a handy utility to convert those line endings to Unix-friendly ones and may be a good first step.

Code: Select all

yum install dos2unix
You would then run the following to convert the script to the correct line endings:

Code: Select all

dos2unix /usr/local/nagios/libexec/check_ncpa.py
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked