Error check_nna.py

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
nagmites
Posts: 24
Joined: Fri Aug 14, 2020 6:05 am

Error check_nna.py

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Error check_nna.py

Post 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
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
nagmites
Posts: 24
Joined: Fri Aug 14, 2020 6:05 am

Re: Error check_nna.py

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Error check_nna.py

Post by dchurch »

Do you have python2 installed on your machine?

Code: Select all

which -a python2
python2 --version
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
nagmites
Posts: 24
Joined: Fri Aug 14, 2020 6:05 am

Re: Error check_nna.py

Post by nagmites »

Hi there!

Yes,

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


That's the problem, right?

Thanks!
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Error check_nna.py

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
nagmites
Posts: 24
Joined: Fri Aug 14, 2020 6:05 am

Re: Error check_nna.py

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Error check_nna.py

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
nagmites
Posts: 24
Joined: Fri Aug 14, 2020 6:05 am

Re: Error check_nna.py

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Error check_nna.py

Post 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
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked