Commit cc0f5d33 cc0f5d33ccd04ddf0880a85a41c171dbea1e5a21 by Christian Gerdes

Fixat bug #7

1 parent 505f3c8c
...@@ -33,4 +33,11 @@ ...@@ -33,4 +33,11 @@
33 <nature>org.eclipse.jdt.core.javanature</nature> 33 <nature>org.eclipse.jdt.core.javanature</nature>
34 <nature>org.eclipse.wst.jsdt.core.jsNature</nature> 34 <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
35 </natures> 35 </natures>
36 <linkedResources>
37 <link>
38 <name>jetty/lilom.jar</name>
39 <type>1</type>
40 <locationURI>PROJECT_LOC/WebContent/WEB-INF/lib/lilom.jar</locationURI>
41 </link>
42 </linkedResources>
36 </projectDescription> 43 </projectDescription>
......
1 <%@page import="se.lil.om.Registry"%>
1 <%@page import="se.lil.om.OraMon"%> 2 <%@page import="se.lil.om.OraMon"%>
2 <%@page import="se.lil.jm.JmxMon"%> 3 <%@page import="se.lil.jm.JmxMon"%>
3 <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 4 <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
...@@ -13,14 +14,21 @@ ...@@ -13,14 +14,21 @@
13 // Handling of actions 14 // Handling of actions
14 boolean error = false; 15 boolean error = false;
15 String errMsg = ""; 16 String errMsg = "";
17 boolean info = false;
18 String infMsg = "";
19
16 if(request.getParameter("action") != null) { 20 if(request.getParameter("action") != null) {
17 if(request.getParameter("action").equals("add")) { 21 if(request.getParameter("action").equals("remove")) {
18 if(request.getParameter("data") != null && request.getParameter("data").length() != 0) { 22 if(request.getParameter("omconstr") != null && request.getParameter("omconstr").length() != 0) {
19 //se.lil.om.Registry.getList().add(new OraMon()); 23 se.lil.om.Registry.remove(request.getParameter("omconstr"));
20 } else { 24 info = true;
21 error = true; 25 infMsg = "Removed OraMon " + request.getParameter("omconstr");
22 errMsg = "Data is empty. Nothing added."; 26 }
23 } 27 if(request.getParameter("jmconstr") != null && request.getParameter("jmconstr").length() != 0) {
28 se.lil.jm.Registry.remove(request.getParameter("jmconstr"));
29 info = true;
30 infMsg = "Removed JmxMon " + request.getParameter("jmconstr");
31 }
24 } 32 }
25 } 33 }
26 %> 34 %>
...@@ -29,6 +37,10 @@ if(request.getParameter("action") != null) { ...@@ -29,6 +37,10 @@ if(request.getParameter("action") != null) {
29 <div style="background: Salmon; padding: 10px;">Error: <%= errMsg %></div> 37 <div style="background: Salmon; padding: 10px;">Error: <%= errMsg %></div>
30 <% } %> 38 <% } %>
31 39
40 <% if(info) { %>
41 <div style="background: Aquamarine; padding: 10px;">Info: <%= infMsg %> <form><input type="submit" value="OK"></form></div>
42 <% } %>
43
32 <h1>OraMon Web 1.1 with JmxMon</h1> 44 <h1>OraMon Web 1.1 with JmxMon</h1>
33 45
34 <h2>Status Oracle Monitors</h2> 46 <h2>Status Oracle Monitors</h2>
...@@ -46,6 +58,7 @@ if(request.getParameter("action") != null) { ...@@ -46,6 +58,7 @@ if(request.getParameter("action") != null) {
46 <th>Last Exception</th> 58 <th>Last Exception</th>
47 <th>Age</th> 59 <th>Age</th>
48 <th>RT</th> 60 <th>RT</th>
61 <th>Action</th>
49 </tr> 62 </tr>
50 <% for (OraMon mon : se.lil.om.Registry.getList()) { %> 63 <% for (OraMon mon : se.lil.om.Registry.getList()) { %>
51 <tr> 64 <tr>
...@@ -57,6 +70,7 @@ if(request.getParameter("action") != null) { ...@@ -57,6 +70,7 @@ if(request.getParameter("action") != null) {
57 <td><%= mon.getLastEx() %></td> 70 <td><%= mon.getLastEx() %></td>
58 <td><%= mon.getAgeTs() %>s</td> 71 <td><%= mon.getAgeTs() %>s</td>
59 <td><%= mon.getLastRTms() %>ms</td> 72 <td><%= mon.getLastRTms() %>ms</td>
73 <td><form method="POST"><input type="submit" name="action" value="remove" ><input type="hidden" name="omconstr" value="<%= mon.getConString() %>"></form></td>
60 </tr> 74 </tr>
61 <% } %> 75 <% } %>
62 </table> 76 </table>
...@@ -77,6 +91,7 @@ if(request.getParameter("action") != null) { ...@@ -77,6 +91,7 @@ if(request.getParameter("action") != null) {
77 <th>Last Exception</th> 91 <th>Last Exception</th>
78 <th>Age</th> 92 <th>Age</th>
79 <th>RT</th> 93 <th>RT</th>
94 <th>Action</th>
80 </tr> 95 </tr>
81 <% for (JmxMon mon : se.lil.jm.Registry.getList()) { %> 96 <% for (JmxMon mon : se.lil.jm.Registry.getList()) { %>
82 <tr> 97 <tr>
...@@ -88,6 +103,7 @@ if(request.getParameter("action") != null) { ...@@ -88,6 +103,7 @@ if(request.getParameter("action") != null) {
88 <td><%= mon.getLastEx() %></td> 103 <td><%= mon.getLastEx() %></td>
89 <td><%= mon.getAgeTs() %>s</td> 104 <td><%= mon.getAgeTs() %>s</td>
90 <td><%= mon.getLastRTms() %>ms</td> 105 <td><%= mon.getLastRTms() %>ms</td>
106 <td><form method="POST"><input type="submit" name="action" value="remove" ><input type="hidden" name="jmconstr" value="<%= mon.getConString() %>"></form></td>
91 </tr> 107 </tr>
92 <% } %> 108 <% } %>
93 </table> 109 </table>
......
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html>
3 <head>
4 <title>LIL JMX Monitor</title>
5 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
6 <script type="text/javascript">
7 var ac_data = null;
8 var ac_chart = null;
9
10 google.load("visualization", "1", { packages: ["corechart"] });
11 google.setOnLoadCallback(getData);
12
13 var ac_options = {
14 title: 'Current Real User Activity',
15 hAxis: { title: 'Timeline', titleTextStyle: { color: '#333'}, format: 'HH:mm:ss' },
16 vAxis: { minValue: 0 },
17 isStacked: false
18 };
19
20 function createChart(nvarray) {
21 ac_data = new google.visualization.DataTable();
22
23 ac_data.addColumn('datetime', 'Time');
24
25 for(var i=0; i < nvarray.length; i++) {
26 ac_data.addColumn('number', nvarray[i].name);
27 }
28
29 ac_chart = new google.visualization.LineChart(document.getElementById('ac_div'));
30 ac_chart.draw(ac_data, ac_options);
31
32 }
33
34 function getData() {
35 var client = new XMLHttpRequest();
36 client.onreadystatechange = handler;
37 if(location.search != '')
38 {
39 client.open("GET", "/JmxMonREST/getMetrics?connectionString=" + location.search.substring(1));
40 client.setRequestHeader('Cache-Control', 'no-cache');
41 client.setRequestHeader('Pragma', 'no-cache');
42 client.send();
43 } else {
44 // Error, no monitor specified
45 ac_div.innerHTML = "<p>No monitor specified in URL QueryString (use ?enter uri encoded con string)</p>";
46 }
47
48 }
49
50 function handler() {
51 var cT = new Date();
52 if (this.readyState == 4) {
53 if (this.status == 200 &&
54 this.responseText != null) {
55 addData(this.responseText);
56 return;
57 }
58 }
59 }
60
61 function addData(data) {
62 var res = eval('(' + data + ')');
63
64 if (ac_data == null) {
65 createChart(res.nvarray);
66 }
67
68 var dataRow = [];
69 dataRow.push(new Date());
70 for(var i=0; i < res.nvarray.length; i++) {
71 dataRow[i+1] = res.nvarray[i].value;
72 }
73
74 if (ac_data.getNumberOfRows() > 1000) ac_data.removeRow(0);
75
76 ac_data.addRow(dataRow);
77 ac_chart.draw(ac_data, ac_options);
78
79 window.setTimeout('getData()', 5000);
80 }
81
82 </script>
83 </head>
84 <body>
85 <h1>LIL JMX Monitor</h1>
86 <div id="ac_div" style="width: 99%; height: 80%; "></div>
87 </body>
88 </html>
No preview for this file type
...@@ -68,7 +68,7 @@ public class JmxMonRESTgetMetrics extends HttpServlet { ...@@ -68,7 +68,7 @@ public class JmxMonRESTgetMetrics extends HttpServlet {
68 sb.append("{\"error\":false,\"nvarray\":"); 68 sb.append("{\"error\":false,\"nvarray\":");
69 sb.append("["); 69 sb.append("[");
70 70
71 sb.append(",{\"name\":\"Number of processors #\",\"value\":" + mon.getNumberOfCPUs() + "}"); 71 sb.append("{\"name\":\"Number of processors #\",\"value\":" + mon.getNumberOfCPUs() + "}");
72 sb.append(",{\"name\":\"Process CPU Used %\",\"value\":" + mon.getCPUPercent() + "}"); 72 sb.append(",{\"name\":\"Process CPU Used %\",\"value\":" + mon.getCPUPercent() + "}");
73 sb.append(",{\"name\":\"Process Threads #\",\"value\":" + mon.getThreads() + "}"); 73 sb.append(",{\"name\":\"Process Threads #\",\"value\":" + mon.getThreads() + "}");
74 sb.append(",{\"name\":\"Process Loaded Classes #\",\"value\":" + mon.getLoadedClassCount() + "}"); 74 sb.append(",{\"name\":\"Process Loaded Classes #\",\"value\":" + mon.getLoadedClassCount() + "}");
......
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://u30030:28392/weblogic.management.mbeanservers.runtime"
...\ No newline at end of file ...\ No newline at end of file
...@@ -25,4 +25,19 @@ public class Registry { ...@@ -25,4 +25,19 @@ public class Registry {
25 jmxList.add(monitor); 25 jmxList.add(monitor);
26 return monitor; 26 return monitor;
27 } 27 }
28
29 public static synchronized void remove(String conStr) {
30 JmxMon mon = null;
31 for (JmxMon item : getList()) {
32 if(item.getConString().equals(conStr)) {
33 mon = item;
34 }
35 }
36 if(mon != null) {
37 try {
38 mon.close();
39 } catch (Throwable t) {}
40 getList().remove(mon);
41 }
42 }
28 } 43 }
......
...@@ -21,11 +21,12 @@ public class TestRunner { ...@@ -21,11 +21,12 @@ public class TestRunner {
21 21
22 //JmxMon mon1 = new JmxMon("service:jmx:iiop:///jndi/iiop://u30457:29722/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2 22 //JmxMon mon1 = new JmxMon("service:jmx:iiop:///jndi/iiop://u30457:29722/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2
23 //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:rmi:///jndi/iiop://u30128:23032/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2
24 JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.12.1 24 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30009:26732/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.12.1
25 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30009:2673/weblogic.management.mbeanservers.runtime"); // Fel port 25 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30009:2673/weblogic.management.mbeanservers.runtime"); // Fel port
26 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u02878.ht.kap.rsv.se:17040/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2 PS 26 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u02878.ht.kap.rsv.se:17040/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2 PS
27 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u01891.ef.kap.rsv.se:17020/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2 CMS 27 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u01891.ef.kap.rsv.se:17020/weblogic.management.mbeanservers.runtime"); // 10.3.6.0.161018.2 CMS
28 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30450:34502/weblogic.management.mbeanservers.runtime"); // CMS 28 //JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30450:34502/weblogic.management.mbeanservers.runtime"); // CMS
29 JmxMon mon1 = new JmxMon("service:jmx:rmi:///jndi/iiop://u30030:28392/weblogic.management.mbeanservers.runtime");
29 //mon1.open(); 30 //mon1.open();
30 //mon2.open(); 31 //mon2.open();
31 jmxList.add(mon1); 32 jmxList.add(mon1);
......
...@@ -24,4 +24,19 @@ public class Registry { ...@@ -24,4 +24,19 @@ public class Registry {
24 oraList.add(monitor); 24 oraList.add(monitor);
25 return monitor; 25 return monitor;
26 } 26 }
27
28 public static synchronized void remove(String conStr) {
29 OraMon mon = null;
30 for (OraMon item : getList()) {
31 if(item.getConString().equals(conStr)) {
32 mon = item;
33 }
34 }
35 if(mon != null) {
36 try {
37 mon.close();
38 } catch (Throwable t) {}
39 getList().remove(mon);
40 }
41 }
27 } 42 }
......