WEB容器:JBOSS-eap-4
现获取JMX数据方式有以下几种:
1. 使用cmdline-jmxclient-0.10.3.jar
-
java -jar cmdline-jmxclient-0.10.3.jar - ip:port jboss.web:*
使用此种方式时,有时会遇到ClassNotFoundException,比如 jboss.system:service=ThreadPool QueueSize
此时需要用到jbossall-client.jar,
-Djava.ext.dirs= 指定到jbossall-client.jar所在目录
-
java -Djava.ext.dirs=. -jar cmdline-jmxclient-0.10.3.jar - ip:port jboss.system:service=ThreadPool QueueSize
2. 浏览器直接打开
这种方式如果配置了账号密码(conf/props/..),需要登录
3. IE 打开
这个需要使用applet 配置起来有点麻烦
4. 使用JAVA代码
此种方式需要导入jbossall-client.jar,部分代码手打 可能有错
可以参考:
-
import java.util.Iterator;
-
import java.util.Properties;
-
import java.util.Set;
-
-
import javax.management.MBeanInfo;
-
import javax.management.MBeanOperationInfo;
-
import javax.management.MBeanParameterInfo;
-
import javax.management.ObjectInstance;
-
import javax.management.ObjectName;
-
import javax.naming.InitialContext;
-
-
import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
-
-
public class JbossJmxInfo{
-
-
public static void main(String[] args) {
-
Properties pro = new Properties();
-
pro.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
-
pro.setProperty("java.naming.provider.url", "jnp://192.168.125.111:1099");
-
pro.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
-
InitialContext ic = new InitialContext(pro);
-
RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
-
OjbectName threadObjectName = new ObjectName("jboss.system:service=ThreadPool");
-
System.out.println(server.getAttribute(threadObjectName,"QueueSize"));
-
String[] attributes = new String[]{"Name","QueueSize"};
-
AttributeList attributeList = server.getAttributes(threadObjectName,attributes);
-
for (int i=0;i<attributeList.size;i++){
-
Attribute attr = (Attribute )attributeList.get(i);
-
System.out.println(attr.getName()+":"+attr.getValue());
-
}
5. 使用jboss自带的twiddle.sh
-s 可以使用IP 或jnp://ip:1099
可以参考:http://blog.csdn.net/niuhea/article/details/14005291
-
./twiddle -s jnp://ip:1099 -uadmin -padmin query "jboss.system:*"
-
./twiddle -s jnp://ip:1099 -uadmin -padmin get"jboss.system:service=ThreadPool" QueueSize
阅读(1433) | 评论(0) | 转发(0) |