Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of JMX objects and attributes?

Tags:

java

jmx

I am trying to implement a nagios plugin, and doing so requires that I know specifically what object and attribute I want to monitor. The thing is, I haven't been able to find a listing anywhere of the standard system jmx objects and attributes. Can anyone point me in the right direction? I need to monitor things like memory pools, heap size, etc.

like image 776
Matthew Avatar asked Jul 07 '11 12:07

Matthew


People also ask

How do I monitor JMX metrics?

JMX Monitoring is done by querying data from “Managed Beans” (MBeans) that are exposed via a JVM port (JMX console). An MBean represents a resource running inside a JVM and provides data on the configuration and usage of that resource. MBeans are typically grouped into “domains” to denote where resources belong to.

What is JMX specification?

The JMX specification defines the architecture, design patterns, APIs, and services in the Java programming language for management and monitoring of applications and networks. Using the JMX technology, a given resource is instrumented by one or more Java objects known as Managed Beans, or MBeans.

What is JMX in Java with example?

The JMX Technology Programming Model. JMX Technology for Remote Management. JMX Technology Related Specifications. The Java Management Extensions (JMX) API is a standard —developed through the Java Community Process (JCP) as JSR 3—for managing and monitoring applications and services.

Is JMX deprecated?

Deprecated MBeanHome and Type-Safe Interfaces Now that the JMX remote APIs (JSR-160) are published, BEA's proprietary API for remote JMX access, weblogic. management. MBeanHome , is no longer needed and is therefore deprecated.


2 Answers

You can use

Set mbeans = mBeanServer.queryNames(null, null);
for (Object mbean : mbeans)
{
    WriteAttributes(mBeanServer, (ObjectName)mbean);
}

private void WriteAttributes(final MBeanServer mBeanServer, final ObjectName http)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException
{
    MBeanInfo info = mBeanServer.getMBeanInfo(http);
    MBeanAttributeInfo[] attrInfo = info.getAttributes();

    System.out.println("Attributes for object: " + http +":\n");
    for (MBeanAttributeInfo attr : attrInfo)
    {
        System.out.println("  " + attr.getName() + "\n");
    }
}

This will write all the object names and their attributes...

like image 82
Gilad Avatar answered Sep 24 '22 18:09

Gilad


You can always use mBeanServer.queryNames(null, null); for getting to all MBeans registered at a certain MBeanServer (where mBeanServer is the MBeanServerConnection which you obtained either locally or remotely).

However, before implementing your own Nagios Plugins, why not using an already exisiting one ? E.g. jmx4perl's check_jmx4perl which comes with tools for exploring the JMX namespace (like jmx4perl <url> list for listing all JMX MBeans with their attributes and operations or j4psh a readline based JMX shell with context sensitive command line completion).

like image 44
Roland Huß Avatar answered Sep 24 '22 18:09

Roland Huß