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.
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.
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.
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.
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.
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...
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With