I need to query a nrpe nagios server from a Java application remotely just as check_nrpe would do:
check_nrpe -H 192.***.***.*** -p 56** -c "check_load"
When I say "from a Java application" I mean I want the results to be received and processed at my Java application. The first idea I had was to call the "check_nrpe" command from my application and retrieve its output and return value but I would like more a standalone solution where no external programs are called.
I don't need to wait for state changes, just eventually check the monitor state. Since I have been unable to locate any Java library (should I try JNRPE?), I would like to implement the protocol check_nrpe and nrpe daemon use to communicate.
Have any of you tried this before? In that case, do you have a description of this protocol?
If your answers are negative I will try to analize the protocol using whireshark but any clue will be much appreciated.
An explanation of NRPE protocol from Andreas Marschke blog, The NRPE Protocol explained (on gitHub too)
Anyway, JNRPE have a full working implementation of the protocol, you can download
jcheck_nrpe-2.0.3-RC5
source code and take a look atjcheck_nrpe-2.0.3-RC5\src\main\java\it\jnrpe\client\JNRPEClient.java
class for a sample client who's usingjnrpe-lib-1.0.1-RC5
.jnrpe-lib
have two concrete classes which implements the protocol request and responseThe full protocol implementation classes can be found at
jnrpe-lib-1.0.1-RC5\src\main\java\it\jnrpe\net\
folder