Page 1 of 1

Nagios Core Bash Command Does not return Variable

Posted: Tue Nov 20, 2012 5:07 pm
by jenglee
I created a bash script that SSH into another machine and gets a value and sets it to a variable and prints the variable out.
But when the command in executed by Nagios it does not print the variable.

Sudo code goes as follow:

var_used=$(SSH root@host free -m | get the used memory)

echo used $var_used


In nagios it prints out used $

I have also tried it with

var_used=2 and still get the same results.

Re: Nagios Core Bash Command Does not return Variable

Posted: Tue Nov 20, 2012 5:38 pm
by agriffin
When you test it, are you executing it as the nagios user? This is by far the most common cause of scripts executing differently under Nagios vs. from the command line.

Re: Nagios Core Bash Command Does not return Variable

Posted: Wed Nov 21, 2012 9:46 am
by jenglee
Thanks you for that information. I changed to my nagios user and allowed the nagios user to SSH into the remote linux machine and execute command without need a password. I created a RSA authorization for my linux servers.

Thanks Again.