Problem with check_by_ssh

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Problem with check_by_ssh

Post by niebais »

The check_by_ssh plugin is having problems due to the /etc/issue banner. On the command line here is what is happening:

user@mysystem $ ./check_by_ssh -H mysystem -C "/bin/ls /tmp"
Remote command execution failed: Warning:
In the Nagios viewer it shows a key failure (which is not the case here)

However, I can ssh to the system on the command line:
user@mysystem $ ssh -q mysystem
Last login: Mon May 11 00:01:00 2009 from 192.168.0.12
(newuser)othersystem:/home/newuser#

If I run this command which suppresses the banner and creates a fake tty:
[user@mysystem dir]$ ssh -q -t othersystem -C "/bin/ls /tmp"

The above command works.

The problem is that the check_by_ssh command does not let me put the -t or -q flags in it to make this command possible. In fact the -t command is short for "timeout" in check_by_ssh.

Is there some kind of workaround I can use with the check_by_ssh command? I'd prefer to use check_by_ssh with its options so it saves me the headache of creating my own plugin.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Problem with check_by_ssh

Post by mmestnik »

I don't understand why you are using '-t' this should not do anything. It would request a PTY if and only if it was being run from any kind of TTY. As it's only being run from a TTY when you are on the command line and not when run from Nagios it should not have any effect.

That said, what is the goal of allocating a PTY? If I wrote ssh I could imagine that I'd not display the banner if there was not a TTY, '-T'. However to disable the banner all you should need is a quiet '-q'... or two.

However check_by_ssh supports this feature:
-q, --quiet
Tell ssh to suppress warning and diagnostic messages [optional]
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Problem with check_by_ssh

Post by niebais »

I created a temporary patch that allows me to use the -z option which adds a "-t" to the ssh command allowing everything to work.
Last edited by niebais on Mon May 17, 2010 10:43 am, edited 1 time in total.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Problem with check_by_ssh

Post by niebais »

If I use just the -q option, it doesn't work on these systems.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Problem with check_by_ssh

Post by niebais »

-T Disable pseudo-tty allocation.

-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g., when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.

Capitol -T works as well. I think that's a better option to use anyway.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Problem with check_by_ssh

Post by mmestnik »

Correct. Though keep in mind that unless you are testing with out a TTY then you are not properly emulating the environment that Nagios would use. To disable your TTY you could use something like "ssh -T 127.0.0.1". Not having a TTY is difficult, process interruption "ctrl-C" and "ctrl-Z" don't work and many of the tty-echo features that allow for backspacing don't work.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: Problem with check_by_ssh

Post by niebais »

I've got this working with the patch. This thread can be marked as done.
Locked