I would like to monitor Java applications using Java Management Extension and utilize the PRTG Mini Probe interface for this purpose. How can I implement such a “JMX Probe”? Is there an example of how to gather monitoring data directly from JMX with a mini probe?
How can I monitor Java applications via JMX with a PRTG Mini Probe?
Votes:
2
24 Replies
Votes:
2
This article applies to PRTG Network Monitor 14.x.10 or later
JMX Monitoring with the PRTG Mini Probe
Usually, PRTG monitors systems agentless so you do not have to install any software on target devices. PRTG probes connect directly to the remote system via SSH, WMI, SNMP, etc. to take the desired measurements. Agentless monitoring brings a lot of advantages for you because it is easy to set up and you do not have to maintain anything, but some situations require other methods than agentless.
For example, Java Management Extension (JMX) monitoring is one of those because of its potential complexity. We provide instructions for monitoring a Java Virtual Machine (JVM) via SNMP in this article. However, this shows that installing a small piece of software on the target system might be a better idea in order to monitor data more easily. For this purpose, PRTG offers two options: You can create an HTTP Push Data sensor or you use the PRTG Mini Probe interface.
PRTG Mini Probes work similar like the “big” local and remote probes but with a smaller set of sensor types. You are completely free in implementing and adjusting mini probes depending on which monitoring data you need. The Mini Probe API is publicly available so you can create your own individual probes. Or you simply extend the code of our PRTG JMX Mini Probe proof-of-concept and add your own sensor types.
This article describes the Java-based open source code for a PRTG Mini Probe that you can run on any Java VM to monitor it via JMX.
Note: This article is provided for your information only. The steps described here have been tested carefully. However, we cannot offer deep technical support for customizing this proof of concept nor for writing your own mini probes.
Note: We do not further develop the currently available Mini Probe API because we plan major changes to the underlying API in PRTG. You can still use the JMX Mini Probe, for example, if the available HTTP push sensors are not sufficient for your needs.
JMX Mini Probe (Open Source)
You are free to use the Mini Probe API in order to implement probes and the corresponding sensors for any application scenario. So the Mini Probe helps you gather monitoring data from systems which do not run the supported Windows versions. You can find the full documentation of the Mini Probe API here.
Because there is demand from time to time by our customers for JMX monitoring and the proposed method via SNMP is not completely sufficient, we provide you a Mini Probe proof-of-concept for this purpose. The JMX Mini Probe implementation is intended to demonstrate the capabilities of the Mini Probe interface and to give you a starting point for creating your own probe for JMX.
This Mini Probe proof-of-concept is written in Java. It can run the monitoring processes in standalone mode or in an application container and delivers the results back to the PRTG core server via the PRTG Mini Probe interface.
Get the JMX Mini Probe on GitHub!
Requirements
You need to fulfill only a few prerequisites to monitor with the JMX Mini Probe:
- PRTG Core Server: version 14.x.10 or later
- Running the probe in standalone mode: Java SE 1.6 or higher
- Running the probe in an application container: Java EE 6 compliant or higher
Installation
Please follow the steps below to get the JMX Mini Probe up and running:
1) Prepare your PRTG server:
- Set your PRTG server to use HTTPS: In the PRTG web interface, navigate to Setup | System Administration | User Interface, section Web Server, and choose Secure HTTPS server in section TCP Port for Web Server.
Note: Other connection methods are not allowed! - In the PRTG web interface, navigate to Setup | System Administration | Core & Probes and define the settings as given in the next steps.
- Define an Access Key for the JMX Mini Probe. You can also use an existing one.
- Add an appropriate IP filter in section Allow IPs. Use, for example, any.
- Allow Mini Probe connections: Go to section Probe Connection Settings and allow Mini Probes to connect. You can specify a custom Mini Probe port as of PRTG version 14.x.13.
- Now check that you can reach your PRTG server from the machine on which the JMX Mini Probe will run: e.g., execute the command
wget https://<your_PRTG_server>
Note: If you get an SSL handshake failure, it might be necessary to choose the weakened SSL security option for the web server in the PRTG System Administration! (see Setup | System Administration | User Interface)
2) Prepare and start the JMX Mini Probe
Download the JMX Mini Probe package from GitHub. Then you have two options to run the JMX probe: Either you start it as standalone in its own virtual machine, or you add it to an application container.
Note:
- Before you start, please ensure that your PRTG core server is up and running. Currently, the JMX probe is not able to re-send the initial announce request.
- Please also make sure that you have working remote access over JMX to the devices you want to monitor, regardless of whether you use the JMX Mini Probe in standalone mode (option 1) or in an application container (option 2). You might find helpful tips in this stackoverflow article on Connecting remote tomcat JMX instance using jConsole.
Option 1: JMX Mini Probe in standalone mode
In standalone mode, the probe will run in its own threadpool so you do not need to have an application server installed.
- Add the JMX probe package to its dedicated JVM.
- Create a config file prtgjmx.properties.
- Ensure write access to prtgjmx.properties for the UID (user, service) which runs the probe.
- Add the following parameters to prtgjmx.properties:
key=prtg_access_key host=your_prtg_server
- Replace prtg_access_key with the access key you have defined in PRTG before (see above).
- Replace your_prtg_server with the IP address or DNS name of your PRTG server.
- Start the probe with the following command:
java -jar JMXProbe.war –c prtgjmx.properties
- Approve the new probe connection in the PRTG web interface. The acknowledgement works like for a new remote probe connection.
Option 2: JMX Mini Probe in an application container
If you want to run the JMX probe in an app container, add the JAR files to it and follow the steps below:
- Create a config file prtgjmx.properties.
- Make the config file writable by the UID that runs the application server.
- Add the following parameters to the config file (see description of standalone mode):
key=prtg_access_key host=your_prtg_server
- Add the following line to the server’s Java options and provide the path to the config file accordingly:
com.paessler.jmxprobe.config=/path_to_config_file
- Approve the new probe connection in the PRTG web interface like for a new remote probe connection.
Default Sensors
After you have got the JMX probe running, you can work with it in the PRTG web interface as usual, e.g., add sensors, review monitoring data, create notifications, etc.
By default, the JMX Mini Probe contains the following sensors to monitor Java applications via JMX:
- JMX VM Health Sensor: Shows various health parameters for the JVM, for example, information about heap memory, about threads, and about loaded classes.
- Custom MBean Attributes Sensor: Monitors MBean attributes which you can define in the sensor settings via their object name. You can use the following unit types for the objects: Disk (bytes), Memory (bytes), Bandwidth (bytes), CPU (%), Count, Percent, File (bytes).
Please see Monitoring and Managing MBeans in the Oracle documentation about how to get MBeans available and how to find out the desired attribute names.
In order to monitor these sensors, you have to provide an RMI Connection String in the particular sensor settings, so specify a JMX service URL. It has to match this syntax: service:jmx:protocol://[host[:port][:path]]
It could look like this, for example: service:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi
See also The JMX Service URL in the Oracle documentation.
You can adjust these default sensors or add even new ones to the probe package. Please refer to PRTG Manual: Mini Probe API for more information.
Debugging
tba.
See Also
Created on Jul 24, 2014 3:48:19 PM by
Gerald Schoch [Paessler Support]
Last change on Aug 14, 2018 8:10:10 AM by
Brandy Greger [Paessler Support]
Votes:
1
Hey there,
maybe you should give it a try with "-jar" to start the ".war"
java -jar JMXProbe.war -c prtgjmx.properties
For me the version without won't work.
Server: Linux Debian / Java Version 6
Best
Sascha
Votes:
0
Hi Sascha,
Thank you very much for your comment, "-jar" was mistakenly missing. I added it to the command!
Best,
Votes:
0
Hallo,
thank you for this short article explaining the main steps. I could start an easy setup successfuly. But there are some questions / remarks remaining:
- Just a little optimization: If one download the miniprobe, the war-file does not have that name. It name contains a version suffix, so in your examples you should not write "JMXProbe.war" but "<JMXProbe_Version>.war" or something like that
- The Code and War file are poorly documented. No advice how and where in the sourcecode to add new sensors
- An example how to install the probe standalone as a i.e. Windows Service will be great for not so well java skilled people. Same for installing in a container
- For me it is not clear, if i could use the prtg_access_key for more than one probe and if not, how to get another key
- How to set up an secure (ssl) connection between the probe and the Java VM
- How to set up an secure connection between the miniprobe and the main PRTG server
If you could answer these questions and / or initiate a better documentation of the war-file and code, this miniprobe feature will be my favourite.
Votes:
0
Yes, we need to improve the documentation to cover 1, 2, and 3. For your other questions:
4) Yes, you can use the access key for multiple probes, or you can just add a new key in the administrative section of the PRTG interface.
5) We do not support JMX over SSL right now.
6) The probe-to-PRTG connection is automatically secure - it only connects over HTTPS.
Votes:
0
Trying to this Mini Probe running. But without success. Downloaded the current .war file and tried to run it standalone.
It gives me the following error
java -jar JMXProbe.war
Error: Could not find or load main class com.paessler.prtg.jmx.DaemonMain
Java is available on the server. Its OpenJDK. Might this be an issue?
java -version
java version "1.7.0_91"
Another general question is if the Mini Probe will connect to a PRTG server using a self signed SSL certificate?
Any hints? Thanks!
Votes:
0
This JMXminiProbe run in JBoss EAP 6x ? I could not make it work. Appear the message below when I try to run it:
[jboss@eaphom1 prtg_agent]$ ./JMXMiniProbe.sh Missing configuration file path. Reverting to default(/opt/redhat/prtg_agent/prtgjmx.properties) org/xbill/DNS/TextParseException java.lang.NoClassDefFoundError: org/xbill/DNS/TextParseException at com.paessler.prtg.jmx.ProbeContext.loadSensors(ProbeContext.java:390) at com.paessler.prtg.jmx.ProbeContext.loadProperties(ProbeContext.java:264) at com.paessler.prtg.jmx.ProbeContext.getProbeContext(ProbeContext.java:343) at com.paessler.prtg.jmx.DaemonMain.main(DaemonMain.java:72) Caused by: java.lang.ClassNotFoundException: org.xbill.DNS.TextParseException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Here is the content of prtgjmx.properties file:
guid=8c017674-8867-4348-a265-b0b915431903 (added automatically after the first attempt to run .sh script) key=C2B30822-4B58-468E-96EA-606134749953 host=192.168.53.200
Created on Aug 15, 2016 6:14:32 PM
Last change on Sep 5, 2016 5:55:59 AM by
Luciano Lingnau [Paessler]
Votes:
0
Hi The problem is a missing library/JAR file (dnsjava-2.1.x.jar) which is required by the DNSSensor class. I see you are using a shell script (.sh) to launch the app. The stand alone version should be started with one of the scripts in the ".\bin" directory
JMXMiniProbe or JMXMiniProbe.bat will start the Java Service Wrapper (JSW ) based version runJMXMiniProbe or runJMXMiniProbe.bat will start the default JVM with the correct options
These scripts will set the lib paths right for the app to find the correct libraries. Please download the latest version from GitHub and try again. JR
Votes:
0
I have same error when config jmx prob mini : Error: Could not find or load main class com.paessler.prtg.jmx.DaemonMain what's the problem?
Votes:
0
Hi there,
have you tried what JR has suggested?
Best regards.
Votes:
0
Hey,
We are trying to get the JMXMiniProbe to work, bu we encounter a few problems
- In earlier comments you refer to running the standalone version from the bin folder. However, there are no scripts in there.
- It says Error: Could not find or load main class com.paessler.prtg.jmx.DaemonMain. We tried all the solutions that were posted above, but the error keeps comming.
- Inside the JMXMiniProbe.sh it refers to WEB-INF instead of web/WEB-INF.
Votes:
0
Hi... A common problem is that users download the source can not run it directly, it has to be built. If you download the release package which contains the jar, it is runnable directly in an App server. To run it as an app, you have to unzip (jar -xvf <WarFile.war>) it and run it using the scripts/batch files.
The problem is the way WAR files are structured, they keep the jar files in "WEB-Inf/* and WEB-INF/lib/*"... Which is non-standard, but the way it is done in WAR's....
To deploy the WAR directly onto an AppServer, you have to create the "prtgjmx.properties" file and add it to the WAR file before deploying or edit it directly on the app server after it is deployed.
Votes:
0
I am trying with the option 1 by using the Mini probe in the standalone mode but it's not working for me. Can somebody please explain in a little more details on how to proceed with the option 1.
Thanks
Votes:
0
Hi
In most cases, the issues related to running the JMXMiniProbe in standalone mode is related to access and security. You should be able to add a sensor on the 'localhost', which is the JVM the probe is running in without problem. (Which is why it is much simpler to run the JMXMiniProbe in the same JVM as your app server) When you try to access a remote JMX instance (like an app server), you have to enable remote access to the JVM running the app server. This is accomplished by setting the port/access/security mode on the commandline of the JVM running AppServer and creating a UID/PWD.
The settings are listed in "https://github.com/PRTG/JMXMiniProbe/blob/master/JR_Observations.txt"
java -jar yourApp.jar [JVM_OPTIONS]
For local host access only JVM_OPTIONS are:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
For full remote access JVM_OPTIONS are:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
Prefer IPv4 over IPv6:
-Djava.net.preferIPv4Stack=true
Example:
java -jar MyJar.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.net.preferIPv4Stack=true
More:
http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
Here are some more links to guide you in opening up Remote access to JMX:
https://stackoverflow.com/questions/834581/remote-jmx-connection
Created on Mar 25, 2018 8:48:04 PM by
JR Andreassen
(10)
●2
Last change on Mar 26, 2018 8:44:51 AM by
Stephan Linke [Paessler Support]
Votes:
0
iam trying to install the JMX Mini Probe on my windows client machine. have created the prtgjmx properties file , when i try to install the JMXminiprobe file in a standalone mode i get the following error https://ibb.co/d0cZCS https://ibb.co/gSBGRn https://ibb.co/jRC1sS plz help me out with this , going by the above comment i tried installing the latest zip , but there is no installable file in /bin package.
Votes:
0
Hi Svad,
Did you run the java.exe directly or using the Batch file ? It looks like there are some missing libraries...
If you pulled the source, you have to build the source. Or, download the WAR (https://github.com/PRTG/JMXMiniProbe/releases/download/0.5.6/JMXProbe.war) unzip it. then run the batch file 'JMXMiniProbe.bat' (copyu the config file if you unzip it to a different location).
Votes:
0
Iam trying to install the jmx mini probe in an application container , deployed the .war file to glassfish server as an application, before deploying it added the jmxprobe.properties to that WAR package, how to approve this new probe in my server ? i dont have to install anything else now i guess, i have seen the knowledgebase to add a remote probe but that is not required in this case iam guessing , i just need to approve it somewhere in the server interface iam guessing , can you tell me how i could do that https://ibb.co/jBMPhS https://ibb.co/fJLvp7
Votes:
0
Hi Sved,
Once the JMXMiniProbe is installed and running on the App Server, The MiniProbe should pop up in your Web GUI to be approved. (In the pop-ups in the lower right hand corner) If it does not, there is probably a parameter problem (jmxprobe.properties).
Please check the following in jmxprobe.properties key=prtg_access_key host=your_prtg_server #webprotocol=http #webprotocol=https These parameters have to match the PRTG Core Server settings (Setup -> System Administration -> Core and Probe Probe IP Connection <= host Access Key <= key MiniProbes "Allow Mini Probes to connect to the web server"
If these match, the probe should be allowed, and show up in the "Approve". If not, please check the log files, both on the PRTG Server and App server...
Created on Apr 19, 2018 5:16:19 PM by
JR Andreassen [Paessler Support]
(220)
●3
●1
Last change on Apr 19, 2018 5:18:48 PM by
JR Andreassen [Paessler Support]
(220)
●3
●1
Votes:
0
This has been done successfully, what should be my next step? if iam tryin to deploy this in standalone mode.
[root@FidoEngine JMXProbe]# cd bin/ [root@FidoEngine bin]# ./JMXMiniProbe start Starting JMXMiniProbe...
where do i run this command "java -jar jmxprobe -c prtgjmx.properties"
Votes:
0
On a unix system, you should run the shell script:
JMXMiniProbe.sh
or if you uzipped the WAR file...
Using the service Wrapper: .\bin\JMXMiniProbe Using the plain Java : .\bin\runJMXMiniProbe
Now you should be able to create Groups/devices/Sensors...
Votes:
0
Thanks a lot for your help JR , i was successfully able to deploy the JMXMini Probe in stand alone mode for one of my centos virtual machine and able to add java sensors , however my requirement is to monitor a java application thats running in there , I tried deploying the .war in the glassfish server with prtgjmx.properties file inside the .war file. Is this how iam supposed to do? but iam unable to see any new probe approval in the prtg server, could you please tell me what iam missing on , or help me with precise steps, iam new to java and dont have much knowledge , would be greatly appreciated if you could help me out.
Votes:
0
Hi Sved,
I don't have much experience with GlassFish, so I can't be of great help there. I have tested it with Tomcat and a few others. Usually, the App server unpacks the WAR into a sub-directory of the AppServer. If you find it, you can verify the files and location. You should also be able to find the logs that will tell you what the Probe is doing. (https://stackoverflow.com/questions/13835913/location-of-glassfish-server-logs)
Have a look at the logs, they should be the same as the Standalone version.
You should be able to connect to the Glassfish instance "remotely with the "RMI/JMX" string. https://blogs.oracle.com/quinn/jmx-monitoring-of-glassfish-servers
Votes:
0
Hello, the JMX uses Log4j see GitHub repo. Is there anything that the developers do to check if there is a security vulnerability?
Votes:
0
Hello there,
While certainly the JMX Miniprobe Project includes an example configuration file for log4j compatible logging frameworks, the prebuild binaries utilize apache commons logging library instead.
Kind regards,
Felix Saure, Tech Support Team
Add comment