Nagios Core Bash Command Does not return Variable

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.
Locked
jenglee
Posts: 10
Joined: Tue Nov 20, 2012 4:50 pm

Nagios Core Bash Command Does not return Variable

Post 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.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Nagios Core Bash Command Does not return Variable

Post 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.
jenglee
Posts: 10
Joined: Tue Nov 20, 2012 4:50 pm

Re: Nagios Core Bash Command Does not return Variable

Post 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.
Locked