Page 1 of 2

Nagios Monitoring for JMX/JVM.

Posted: Thu May 28, 2015 11:09 am
by haile711
Hey everyone,
I'm trying to monitor JMX/JVM for jboss with this ./check_jmx -U service:jmx:rmi:///jndi/rmi://hostname:host_port/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192.

Im getting the following errors, has anyone everyone ran into this issue, please let me know how did u resolve it. Thanks in advance!!

JMX CRITICAL Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 11.48.222.159; nested exception is:
java.net.ConnectException: Connection refused] connecting to java.lang:type=Memory by URL service:jmx:rmi:///jndi/rmi://hostname:port/jmxrmijava.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: hostname; nested exception is:
java.net.ConnectException: Connection refused]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:355)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:227)
at org.nagios.JMXQuery.connect(JMXQuery.java:53)
at org.nagios.JMXQuery.main(JMXQuery.java:75)

Re: Nagios Monitoring for JMX/JVM.

Posted: Thu May 28, 2015 1:27 pm
by tgriep
It looks like the server you are connecting to is blocking the check or isn't setup for remote checks. Do you have a firewall on the server and is it allowing the connection through?

Re: Nagios Monitoring for JMX/JVM.

Posted: Fri May 29, 2015 1:02 pm
by haile711
I don't have jmx/rmi agent enable on the remote server, because of company policy regarding vulnerabilities. I think that is the reason for the above errors. I have another plugin from https://fidanov.net/c0d3/nagios-plugins ... /check_jvm. I have defined the command in nrpe.cfg, but whenever I issue the command "/usr/local/nagios/libexec/check_nrpe -H <hostname> -c check_jvm" I get "UNKNOWN JVM is running with different username, run this script with UID 501". The issue is I have a different user running the java application that user belong to UID 501. I don't know what user run the nrpe agent. For example, I have user X running the java application, and user B running the nrpe agent; therefore the command I defined within the nrpe.cfg. If anyone has any idea, please let me know. Or any suggestion. Thank you very much!!!

Re: Nagios Monitoring for JMX/JVM.

Posted: Fri May 29, 2015 1:16 pm
by abrist
You have a few options:
1. Give the nagios user needs rights to the jvm (or be in the necessary group)
2. Change the nrpe user by editing the nrpe.cfg and changing:

Code: Select all

nrpe_user=nagios
But understand that all other nrpe checks will run as this user.
3. Create a sudoer rule to allow the nagios user to run the check.

There are probably other options as well, but these three come to mind.

Re: Nagios Monitoring for JMX/JVM.

Posted: Mon Jun 01, 2015 1:17 pm
by haile711
Im still having some difficulties with this service. Do you guys know any others plugin for Nagios to monitor JMX without JMX agent being enable? Thanks

Re: Nagios Monitoring for JMX/JVM.

Posted: Mon Jun 01, 2015 3:44 pm
by abrist
haile711 wrote:Im still having some difficulties with this service. Do you guys know any others plugin for Nagios to monitor JMX without JMX agent being enable? Thanks
Take a look at the exchange:
https://exchange.nagios.org/index.php?o ... chword=jmx
I have used check_jmx4perl in the past at it worked great. The real issue you are going to face is that unless you contact the direct JMX server remotely, you will need to use an agent. This means you will once again run into the permission issues of the agent.

Did you look over my possible suggestions above? Will any of them work for you in your environment? If not, why?

Re: Nagios Monitoring for JMX/JVM.

Posted: Tue Jun 02, 2015 1:47 pm
by haile711
Hey abrist,
Thank you for replying. Yea, I am currently experiencing with jmx4perl. I got it to work locally, but whenever I called the command from a nagios server ""check_jmx4perl --url http://<hostname>:<hostport>/jolokia --alias MEMORY_HEAP_USED --base MEMORY_HEAP_MAX --critical :80 --la bel "Heap-Memory: %.2r% used (%.2v %u / %.b %u)" --unit B:" from a remote server I got the following error "UNKNOWN - Error: 404 Error while fetching http://jcia6085:8080/jolokia/ :

404 Not Found". I have "jolokia.war" deployed on the remote server need to be monitored. If I have multiple containers, do I need to deploy this jolokia.war in all those container? I'm in new to this, so forgive me for the lack of syntax!! Thanks for all the help.

Re: Nagios Monitoring for JMX/JVM.

Posted: Tue Jun 02, 2015 2:55 pm
by tgriep
Are you still trying to use NRPE on the remote server to check JMX?
If so, can you post your nrpe.cfg file showing how the check is configured?

Re: Nagios Monitoring for JMX/JVM.

Posted: Tue Jun 02, 2015 3:20 pm
by haile711
Hey tgriep,
No im not using NRPE anymore. I have jmx4perl and both the nagios server and the remote server has jolokia.war agent running. Jmx4perl should contact the agent on the remote server to give back information, but I'm not getting it.

Re: Nagios Monitoring for JMX/JVM.

Posted: Tue Jun 02, 2015 3:56 pm
by tgriep
A quick look at the documentation and there is a file called jolokia-access.xml that you have to edit to allow access to the server. Did you add the Nagios XI server to file when you deployed the WAR file?
Here is the link to the instructions where I found that information.
http://search.cpan.org/~roland/jmx4perl ... k_jmx4perl