nagios-plugins / nagios-plugins

Nagios Plugins
GNU General Public License v3.0
361 stars 335 forks source link

check_by_ssh : Specifying "-o LogLevel" causes command to fail. #683

Open invadetl opened 1 year ago

invadetl commented 1 year ago

Hi.

We have the following RPM package: nagios-plugins-by_ssh-2.3.3-6.el8.x86_64

from the EPEL repo installed on Rocky Linux 8.

Note : I can see that this isn't the latest version, but it's the latest release from EPEL and I can't see anything in the subsequent release notes that relate to this problem.

I'm trying to debug some connections but when I set the LogLevel to certain values, the command fails. eg.

Both the following work OK: ssh -o LogLevel=FATAL {HOST} 'date +"OK: %d-%m-%Y @ %T %Z"' /usr/lib64/nagios/plugins/check_by_ssh -o LogLevel=FATAL {HOST} -C 'date +"OK: %d-%m-%Y @ %T %Z"'

The following works: ssh -o LogLevel=VERBOSE {HOST} 'date +"OK: %d-%m-%Y @ %T %Z"' but: /usr/lib64/nagios/plugins/check_by_ssh -o LogLevel=VERBOSE {HOST} -C 'date +"OK: %d-%m-%Y @ %T %Z"' returns: Remote command execution failed: Authenticated to {HOST} ([n.n.n.n]:22).

and, the following works: ssh -o LogLevel=DEBUG {HOST} 'date +"OK: %d-%m-%Y @ %T %Z"' but: /usr/lib64/nagios/plugins/check_by_ssh -o LogLevel=DEBUG {HOST} -C 'date +"OK: %d-%m-%Y @ %T %Z"' returns: Remote command execution failed: debug1: Reading configuration data /etc/ssh/ssh_config

Is there a known cause / fix for this is so I can enable debugging?

Thanks in advance.

sawolf commented 1 year ago

I think the issue is that the extra logging messages from ssh are being written to stderr, and check_by_ssh always processes this as UNKNOWN. If your goal is to just have those two failing lines work, you can specify -E to skip any output from stderr. I was able to reproduce your behavior and that did get me back to "OK". However, I don't think that'd be very useful in your case. As far as I can tell, there isn't a way to get the plugin to print the full output at the moment.

invadetl commented 1 year ago

Thanks for the reply.

As you say, this doesn't really help as I need the stderr output to debug the causes of the connection problems.

Unless this ability is going to be added to the plugin, feel free to close this issue.