Unable to execute a application specific cmd using check_nrp

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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Unable to execute a application specific cmd using check

Post by tgriep »

The NRPE agent is used to run commands on remote systems without opening a TTY, if your command requires a terminal to run, then it would have to be changed to not need a terminal.
Be sure to check out our Knowledgebase for helpful articles and solutions!
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

Changing command to not use terminal is not possible. As while command is architect to be run on different shell prompt and execute commands on that prompt then get the output. Anyhow it's depend upon application owner to raise it further.

What if I give nagios user to open a terminal which command use its on while nrpe executes it? What are the possibilities for the same??

If you can also share your views on check_by_ssh(If that is in scope of this forum). Why check_by_ssh getting failed while implemented in command.cfg but running fine for nagios server's cli.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Unable to execute a application specific cmd using check

Post by tgriep »

I would guess that the check_by_ssh failed because of not having a local tty when running the command in nagios, will not open a tty on the remote system to run the command.
Be sure to check out our Knowledgebase for helpful articles and solutions!
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

Thanks tgriep for your responses and valuable time. If some one want, I would like a second opinion on check_by_ssh plugin. After so much discussions, I am still at day 1 situation and need some way to figure out the Solution.

As default check_by_ssh plugin do not have feature to forcing a tty session on remote host. To overcome this scenerio, I referred a customised check_by_ssh plugin which is same as feature of check_by_ssh plugin with typical ssh protocol application potential of forcing a remote tty. (Detailed on check_by_ssh is available in my previous post on same thread) .
jfrickson

Re: Unable to execute a application specific cmd using check

Post by jfrickson »

The nrpe process on the remote does not even try to allocate a tty and is probably unable to do so. I can check into that further. But right now it looks like the only option is to use check_by_ssh.

Is there some reason why you want to use nrpe instead of check_by_ssh?
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

My 1st preference was nrpe, if that is not working then check_by_ssh.

Currently I have deployed check using check_by_ssh.
Results already shared on my previous post on this thread. Check_by_ssh is also not working while used from nagios, but working fine while used from cli.
jfrickson

Re: Unable to execute a application specific cmd using check

Post by jfrickson »

In your source for check_by_ssh.c where it checks for -z, change it to use -tt instead of -t and see if that makes any difference.
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

Hi,
Sorry for delay response as I was away from system.

I am no good with C, but how much I learn by seeing source code. I made below changes
check_by_ssh.c
(20.1 KiB) Downloaded 392 times

Code: Select all

                case 'z':                                                                       /* -4 for IPv4 */
                        comm_append("-tt");
                        break;
then

Code: Select all

make
make all
make install
output from cli:

Code: Select all

[nagios@Nagiosserver ~]$ /usr/local/nagios/libexec/check_by_ssh -z -E  -H <Remote server IP> -C /usr/local/nagios/libexec/check_watchque
Ok: Message rate is 2 | 2
output from nagios UI: (it works)
check_watchqueue_nagios.GIF
check_watchqueue_nagios.GIF (7.71 KiB) Viewed 6151 times
But output is placing with junk characters too.


If I implemented with below option in command.cfg

Code: Select all

# 'check_by_ssh' command definition
define command{
        command_name    check_by_ssh_watchque
        command_line    $USER1$/check_by_ssh -z -E -S -t 20 -H $HOSTADDRESS$ -C "/usr/local/nagios/libexec/check_watchque"
        }


 -S, --skip-stdout[=n]
    Ignore all or (if specified) first n lines on STDOUT [optional]
 -E, --skip-stderr[=n]
    Ignore all or (if specified) first n lines on STDERR [optional]
I start getting below snapshot on nagios UI and CLI
check_watchqueue_nagios1.GIF
check_watchqueue_nagios1.GIF (8.51 KiB) Viewed 6151 times

Code: Select all

[nagios@nagiosserver~]$ /usr/local/nagios/libexec/check_by_ssh -v -z -E -S -H <Remote server IP> -C /usr/local/nagios/libexec/check_watchque
Command: /usr/bin/ssh
Argument 1: -tt
Argument 2: (remote server ip)
Argument 3: /usr/local/nagios/libexec/check_watchque
OK - check_by_ssh: Remote command '/usr/local/nagios/libexec/check_watchque' returned status 0
Any further suggestions on this characters, this may be leading to not plot graph details.

BR//
Last edited by diwakar0304 on Wed May 03, 2017 1:00 pm, edited 1 time in total.
jfrickson

Re: Unable to execute a application specific cmd using check

Post by jfrickson »

Ok, it sounds like we're making progress.

Those junk characters look like terminal control sequences (move cursor, set colors, etc.).

Try replacing this part: /bin/sed 's/(//g' with this: /bin/sed 's/\x1b[\[(0-9a-zA-Z;]*//g and see if that gets rid of the garbage.
diwakar0304
Posts: 28
Joined: Tue Nov 04, 2014 4:19 am

Re: Unable to execute a application specific cmd using check

Post by diwakar0304 »

No Luck!!!!

Attaching strace output for same.
Strace_Junk_character output.txt
(6.68 KiB) Downloaded 373 times
Can you please help me to understand why performance data is not processing?
performnce_graph.GIF
Locked