Commit 11bc5265 11bc5265810319be9eee9db2bb97a6c55413595c by Christian Gerdes

JMX clienter och lite annat i lib, fungerande runner

JMX clienterna finns för 2 olika wls versioner fast dessa inte behövs
1 parent 92dffe6c
No preview for this file type
1 javaw.exe -Dcom.sun.management.jmxremote.ssl=false -cp "wls-10.3.6.0.161018.2/wljmxclient.jar;jconsole.1.8.0_91.jar" sun.tools.jconsole.JConsole "service:jmx:rmi:///jndi/iiop://u30128:23032/weblogic.management.mbeanservers.runtime"
...\ No newline at end of file ...\ No newline at end of file
1 javaw.exe -Dcom.sun.management.jmxremote.ssl=false -cp "wls-10.3.6.0.12.1/wljmxclient.jar;jconsole.1.8.0_91.jar" sun.tools.jconsole.JConsole "service:jmx:rmi:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -16,42 +16,37 @@ import javax.management.remote.JMXConnector; ...@@ -16,42 +16,37 @@ import javax.management.remote.JMXConnector;
16 import javax.management.remote.JMXConnectorFactory; 16 import javax.management.remote.JMXConnectorFactory;
17 import javax.management.remote.JMXServiceURL; 17 import javax.management.remote.JMXServiceURL;
18 import javax.management.openmbean.CompositeData; 18 import javax.management.openmbean.CompositeData;
19 import javax.management.openmbean.TabularData;
19 20
20 public class JmxMon { 21 public class JmxMon {
21 String conUser = "system"; 22 String conUser = "system";
22 String conPass = "passw0rd"; 23 String conPass = "passw0rd";
23 String domain = null; 24 String domainName = null;
25 String serverName = null;
26 String runtimeName = null;
24 27
25 JMXServiceURL url = null; 28 JMXServiceURL url = null;
26 JMXConnector jmxc = null; 29 JMXConnector jmxc = null;
27 MBeanServerConnection mbsc = null; 30 MBeanServerConnection mbsc = null;
28 31
32 Thread myThread = null;
33 ClassLoader myCL = null;
34
29 Collector col = new Collector(); 35 Collector col = new Collector();
30 36
31 int getDataCalls = 0; 37 int getDataCalls = 0;
32 int getDataSucess = 0; 38 int getDataSucess = 0;
33 39
34 public void dumpAllMBeans() { 40 public Object getAttributeValue(String name, String attribute) {
35 dumpAllMBeans(null); 41 Object ro = null;
36 }
37
38 public void dumpAllMBeans(String query) {
39 if(mbsc != null) { 42 if(mbsc != null) {
40 try { 43 try {
41 Set<ObjectName> res = mbsc.queryNames(query != null ? new ObjectName(query) : ObjectName.WILDCARD, null); 44 ro = mbsc.getAttribute(new ObjectName(name), attribute);
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) { 45 } catch (Exception e) {
51 // TODO Auto-generated catch block 46 ro = e;
52 e.printStackTrace();
53 } 47 }
54 } 48 }
49 return ro;
55 } 50 }
56 51
57 public int getDataCalled() { 52 public int getDataCalled() {
...@@ -71,11 +66,33 @@ public class JmxMon { ...@@ -71,11 +66,33 @@ public class JmxMon {
71 else return null; 66 else return null;
72 } 67 }
73 68
69 public String getServerName() {
70 return serverName;
71 }
72
73 public String getDomainName() {
74 return domainName;
75 }
76
77 public String getRuntimeName() {
78 return runtimeName;
79 }
80
74 public void open() throws IOException { 81 public void open() throws IOException {
75 if(url != null) { 82 if(url != null) {
76 jmxc = JMXConnectorFactory.connect(url); 83 jmxc = JMXConnectorFactory.connect(url);
77 mbsc = jmxc.getMBeanServerConnection(); 84 mbsc = jmxc.getMBeanServerConnection();
78 domain = mbsc.getDefaultDomain(); 85 domainName = mbsc.getDefaultDomain();
86 Object obj = getAttributeValue("java.lang:type=Runtime", "Name");
87 if(obj.getClass().equals(java.lang.String.class)) {
88 runtimeName = (String)obj;
89 }
90 obj = getAttributeValue("java.lang:type=Runtime", "SystemProperties");
91 TabularData td = (TabularData)obj;
92 for (Object o : td.values()) {
93 CompositeData d = (CompositeData)o;
94 if(d.get("key").toString().equals("weblogic.Name")) serverName = d.get("value").toString();
95 }
79 } 96 }
80 } 97 }
81 98
......
...@@ -19,8 +19,8 @@ public class TestRunner { ...@@ -19,8 +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:rmi:///jndi/iiop://u01892.ef.kap.rsv.se:17020/weblogic.management.mbeanservers.runtime"); 22 JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30128:23032/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2
23 JmxMon mon1 = new JmxMon("service:jmx:iiop:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"); 23 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.12.1
24 mon1.open(); 24 mon1.open();
25 jmxList.add(mon1); 25 jmxList.add(mon1);
26 26
...@@ -31,8 +31,11 @@ public class TestRunner { ...@@ -31,8 +31,11 @@ public class TestRunner {
31 + "\nTime: " + time + "ms\n" 31 + "\nTime: " + time + "ms\n"
32 ); 32 );
33 33
34 mon1.dumpAllMBeans("java.lang:*"); 34 System.out.println("Connected to server " + mon1.getServerName() + " on domain " + mon1.getDomainName() + " and machine " + mon1.getRuntimeName());
35 35
36 //mon1.listAllMBeans();
37 //mon1.dumpAllMBeans("java.lang:*");
38 /*
36 int times = 0; 39 int times = 0;
37 while(times-- > 0) { 40 while(times-- > 0) {
38 for(JmxMon mon : jmxList) { 41 for(JmxMon mon : jmxList) {
...@@ -41,11 +44,6 @@ public class TestRunner { ...@@ -41,11 +44,6 @@ public class TestRunner {
41 mon.getData(); 44 mon.getData();
42 time = System.currentTimeMillis() - ts1; 45 time = System.currentTimeMillis() - ts1;
43 46
44 System.out.println(
45 "GetData called on " + mon.domain + " (age was " + age + "s)"
46 + "\nTime: " + time + "ms\n\n"
47 );
48
49 } 47 }
50 Thread.sleep(15000); 48 Thread.sleep(15000);
51 } 49 }
...@@ -55,5 +53,6 @@ public class TestRunner { ...@@ -55,5 +53,6 @@ public class TestRunner {
55 mon.close(); 53 mon.close();
56 System.out.println("Monitor closed. " + mon.getDataCalled() + " calls and " + mon.getDataSucceeded() + " succeeded and " + mon.getDataFailed() + " failed."); 54 System.out.println("Monitor closed. " + mon.getDataCalled() + " calls and " + mon.getDataSucceeded() + " succeeded and " + mon.getDataFailed() + " failed.");
57 } 55 }
56 */
58 } 57 }
59 } 58 }
......