I have nagios client and server, how I can get the value of JAVA_HOME from my client? I have use to set shell command in script that is running from remote host: echo $JAVA_HOME and printenv | grep "JAVA_HOME" doesnt help.
-
also asked on superuser.com/q/660686/4714– glenn jackmanOct 16, 2013 at 15:12
-
I don't understand the use case: why does the server need to know about the client's environment?– glenn jackmanOct 16, 2013 at 15:13
-
this is a task to do, i think it is stupid, but our clients need this– user2424174Oct 16, 2013 at 15:22
2 Answers
How I worked around this:
echo $localvar > ~/tmpfile
rcp ~/tmpfile me@myremotelocation:~
ssh -t me@myremotelocation 'remotevar = `cat ~/tmpfile`'
$remotevar on server should be the same as $localvar on client Scheduled it as a cronjob. Not the most elegant way but it works like a rock since.
JAVA_HOME
and PATH
may not be properly set on client's system.
Find java exact location first.
$ type -p java
/home/user/jdk1.7.0_02/bin/java
Notice that the returned path is not the same as JAVA_HOME
. (If no path is returned, java is not installed)
Then JAVA_HOME
sets the path to one that containing the /bin
dir:
export JAVA_HOME=/home/user/jdk1.7.0_02/
export PATH=$PATH:$JAVA_HOME/bin