Java Code:
public class check_health{
public static final int OK=0;
public static void main(String args[]){
System.out.println("System OK - Works fine!");
System.exit(OK);
}
}
bash shell:
#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.7.0_40
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
java check_health
This plugin works fine in terminal but got error message in Nagios Core:
(No output on stdout) stderr: Error: Could not find or load main class check_health
Any idea?
Can't execute a Nagios plugin written by java code
Re: Can't execute a Nagios plugin written by java code
I was able to replicate the issue and able to resolve it by passing the class path.
Please change the last line on your bash script from:
To:
Let us know if that works for you.
Please change the last line on your bash script from:
Code: Select all
java health_check
Code: Select all
java -cp /usr/local/nagios/libexec check_health
Re: Can't execute a Nagios plugin written by java code
Dear ssax,
It works now, thanks for your help.
It works now, thanks for your help.
Re: Can't execute a Nagios plugin written by java code
I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee