Showing posts with label jboss. Show all posts
Showing posts with label jboss. Show all posts

Thursday, November 3, 2011

Getting VM name and hostname from JBoss JMX

JBoss JMX exposes all information about the server as MBean's.
Here is a simple way if you need get the JVM name and the host name in your application.
For getting the JVM name 
ServerConfigImplMBean serverConfigMbean = 
MBeanProxyExt.create( ServerConfigImplMBean.class,
“jboss.system:type=ServerConfig”, 
MBeanServerLocator.locateJBoss()); 

serverConfigMbean. getServerName(); 

For getting the Host name 
ServerInfoMBean serverInfoMbean = 
MBeanProxyExt.create( ServerInfoMBean.class, 
“jboss.system:type=ServerInfo”, 
MBeanServerLocator.locateJBoss());  

serverInfoMbean.getHostName(); 

From the JMX Browser we can get the complete list of Server level exposed MBeans under "jboss.system"