Lagt till dumpAllMBeans()
Showing
2 changed files
with
32 additions
and
2 deletions
| ... | @@ -2,11 +2,15 @@ package se.lil.jm; | ... | @@ -2,11 +2,15 @@ package se.lil.jm; |
| 2 | 2 | ||
| 3 | import java.io.IOException; | 3 | import java.io.IOException; |
| 4 | import java.net.MalformedURLException; | 4 | import java.net.MalformedURLException; |
| 5 | import java.util.Set; | ||
| 5 | import java.util.concurrent.locks.Lock; | 6 | import java.util.concurrent.locks.Lock; |
| 6 | import java.util.concurrent.locks.ReentrantLock; | 7 | import java.util.concurrent.locks.ReentrantLock; |
| 7 | 8 | ||
| 8 | import javax.management.JMX; | 9 | import javax.management.JMX; |
| 10 | import javax.management.MBeanAttributeInfo; | ||
| 11 | import javax.management.MBeanInfo; | ||
| 9 | import javax.management.MBeanServerConnection; | 12 | import javax.management.MBeanServerConnection; |
| 13 | import javax.management.MalformedObjectNameException; | ||
| 10 | import javax.management.ObjectName; | 14 | import javax.management.ObjectName; |
| 11 | import javax.management.remote.JMXConnector; | 15 | import javax.management.remote.JMXConnector; |
| 12 | import javax.management.remote.JMXConnectorFactory; | 16 | import javax.management.remote.JMXConnectorFactory; |
| ... | @@ -27,6 +31,29 @@ public class JmxMon { | ... | @@ -27,6 +31,29 @@ public class JmxMon { |
| 27 | int getDataCalls = 0; | 31 | int getDataCalls = 0; |
| 28 | int getDataSucess = 0; | 32 | int getDataSucess = 0; |
| 29 | 33 | ||
| 34 | public void dumpAllMBeans() { | ||
| 35 | dumpAllMBeans(null); | ||
| 36 | } | ||
| 37 | |||
| 38 | public void dumpAllMBeans(String query) { | ||
| 39 | if(mbsc != null) { | ||
| 40 | try { | ||
| 41 | Set<ObjectName> res = mbsc.queryNames(query != null ? new ObjectName(query) : ObjectName.WILDCARD, null); | ||
| 42 | for (ObjectName name : res) { | ||
| 43 | System.out.println(name.getCanonicalName()); | ||
| 44 | MBeanInfo inf = mbsc.getMBeanInfo(name); | ||
| 45 | MBeanAttributeInfo[] attribs = inf.getAttributes(); | ||
| 46 | for (MBeanAttributeInfo ainf : attribs) { | ||
| 47 | System.out.println("(" + ainf.getType() + ") " + ainf.getName()); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } catch (Exception e) { | ||
| 51 | // TODO Auto-generated catch block | ||
| 52 | e.printStackTrace(); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 30 | public int getDataCalled() { | 57 | public int getDataCalled() { |
| 31 | return getDataCalls; | 58 | return getDataCalls; |
| 32 | } | 59 | } | ... | ... |
| ... | @@ -19,7 +19,8 @@ public class TestRunner { | ... | @@ -19,7 +19,8 @@ public class TestRunner { |
| 19 | 19 | ||
| 20 | Long ts1 = System.currentTimeMillis(); | 20 | Long ts1 = System.currentTimeMillis(); |
| 21 | 21 | ||
| 22 | JmxMon mon1 = new JmxMon("service:jmx:iiop:///jndi/iiop://u01892.ef.kap.rsv.se:17020/weblogic.management.mbeanservers.runtime"); | 22 | //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u01892.ef.kap.rsv.se:17020/weblogic.management.mbeanservers.runtime"); |
| 23 | JmxMon mon1 = new JmxMon("service:jmx:iiop:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"); | ||
| 23 | mon1.open(); | 24 | mon1.open(); |
| 24 | jmxList.add(mon1); | 25 | jmxList.add(mon1); |
| 25 | 26 | ||
| ... | @@ -30,7 +31,9 @@ public class TestRunner { | ... | @@ -30,7 +31,9 @@ public class TestRunner { |
| 30 | + "\nTime: " + time + "ms\n" | 31 | + "\nTime: " + time + "ms\n" |
| 31 | ); | 32 | ); |
| 32 | 33 | ||
| 33 | int times = 3; | 34 | mon1.dumpAllMBeans("java.lang:*"); |
| 35 | |||
| 36 | int times = 0; | ||
| 34 | while(times-- > 0) { | 37 | while(times-- > 0) { |
| 35 | for(JmxMon mon : jmxList) { | 38 | for(JmxMon mon : jmxList) { |
| 36 | ts1 = System.currentTimeMillis(); | 39 | ts1 = System.currentTimeMillis(); | ... | ... |
-
Please register or sign in to post a comment