Expand my Community achievements bar.

SOLVED

Read attributes from system/console/JMX page

Avatar

Level 3

Newbie to AEM. I have a requirement to read some attributes from the system/console/jmx page. On the JMX page we are looking for Domain org.apache.jackrabbit.oak, and from that domain, we need to read the values of some attributes like AttributeName=Statistics. how do i achieve this?. online i see many resources describing Mbeans creation and manipulation in JMX, but i dont think i need to create any Mbean, i just want to read some attributes on the JMX page. any directions would be appreciated. thank you.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You just need to find a pattern that gives you all the instances you need while creating the `ObjectName`. In the code you posted, you are being too specific to get this item: "org.apache.jackrabbit.oak:id=\"Client c31f948f-5ec9-4bf4-9fb5-5b259018aa93\",type=\"Standby\",name=Status". 

EstebanBustamante_0-1721681179865.png


Please check this as a reference: https://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html



Esteban Bustamante

View solution in original post

5 Replies

Avatar

Level 3

Hi, Esteban, thanks for the direction. it is working now. but i have another problem. For the JMX cold sync Mbean, it has multiple instances. how do i get all the instances? for example if you go the JMX page and search by "standby", you will get multiple instances shown in the picture. how do i get the multiple instances? when i do 

ObjectName objectName = new ObjectName("org.apache.jackrabbit.oak:id=\"Client c31f948f-5ec9-4bf4-9fb5-5b259018aa93\",type=\"Standby\",name=Status"); i get the instance with given client ID. but if there are multiple instances with corresponding multiple clients, how do i get all the instances?

Avatar

Correct answer by
Community Advisor

You just need to find a pattern that gives you all the instances you need while creating the `ObjectName`. In the code you posted, you are being too specific to get this item: "org.apache.jackrabbit.oak:id=\"Client c31f948f-5ec9-4bf4-9fb5-5b259018aa93\",type=\"Standby\",name=Status". 

EstebanBustamante_0-1721681179865.png


Please check this as a reference: https://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html



Esteban Bustamante

Avatar

Level 3

hi Esteban, thanks for the direction and yes it worked. but with a slight change. so, if anyone want to get multiple instances of JMX beans, you need to give a pattern and all the instances that satisfy that pattern are returned. the objects are returned in a set.

 

MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> allInstancesSatisfyingThePattern = mBeanServer.queryNames(new ObjectName("org.apache.jackrabbit.oak:type=\"Standby\",name=Status,*"), null);

Avatar

Administrator

@ASP_Corp Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni