MBean nested object name in JMX
Asked Answered
O

2

7

I've noticed that some MBeans have nested keys; how do I make the query to get that key?

The image below shows an example:

enter image description here

Normally, the MBean query is like this: "org.apache.cassandra.metrics:type=CQL,name=RegularStatementsExecuted"

How do I add the additional folder to that query? I've tried the following:

"org.apache.cassandra.metrics:type=Cache,CounterCache,name=Capacity"
"org.apache.cassandra.metrics:type=Cache.CounterCache,name=Capacity"
"org.apache.cassandra.metrics:type=Cache,type=CounterCache,name=Capacity"

Any ideas?

I looked over Java Management Extensions (JMX) Best Practices and it doesn't mention anything about nested keys.

Oly answered 12/11, 2015 at 1:2 Comment(0)
O
5

I noticed that I could add scope to the property list when I looked at jconsole:

So, what I used was:

"org.apache.cassandra.metrics:type=Cache,scope=CounterCache,name=HitRate"

It's nice to know that it's not documented anywhere...

Oly answered 12/11, 2015 at 1:13 Comment(0)
V
3

To get all session ids of tomcat using JConsole which can be found at :-

Catalina > Manager > localhost > /##07 ( > Operations > listSessionIds )

To get the MBean object name of /##07 just click on it on JConsole and it will show the name.(As shown below)

enter image description here

Java code to fetch all the session Ids:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
JMXConnector jmxConn = JMXConnectorFactory.connect(url, null);
// Connecting to the MBeanServer
MBeanServerConnection mbsConn = jmxConn.getMBeanServerConnection();

Object sessionIds = mbsConn.invoke(new ObjectName("Catalina:type=Manager,host=localhost,context=/##07"), "listSessionIds", null, null);

System.out.println(sessionIds.toString());
//close jmx connection
jmxConn.close();
Vieira answered 19/12, 2017 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.