-1

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.

3
  • also asked on superuser.com/q/660686/4714 Oct 16, 2013 at 15:12
  • I don't understand the use case: why does the server need to know about the client's environment? Oct 16, 2013 at 15:13
  • this is a task to do, i think it is stupid, but our clients need this Oct 16, 2013 at 15:22

2 Answers 2

0

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.

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .