Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need some help in getting my Java plugins to work with Nagios. I have written few java programs, packed them in a jar file and placed it in the linux machine which is to be monitored by Nagios. This Jar produces desired output when invoked from command line, but when invoked from check_nrpe on Nagios server, it is throwing error " no output returned". Now I replaced my jar with a simple shell script to echo the same output as jar was supposed to produce, check_nrpe is working. Any idea, why my Jar is not being executed by check_nrpe?
NRPE is rubbish. Is there any chance I could bully you into use check_by_ssh or something less awful?
When you say it's "throwing an error", this is from running check_nrpe yourself on a command line? What output streams is your Jar outputting the details too? Maybe it's writing to stderr? I would not personally look to directly run a remote program over nrpe, but to call a local nagios plugin which in turn will run whatever arbitrary code you need and return the output back over the nrpe call.
Hello Chris, yes, I ran check_nrpe -H <host ip> -c <my remote jar> from command line which gave me the error. I am totally stuck in finding out where it is going wrong. My java program writes stderr to /dev/null and prints only the output on commandline. Could that be the reason of nrpe failing?
well like I said, you should be running a nagios plugin remotely, not an arbitrary application. If your code IS a binary nagios plugin then that's kind of different. You say you're running "my remote jar", but you'll need a functional java runtime environment to run it, which you probably won't have as the nrpe / nagios user account on the system. try running the code via a "su - nagios <my remote jar>" or similar and that shuold give you a similar experience to that enojyed by nrpe.
Thanks, I have set my nagios user's java env, still check_nrpe is failing. This time the error (from syslog)
is
Command completed with return code 3 and output:
Feb 29 14:23:14 inn63u-0564 nrpe[10214]: Return Code: 3, Output: NRPE: Unable to read output
One more thing I noted is that if i change my script to execute an echo "Hello", it works from nrpe. But if I change the same script to run System.out.println("Hello"), nrpe fails with the above message. I have verified permissions of all the folders, files(nagios, nrpe and java) and everything seems to be ok. So, is there any difference in the way echo and System.out.println works.
It worked finally, though I am still not sure what the actual issue was. Inside my plugin script, I was running java -jar myjar. I changed it to /usr/java/jdk/bin/java -jar myjar and it worked. I am not sure, why is it required as I have java in the PATH of Nagios user. Also, I was able to successfully run java -jar as Nagios user. It might be that nrpe is using it's own environment variables to run it's script.
It worked finally, though I am still not sure what the actual issue was. Inside my plugin script, I was running java -jar myjar. I changed it to /usr/java/jdk/bin/java -jar myjar and it worked. I am not sure, why is it required as I have java in the PATH of Nagios user. Also, I was able to successfully run java -jar as Nagios user. It might be that nrpe is using it's own environment variables to run it's script.
Hi laks, I have simple hello world jar, I am going to convert it to NRPE standard by writing to System.out('Some text') and exiting with one of the Nagios return codes (0-OK/1-WARNING/2-CRITICAL/3-UNKNOWN). Meanwhile I am interested in the script that invokes check_nrpe to invoke the .jar file. Would you please share the script or snippet. Do you the show the output on the Nagios browser console?
Thanks
-Hussain
Last edited by Hussain123; 07-17-2012 at 01:49 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.