Read attributes from system/console/JMX page | Community
Skip to main content
Level 3
July 9, 2024
Solved

Read attributes from system/console/JMX page

  • July 9, 2024
  • 2 replies
  • 1140 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

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


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

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
July 11, 2024
ASP_CorpAuthor
Level 3
July 22, 2024

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?
ASP_CorpAuthor
Level 3
July 24, 2024

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


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


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);
kautuk_sahni
Community Manager
Community Manager
July 23, 2024

@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