Page 1 of 1

check_by_ssh -C problem

Posted: Mon Apr 16, 2012 1:25 pm
by lhsch
Hi all.

I have a little question . . . . Can I do the following?

./check_by_ssh -t XX -H localhost -l <user> -p <port> -C "cd $ARGS1$ ; ./check_cpu_stats.sh -w <WARN> -c <CRIT>"

If i do this from a command line it works fine but If I do frm commands.cfg Nagios only use -C 'cd $ARGS1$ because ";" is a comment char.

Is it possible? Can I tell nagios that ";" is a part of -C command?

Regards.

Luis

Re: check_by_ssh -C problem

Posted: Mon Apr 16, 2012 1:59 pm
by scottwilkerson
First, it should be $ARG1$ not $ARGS1$

I'm not positive, but you may be able to escape it with \

Code: Select all

./check_by_ssh -t XX -H localhost -l <user> -p <port> -C "cd $ARG1$ \; ./check_cpu_stats.sh -w <WARN> -c <CRIT>"
But also, there should be no need to change directory with this command, you could just do

Code: Select all

./check_by_ssh -t XX -H localhost -l <user> -p <port> -C "$ARG1$/check_cpu_stats.sh -w <WARN> -c <CRIT>"

Re: check_by_ssh -C problem

Posted: Tue Apr 17, 2012 5:53 am
by lhsch
I just tired to escape with "\" but it doesn't work.
Tanks Scott.
Regards.

Re: check_by_ssh -C problem

Posted: Tue Apr 17, 2012 6:11 am
by lhsch
And I tried with multiple -C too, but only executes the first command:

check_by_ssh -t 90 -H localhost -l <user> -p 3331 -s c1:c2:c3 -C "date" -C "uptime" -C "whoami"
Tue Apr 17 08:14:36 CUT 2012

Is there anything wrong?

Thanks.

Re: check_by_ssh -C problem

Posted: Tue Apr 17, 2012 8:28 am
by lhsch
Hi.
Ijust resolved my problem.
defining $USERX$=; in resource.cfg file . . . .
then . . . .
./check_by_ssh -t XX -H localhost -l <user> -p <port> -C "cd $ARGS1$ $USERX$ ./check_cpu_stats.sh -w <WARN> -c <CRIT>"

Tks.

Re: check_by_ssh -C problem

Posted: Tue Apr 17, 2012 10:12 am
by scottwilkerson
That's a unique way to do it. glad you got it resolved