Commit cc0f5d33 cc0f5d33ccd04ddf0880a85a41c171dbea1e5a21 by Christian Gerdes

Fixat bug #7

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