"--refuse=warn" not working from monitoring server

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
dhhh
Posts: 8
Joined: Thu Mar 18, 2021 5:07 am

"--refuse=warn" not working from monitoring server

Post by dhhh »

Hi,
I am trying to get a service check on an app running as a service with check_tcp.

This is on a CentOS 7 server with nagios-plugins-2.3.3-2. I'm using "check_tcp -p <port # of service here> --refuse=warn" for the check_command. It returns "NRPE: Unable to read output" on the Nagios monitoring server when using this (the same check works fine with "--refuse=warn" removed). Running that same check_command on the CentOS 7 server being monitored returns a Linux exit code of 1 (rather than 2) as desired when the service isn't listening on the expected port (I ultimately want the Nagios monitoring server to return WARNING rather than CRITICAL when nothing is listening on the port being checked).

On a Debian 10.6 server with monitoring-plugins-2.2-6 installed, it works fine on the Nagios monitoring server.

Admittedly, I am running Nagios server 3.5.1 compared to much newer nagios-plugins-2.3.3 on the CentOS server. Anyone know if this is a bug or of a workaround? Thanks if anyone can help.
Last edited by dhhh on Wed Mar 31, 2021 6:11 pm, edited 1 time in total.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: "--refuse=warn" not working from monitoring server

Post by mcapra »

dhhh wrote:Anyone know if this is a bug or of a workaround?
I gather you're running NRPE on this CentOS 7 server, and executing the check from your Nagios Core machine (on the Debian 10 server) by leveraging the check_nrpe plugin? Or are you executing the check_tcp plugin directly from the Nagios Core server to the remote CentOS 7 server, and getting that "NRPE: Unable to read output" message? (that would be weird)

If you're using NRPE, here's a brief guide for how to configure commands within NRPE, to be executed remotely via the check_nrpe plugin:
https://support.nagios.com/kb/article/n ... s-759.html

Depending on how NRPE was installed, you might play around with these configuration directives:
https://github.com/NagiosEnterprises/nr ... -arguments
https://github.com/NagiosEnterprises/nr ... characters

My guess is, if you're executing this plugin via NRPE, that you need to adjust the NRPE configurations on the remote machine. If you're simply trying to execute check_tcp from the Nagios Core machine to some remote machine, you don't need NRPE for that and your check_tcp command definition might be malformed. The check_tcp command definition that gets passed to your host/service's check_command directive can represent literally anything; It does not necessarily need to be a command that invokes the check_tcp plugin. The check_command directive always references a command definition, not necessarily a specific plugin.
Former Nagios employee
https://www.mcapra.com/
dhhh
Posts: 8
Joined: Thu Mar 18, 2021 5:07 am

Re: "--refuse=warn" not working from monitoring server

Post by dhhh »

Thanks for the reply. Yes, The Nagios monitoring server is using check_nrpe plugin (i.e not the “weird” option lol). The Debian and CentOS servers being monitored have their nrpe.cfg configured to use check_tcp.

So to outline, the Nagios monitoring server has a service with a check_command line of:
check_command check_nrpe!check_tcp_my_custom_service

And the Debian server being monitored that’s working has the following line (and that works as desired when the Nagios monitoring server runs the check):
command[check_tcp_my_custom_service]=/usr/lib64/nagios/plugins/check_tcp -p 12001 --refuse=warn

But on a newer CentOS server being monitored, the same, above line results in the dreaded ""NRPE: Unable to read output" being returned when the Nagios monitoring server runs the service check (the only difference with the above line is the plugins path is slightly different on this CentOS server than the Debian one – lib64 instead of lib). As a common troubleshooting method, If I run the command from the command line on the CentOS server, it works. FYI The working command executed from the bash shell being:
# /usr/lib/nagios/plugins/check_tcp -p 12001 --refuse=warn
dhhh
Posts: 8
Joined: Thu Mar 18, 2021 5:07 am

Re: "--refuse=warn" not working from monitoring server

Post by dhhh »

I even tried compiling the source code version of the v2.3.3 release of nagios plugins on the CentOS server and using check_tcp from that but I get the same "NRPE: Unable to read output" response when the service check is executed from the Nagios monitoring server (again, the command line run from the CentOS server itself works as expected when executing the check in a shell):
# /usr/lib/nagios/plugins/check_tcp -p 12001 --refuse=warn
Locked