Page 1 of 2

UNKNOWN: An error occured connecting to API. (Connection err

Posted: Thu Oct 21, 2021 12:59 am
by preethu.d
Hi Team,

I am getting the below error for a linux server.

"UNKNOWN: An error occured connecting to API. (Connection error: '[Errno 111] Connection refused')"

I tried uninstalling and reinstalling NCPA but still issue remains same.
port 5693 is not listening and there is no internal firewall enabled on the server.
attached the logs.

Regards,
Preethu

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Thu Oct 21, 2021 2:10 pm
by ssax

Code: Select all

error: [Errno 97] Address family not supported by protocol
That system may have IPv6 disabled, try editing your ncpa.cfg on the remote system (not the XI server) and set this under the [listener] section:

Code: Select all

ip = 0.0.0.0
Then restart the listener on the remote server (not the XI server):

Code: Select all

systemctl restart ncpa_listener
Then test again and see if it resolved it.

If it's still not working, attach your ncpa.cfg from the remote system and send this information:

What OS/version is the remote system running?

Code: Select all

uname -a
cat /etc/*release
What NCPA version is the remote system running?

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Sat Oct 23, 2021 12:23 pm
by preethu.d
Hi,

I have made the changes but issue persists. I have attached the screenshot with OS details and ncpa.cfg file.
ncpa version:ncpa-2.2.2-1x86_64

Regards,
Preethu

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Mon Oct 25, 2021 10:48 am
by pbroste
Hello @preethu.d

Thanks for providing the details, want to take a look at verbose details on the 'ncpa_listener' service restart. We are still unclear as to what is causing it to throw the error(s).

Code: Select all

systemctl restart nagios.service && journalctl -u ncpa_listener.service > /tmp/ncpa_results.txt && journalctl -u ncpa_listener.service -o verbose >> /tmp/ncpa_results.txt
Please provide the results on the /tmp/ncpa_results.txt.

Thanks,
Perry

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Tue Oct 26, 2021 7:09 am
by preethu.d
Hi Perry,

I have sent the requested log via PM.

Regards,
Preethu

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Tue Oct 26, 2021 10:38 am
by pbroste
Hello @preethu.d

Thanks for following up, after reviewing of the ncpa.cfg, we want to move the 'ip = 0.0.0.0' up to the "listener configuration (daemon)".
# -------------------------------
# Listener Configuration (daemon)
# -------------------------------
#

[listener]

#
# User and group to run plugins as (recommended to use nagios:nagios)
# Default: uid = nagios
# Default: gid = nagios
#
# ** Note - The daemon runs as root, but forks a child process when running a plugin
# that is defined by the user, for security reasons. However, without the main daemon
# running as root, much of the system information would be missing. This is typical behavior. **
#
# This is for Unix only (Linux, Mac OS X, etc)
#
uid = nagios
gid = nagios

#
# IP address and port number for the Listener to use for the web GUI and API
#
# :: allows for dual stack (IPv4 and IPv6 on most linux systems) but will only allow
# for IPv6 connections on Windows
# 0.0.0.0 allows for IPv4 connections only on Windows and most linux systems
#
# Default: ip = ::
# Default (Windows): ip = 0.0.0.0
# Default: port = 5693
#
ip = ::,0.0.0.0
# port =
Restart the 'ncpa_listener' and view the status:

Code: Select all

systemctl restart ncpa_listener

Code: Select all

systemctl status ncpa_listener

Code: Select all

sudo ss -tulpn | grep -Ei 'LISTEN|ESTABLISHED' > /tmp/ncpa_listener.txt
Please send the '/tmp/ncpa.txt' so we can review the configuration and info.

Thanks,
Perry

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Wed Oct 27, 2021 4:00 am
by preethu.d
Hi Perry,

I have made the changes and sent you the log via PM.

Regards,
Preethu

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Wed Oct 27, 2021 11:15 am
by pbroste
Hello @preethu.d

Thanks for sending the 'netstat' info over, and we don't see anything related to ncpa service or port, but we do know that everything is reference ipv4.

Let's find out if server will listen on port 5693 ruling out ncpa on your server by:

Code: Select all

ssh root@localhost -L 5693:localhost:5693
My test server we then see:

Code: Select all

sudo ss -tulpn | grep -Ei 'LISTEN|ESTABLISHED'
Results:
tcp LISTEN 0 128 127.0.0.1:5693 0.0.0.0:* users:(("ssh",pid=199174,fd=7))
Let's see if 'ncpa_listener' will connect on port 5693 going through the ssh tunnel:

Code: Select all

systemctl start ncpa_listener
Then;

Code: Select all

systemctl status ncpa_listener
Please let us know how things look,
Perry

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Thu Oct 28, 2021 8:54 pm
by preethu.d
Hi Perry,

I have executed the steps but ncpa_listener service still shows active (exited)
It shows output for port 5693 as below.

tcp LISTEN 0 128 127.0.0.1:5693 0.0.0.0:* users:(("ssh",pid=133982,fd=4))

Regards,
Preethu

Re: UNKNOWN: An error occured connecting to API. (Connection

Posted: Fri Oct 29, 2021 1:37 pm
by pbroste
Hello @preethu.d

Thanks for following up, appears that you were able to verify 'ncpa_listener' service on port 5693 is listening through forward.

To verify ncpa_listener status:

Code: Select all

systemctl status ncpa_listener
Do you get check results on 'check_ncpa.py' (linux)

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourhostaddresshere -P 5693 -t yourtokenhere -M 'disk/logical/|boot/used_percent' -w 80 -c 90
Let me know how things are looking,
Perry