LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 02-29-2012, 04:16 AM   #1
laks
Member
 
Registered: Feb 2012
Posts: 34

Rep: Reputation: Disabled
NRPE not working with my jar


Hello,

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?

Thanks,
Laks
 
Old 02-29-2012, 04:29 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 02-29-2012, 06:58 AM   #3
laks
Member
 
Registered: Feb 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
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?
 
Old 02-29-2012, 08:01 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.

BTW, NRPE is rubbish.
 
1 members found this post helpful.
Old 03-01-2012, 03:38 AM   #5
laks
Member
 
Registered: Feb 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-02-2012, 12:19 AM   #6
laks
Member
 
Registered: Feb 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
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.
 
Old 07-17-2012, 01:46 PM   #7
Hussain123
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Check_nrpe invoking Java .jar

Quote:
Originally Posted by laks View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nagios + nrpe working on the same machine aocferreira Linux - Networking 2 05-25-2011 05:05 PM
Installing Nagios agent nrpe, problems following nrpe install steps rfreiberger Linux - Newbie 3 04-19-2010 08:43 AM
How to set mail.jar(JavaMail) and mysql-connector-java.jar in Linux class path Terry56 Linux - Software 3 01-19-2010 09:06 AM
Jar and Java are never working. Isnt it? frenchn00b General 2 04-23-2009 05:21 AM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 05:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration