Page 1 of 2

Error check_nna.py

Posted: Wed Feb 10, 2021 5:38 am
by nagmites
Hi there,

When I run check_nna.py command I get the following error:

UNKNOWN - Error occurred while running the plugin

On the command line with the verbose option, the following error is displayed:

And error was encountered:
local variable 'text_type' referenced before assignment


Any idea what may be happening?

Thank you a lot

Re: Error check_nna.py

Posted: Wed Feb 10, 2021 12:34 pm
by dchurch
Hi!

That's a bug in the script that we should hopefully have fixed in the next release.

What it should have told you instead is that the option --source NAME (AKA -S NAME) or --sourcegroup NAME (AKA -G NAME) must be specified.

You may be running this under Python 3, which this plugin isn't compatible with. What's the output from this command:

Code: Select all

python --version

Re: Error check_nna.py

Posted: Thu Feb 11, 2021 6:36 am
by nagmites
Hi there!
Thank you a lot for your answer.
We have updated python,

python --version
Python 3.6.8


The command output is now as follows

./check_nna.py -H 10.16.70.11 -K 6b35edcce726bfdc1e5233608d48c85ac9c7af2 --source VMFABRICNETFLOW --exists --secure --verbose
File "./check_nna.py", line 159
print "DOWN - The " + text_type + " you are trying to use doesn't exist"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("DOWN - The " + text_type + " you are trying to use doesn't exist")?

Thanks

Re: Error check_nna.py

Posted: Thu Feb 11, 2021 1:29 pm
by dchurch
Do you have python2 installed on your machine?

Code: Select all

which -a python2
python2 --version

Re: Error check_nna.py

Posted: Fri Feb 12, 2021 5:12 am
by nagmites
Hi there!

Yes,

which -a python2
/usr/bin/python2
python2 --version
Python 2.7.5


That's the problem, right?

Thanks!

Re: Error check_nna.py

Posted: Fri Feb 12, 2021 12:41 pm
by dchurch
The way I see it you can solve this one of three ways:

Option 0
Fix the symlink so that /usr/bin/python points to python2 - This is the default on CentOS, Ubuntu, Debian, etc. Not sure why your system has it pointing to python3:

Code: Select all

ln -sf python2 /usr/bin/python
Option 1
Modify check_nna.py so that the first line reads #!/usr/bin/env python2. This won't fix the other scripts that assume "python" means "python2".

Option 2
Update check_nna.py so that it runs in Python 3.x and send it my way so I can submit a merge request to our internal code depot, then wait for the next release.

Re: Error check_nna.py

Posted: Tue Feb 16, 2021 3:35 am
by nagmites
Hi there

I'm confused with your answer.
You have told me that the plugin does not work with python 2, why change the script to point to that version?

Thanks

Re: Error check_nna.py

Posted: Tue Feb 16, 2021 1:34 pm
by dchurch
nagmites wrote:You have told me that the plugin does not work with python 2
If I implied that, I'm sorry. That's not what I'm saying.

The plugin does not work in Python 3. In fact, many plugins that Nagios uses are designed to run in Python 2.x, and will need to be re-written if they are to run in Python 3. Much of the code in those plugins assumes that /usr/bin/python is Python 2.x (the default on CentOS), and not Python 3.x (in your machine's case).

/usr/bin/python should be Python 2 or plugins will break.

Again, the fix for this:

Code: Select all

ln -sf python2 /usr/bin/python
I've learned that there's a package python-is-python3 that causes the /usr/bin/python to point to python3, which is wrong. You'll want to uninstall that package if you have it installed.

Re: Error check_nna.py

Posted: Wed Feb 17, 2021 3:00 am
by nagmites
Hi there,

Ok,
With phyton 2 the error is the following:

/usr/local/nagios/libexec/check_nna.py -H 10.16.70.11 -K 46b35edcce726bfdc1e5233608d48c85ac9c7af2 -S 2 --exists --secure UNKNOWN - Error occurred while running the plugin.
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)>

This service has been generated automatically with the wizard


The same problem as when I asked the first time.

Thank you a lot

Re: Error check_nna.py

Posted: Wed Feb 17, 2021 5:56 pm
by dchurch
I'd either use the FQDN after -H, or add --ignorecert to the option list.

For example:

Code: Select all

check_nna.py -H my-hostname.example.com -K 46b35edcce726bfdc1e5233608d48c85ac9c7af2 -S 2 --exists --secure
-OR-

Code: Select all

check_nna.py -H 10.16.70.11 -K 46b35edcce726bfdc1e5233608d48c85ac9c7af2 -S 2 --exists --secure --ignorecert