Matthew
Matthew

Reputation: 512

List of JMX objects and attributes?

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.

Upvotes: 22

Views: 45056

Answers (5)

helios
helios

Reputation: 2821

Check out MC4J or JConsole - it's trivial to get going with both of 'em.

Upvotes: 0

Roland Huß
Roland Huß

Reputation: 2525

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).

Upvotes: 21

Gilad
Gilad

Reputation: 841

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...

Upvotes: 32

Chux Uzoeto
Chux Uzoeto

Reputation: 1404

From a sysadmin point of view, I fully understand the bases for the question. The standard JMX documentation, or the objects one can encounter while trying to browse JMX object trees, can be overwhelming and confusing.

I have found this Op5 KB article quite useful in providing a decent overview of JMX objects of interest for JBoss.

Obviously, one needs to adjust to fit with the monitoring system they are actually using, but there is enough in the examples for whatever nagios-based monitoring system is being used.

Upvotes: 2

Joel
Joel

Reputation: 30156

Are you looking for the JVM platform MBean docs?

There are examples there on to get the MBeans and interrogate them e.g.

The ThreadMXBean platform MBean provides support for monitoring thread contention and thread CPU time.

Upvotes: 1

Related Questions