Nagios Monitoring for JMX/JVM.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Nagios Monitoring for JMX/JVM.

Post 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)
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Monitoring for JMX/JVM.

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Nagios Monitoring for JMX/JVM.

Post 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!!!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios Monitoring for JMX/JVM.

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Nagios Monitoring for JMX/JVM.

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios Monitoring for JMX/JVM.

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Nagios Monitoring for JMX/JVM.

Post 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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Monitoring for JMX/JVM.

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Nagios Monitoring for JMX/JVM.

Post 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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Monitoring for JMX/JVM.

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked