Check_TCP Plugin - Windows Server 2019

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
DerekNagiosXI
Posts: 14
Joined: Thu Apr 29, 2021 1:08 pm

Check_TCP Plugin - Windows Server 2019

Post by DerekNagiosXI »

Good Afternoon,

Have the check_tcp on the windows server under C:\Program Files (x86)\Nagios\NCPA\plugins
Running into error - UNKNOWN: An error occurred connecting to API. (HTTP error: '500 INTERNAL SERVER ERROR')
Here is $ARG1$ parameter - -t 'xxxx' -P 5693 -M 'plugins/check_tcp' -q 'args=-H [email protected] -p xx'
I believe my context in $ARG1$ needs to be modified, this plugin is working great on linux servers.
I do know that for the linux servers, i have to run chown nagios so my question is, could my error be due to permissions for the windows server?
Thanks for your help.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Check_TCP Plugin - Windows Server 2019

Post by pbroste »

Hello @DerekNagiosXI

Thanks for reaching out on 'check_tcp' plugin 500 error condition.

Want to verify that we are able to view the 'ncpa' web console:

Code: Select all

https://yourwindowsserver2019:5693
  • Image
For raw api results:

Code: Select all

curl -k https://yourwindowsserver2019:5693/api/plugins/check_tcp.exe?args=-H localhost&args=-p 5693&args=-c 22&args=-w 3
To verify from Linux command line from your Nagios XI instance:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourwindowsserver2019 -t welcome -M 'plugins/check_tcp' -q 'args= -H hosttocheckhere -p 5693'
Allow hosts in the 'ncpa.cfg' configured to allow found in the /nagios/ncpa/etc/ directory:
allowed_hosts = xxx.xxx.xxx.0/24
For testing purposes, I gave "everyone" full access permissions on the '/plugin/check_tcp'.

Let us know how things look,
Perry
DerekNagiosXI
Posts: 14
Joined: Thu Apr 29, 2021 1:08 pm

Re: Check_TCP Plugin - Windows Server 2019

Post by DerekNagiosXI »

pbroste wrote:Hello @DerekNagiosXI

Thanks for reaching out on 'check_tcp' plugin 500 error condition.

Want to verify that we are able to view the 'ncpa' web console:

Code: Select all

https://yourwindowsserver2019:5693
  • Image
For raw api results:

Code: Select all

curl -k https://yourwindowsserver2019:5693/api/plugins/check_tcp.exe?args=-H localhost&args=-p 5693&args=-c 22&args=-w 3
To verify from Linux command line from your Nagios XI instance:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourwindowsserver2019 -t welcome -M 'plugins/check_tcp' -q 'args= -H hosttocheckhere -p 5693'
Allow hosts in the 'ncpa.cfg' configured to allow found in the /nagios/ncpa/etc/ directory:
allowed_hosts = xxx.xxx.xxx.0/24
For testing purposes, I gave "everyone" full access permissions on the '/plugin/check_tcp'.

Let us know how things look,
Perry
Thank you for the reply. Confirmed I am able to view NCPA web console.
Updated allow hosts in the ncpa.cfg and error message changed to
UNKNOWN: An error occured connecting to API. (HTTP error: '403 FORBIDDEN')
Verified token is correct.

Tried redownloading check_ncpa and replacing on my server. Please advise.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Check_TCP Plugin - Windows Server 2019

Post by pbroste »

Hello @DerekNagiosXI

Thanks for following up, what do you get for results on the command line and the option to add -v or --verbose to see more information.

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourwindowsserver2019 -t welcome -M 'plugins/check_tcp' -q 'args= -H hosttocheckhere -p 5693' --verbose
Or if the plugin is in your '/nagios/libexec/.' on your server:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourwindowsserver2019 -t welcome -M 'check_tcp' -q 'args= -H hosttocheckhere -p 5693' --verbose
Let us know the results,
Perry
DerekNagiosXI
Posts: 14
Joined: Thu Apr 29, 2021 1:08 pm

Re: Check_TCP Plugin - Windows Server 2019

Post by DerekNagiosXI »

Tried off the server, got
An error occurred:
UNKNOWN: An error occured connecting to API. (HTTP error: '500 INTERNAL SERVER ERROR')
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Check_TCP Plugin - Windows Server 2019

Post by pbroste »

Hello @DerekNagiosXI

Typical reasons to see 500 errors include; permissions, coding, and perhaps redirect issues.

To further dig let's verify:

Date and time are the same across.

Update the 'nagios' User Account:

Code: Select all

chage -I -1 -m 0 -M 99999 -E -1 nagios
Verify the user and the 'check_ncpa.py' command:

Code: Select all

whoami
Results:
root
List permissions:

Code: Select all

ls -l /usr/local/nagios/libexec/check_ncpa.py
Results:
-rwxr-xr-x. 1 apache nagios size mon day hh:mm /usr/local/nagios/libexec/check_ncpa.py
Switch to nagios User Account:

Code: Select all

su -l nagios
Run with 'nagios' User Account:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourhostyouarecheckinghere -V
Results:
check_ncpa.py, Version 1.2.4
We verified the 'check_ncpa.py'; now lets check via the Windows command that 'plugins/check_tcp' <yourargshere> passes. Also, test by adding 'Everyone' with full control.

Once verified that the 'check_ncpa.py' and the 'check_tcp' each pass when execute separately. Then integrate the commands and run:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H yourwindowsserver2019 -t welcome -M 'plugins/check_tcp' -q 'args= -H hosttocheckhere -p 5693' --verbose
Thanks,
Perry
Locked