> OctoPerf load testing - Generic JMX Monitor documentation page. How to configure the Generic JMX monitor and firewall considerations.

Source: https://api.octoperf.com/doc/monitoring/create-connection/generic-jmx/

# Generic JMX

![Java Logo](https://api.octoperf.com/doc/monitoring/create-connection/generic-jmx/img/java-logo.png "Java Logo")

**The Generic JMX module supports virtually any web-server exposing metrics through the JMX protocol**. The MBeans Generic JMX monitoring module monitors MBeans attributes available on a JMX server. The supported MBean attribute types are:

 * **Java primitive types**: short, int, long, float, double.
 * **Java numbers**: java.lang.Number, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Float, java.lang.Byte, java.lang.Double, java.math.BigInteger, java.math.BigDecimal, java.util.concurrent.atomic.AtomicInteger, java.util.concurrent.atomic.AtomicLong.
 * **JMX composite types**: javax.management.openmbean.CompositeData, javax.management.openmbean.CompositeDataSupport.

**Only public MBean attributes can be accessed**. Various Java web-server can be monitored using this monitoring module like Wilfly, Tomcat, GlassFish, or Jetty. Please refer to the documentation of your web server to see how to enable JMX monitoring.

**This monitoring module is best suited for advanced users as it allows to query custom exposed MBeans**. For this reason, the Generic JMX monitoring module does not provide any counter pre-selection, nore predefined thresholds. If the server to monitor has a dedicated monitoring module defined in OctoPerf, we suggest to use it for the sake of simplicity.

## External JARs

In order to monitor certain vendor specific MBeans, additional libraries can sometimes be required. The appropriate JAR files are provided by each vendor.

In that case the procedure to pass the JAR to the OctoPerf agent is as follows:

- Create a local folder named "jmxlib": `mkdir jmxlib`
- Place the JAR files into this `jmxlib/` folder,

- Launch the OctoPerf agent from this folder and declare `jmxlib/` in the command-line via a volume mapping: ` -v ./jmxlib:/home/octoperf/jmxlib`

!!! Example
    WebLogic documentation indicates [two JAR files are required](https://docs.oracle.com/cd/E17904_01/web.1111/e13728/accesswls.htm#JMXCU152).

## Configuration

![Generic JMX Wizard](https://api.octoperf.com/doc/monitoring/create-connection/generic-jmx/img/generic-jmx-wizard.png "Generic JMX Wizard")

A **JMX Java URL** must be specified to connect the the JMX server remote connector. JMX Urls are usually in the form:

> `service:jmx:rmi:///jndi/rmi://{host}:{port}/jmxrmi`

Replace **{hostname}** and **{port}** by the monitored server hostname or IP and port. The syntax of the JMX URL is subject to vary depending on the type of server being monitored.

### Optional Authentication

**Enabling authentication is optional**. Authentication protects your server JMX endpoint from being accessible to anyone. An alternative to authentication is to filter access to JMX port (9004 by default) using **IPTables**.

### Firewall consideration

If the JMX server is behind a firewall, it is necessary to complete the Java URL by specifying the rmi connection port ( {rmi-port} ) and the connection port to the registry ( {registry-port} ).
`service:jmx:rmi://{host}:{rmi-port}/jndi/rmi://{host}:{registry-port}/jmxrmi`

A Java system property allows to enable the RMI port by specifying on server launch:

> `-Dcom.sun.management.jmxremote.rmi.port=9911`

### Monitored Counters

The available counters tree is dynamically generated depending on the MBeans exposed through the JMX connection. Select the counters to monitor in the counters tree.
