Commit 91783105 9178310507f4d03421c0c778f59f3b93964ccf12 by Christian Gerdes

Fungerande viewJmxMon.html

Lagt till view knapp för denna i OraMon.jsp
1 parent cc0f5d33
<%@page import="java.net.URLEncoder"%>
<%@page import="se.lil.om.Registry"%>
<%@page import="se.lil.om.OraMon"%>
<%@page import="se.lil.jm.JmxMon"%>
......@@ -70,7 +71,13 @@ 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>
<td>
<form method="POST">
<input type="submit" name="action" value="remove" >
<input type="hidden" name="omconstr" value="<%= mon.getConString() %>">
<input type="button" value="view" onClick="window.open('/viewOraMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')">
</form>
</td>
</tr>
<% } %>
</table>
......@@ -103,7 +110,13 @@ 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>
<td>
<form method="POST">
<input type="submit" name="action" value="remove" >
<input type="hidden" name="jmconstr" value="<%= mon.getConString() %>">
<input type="button" value="view" onClick="window.open('/viewJmxMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')">
</form>
</td>
</tr>
<% } %>
</table>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html>
<head>
<title>LIL JMX Monitor</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
</head>
<body>
<h1 id="main_title">LIL JMX Monitor</h1>
<div style="background-color: lightgrey; line-height:1em; min-height:3em;"><p id="statusP">Nothing loaded</p></div>
<div id="main_div"></div>
<script type="text/javascript">
var ac_data = null;
var ac_chart = null;
var ac_data = [];
var ac_chart = [];
var created = false;
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(getData);
var ac_options = {
title: 'Current Real User Activity',
title: 'Current Activity',
hAxis: { title: 'Timeline', titleTextStyle: { color: '#333'}, format: 'HH:mm:ss' },
vAxis: { minValue: 0 },
isStacked: false
vAxis: { },
isStacked: false,
legend: { position: 'none' }
};
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_data[i] = new google.visualization.DataTable();
ac_data[i].addColumn('datetime', 'Time');
ac_data[i].addColumn('number', nvarray[i].name);
var newdiv = document.createElement('div');
newdiv.id = 'ac_div' + i;
main_div.appendChild(newdiv);
ac_chart[i] = new google.visualization.LineChart(newdiv);
}
ac_chart = new google.visualization.LineChart(document.getElementById('ac_div'));
ac_chart.draw(ac_data, ac_options);
created = true;
}
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();
// Update the data
statusP.innerHTML = "Calling getData...";
var client1 = new XMLHttpRequest();
client1.onreadystatechange = handler1;
client1.open("GET", "/JmxMonREST/getData?age=14&connectionString=" + location.search.substring(1));
client1.setRequestHeader('Cache-Control', 'no-cache');
client1.setRequestHeader('Pragma', 'no-cache');
client1.send();
} else {
// Error, no monitor specified
ac_div.innerHTML = "<p>No monitor specified in URL QueryString (use ?enter uri encoded con string)</p>";
statusP.innerHTML = "No monitor specified in URL QueryString (use ?enter uri encoded con string)";
}
}
function getMetrics() {
if(location.search != '')
{
// Get the metrics
statusP.innerHTML += "<br>Calling getMetrics...";
var client2 = new XMLHttpRequest();
client2.onreadystatechange = handler2;
client2.open("GET", "/JmxMonREST/getMetrics?connectionString=" + location.search.substring(1));
client2.setRequestHeader('Cache-Control', 'no-cache');
client2.setRequestHeader('Pragma', 'no-cache');
client2.send();
} else {
// Error, no monitor specified
statusP.innerHTML = "No monitor specified in URL QueryString (use ?enter uri encoded con string)";
}
}
function handler() {
var cT = new Date();
function handler1() {
if (this.readyState == 4) {
if ((this.status == 200 || this.status == 202) &&
this.responseText != null) {
var res = eval('(' + this.responseText + ')');
statusP.innerHTML += " Received 200 OK (ms:" + res.ms + " age:" + res.age + ")<br>" + res.msg;
getMetrics();
} else {
statusP.innerHTML += " Received responsecode " + this.status;
}
}
}
function handler2() {
if (this.readyState == 4) {
if (this.status == 200 &&
this.responseText != null) {
addData(this.responseText);
return;
statusP.innerHTML += " Received 200 OK";
var res = eval('(' + this.responseText + ')');
addData(res);
} else {
statusP.innerHTML += " Received responsecode " + this.status;
}
}
}
function addData(data) {
var res = eval('(' + data + ')');
if (ac_data == null) {
createChart(res.nvarray);
function addData(res) {
if(res.error == false && res.nvarray.length > 0) {
main_title.innerHTML = res.name + " JMX Monitor";
if (created == false) {
createChart(res.nvarray);
}
for(var i=0; i < res.nvarray.length; i++) {
var dataRow = [];
dataRow[0] = new Date();
dataRow[1] = res.nvarray[i].value;
ac_data[i].addRow(dataRow);
if (ac_data[i].getNumberOfRows() > 1000) ac_data[i].removeRow(0);
ac_options.title = res.nvarray[i].name + ": " + res.nvarray[i].value;
ac_chart[i].draw(ac_data[i], ac_options);
}
}
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);
window.setTimeout('getData()', 15000);
}
</script>
</head>
<body>
<h1>LIL JMX Monitor</h1>
<div id="ac_div" style="width: 99%; height: 80%; "></div>
</body>
</html>
......
......@@ -65,26 +65,30 @@ public class JmxMonRESTgetMetrics extends HttpServlet {
}
// Loop over all monitors and output a Json array with the default set of metrics
sb.append("{\"error\":false,\"nvarray\":");
sb.append("{\"name\":\"" + mon.getServerName() + "\",\"error\":false,\"nvarray\":");
sb.append("[");
sb.append("{\"name\":\"Number of processors #\",\"value\":" + mon.getNumberOfCPUs() + "}");
sb.append(",{\"name\":\"Process CPU Used %\",\"value\":" + mon.getCPUPercent() + "}");
sb.append("{\"name\":\"Process CPU Used %\",\"value\":" + mon.getCPUPercent() + "}");
sb.append(",{\"name\":\"Process Heap Used %\",\"value\":" + mon.getHeapUsedPercent() + "}");
sb.append(",{\"name\":\"OldGen Used %\",\"value\":" + mon.getOldGenUsedPercent() + "}");
sb.append(",{\"name\":\"GC Time (Overhead) %\",\"value\":" + mon.getGCOverhead() + "}");
sb.append(",{\"name\":\"Process File Descriptors %\",\"value\":" + mon.getSystemFileDescriptorsPercentUsed() + "}");
sb.append(",{\"name\":\"System Memory %\",\"value\":" + mon.getSystemMemoryPercentUsed() + "}");
sb.append(",{\"name\":\"System Swap %\",\"value\":" + mon.getSystemSwapPercentUsed() + "}");
sb.append(",{\"name\":\"Process Threads #\",\"value\":" + mon.getThreads() + "}");
sb.append(",{\"name\":\"Process Loaded Classes #\",\"value\":" + mon.getLoadedClassCount() + "}");
sb.append(",{\"name\":\"Process File Descriptors %\",\"value\":" + mon.getSystemFileDescriptorsPercentUsed() + "}");
sb.append(",{\"name\":\"Process Heap Committed MB\",\"value\":" + mon.getHeapCommittedMB() + "}");
sb.append(",{\"name\":\"Process Heap Used MB\",\"value\":" + mon.getHeapUsedMB() + "}");
sb.append(",{\"name\":\"Process Heap Used %\",\"value\":" + mon.getHeapUsedPercent() + "}");
sb.append(",{\"name\":\"OldGen Used MB\",\"value\":" + mon.getOldGenUsedMB() + "}");
sb.append(",{\"name\":\"OldGen Used %\",\"value\":" + mon.getOldGenUsedPercent() + "}");
sb.append(",{\"name\":\"OldGen After Last GC MB\",\"value\":" + mon.getOldGenAfterGCMB() + "}");
sb.append(",{\"name\":\"PermGen After Last GC MB\",\"value\":" + mon.getPermGenAfterGCMB() + "}");
sb.append(",{\"name\":\"GC Time (Overhead) %\",\"value\":" + mon.getGCOverhead() + "}");
sb.append(",{\"name\":\"System Load (per cpu)\",\"value\":" + mon.getAverageLoadPerCpu() + "}");
sb.append(",{\"name\":\"System Load (total)\",\"value\":" + mon.getAverageLoad() + "}");
sb.append(",{\"name\":\"System Memory %\",\"value\":" + mon.getSystemMemoryPercentUsed() + "}");
sb.append(",{\"name\":\"System Swap %\",\"value\":" + mon.getSystemSwapPercentUsed() + "}");
sb.append(",{\"name\":\"Number of processors #\",\"value\":" + mon.getNumberOfCPUs() + "}");
sb.append("]}");
......
......@@ -25,8 +25,8 @@ public class TestRunner {
//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");
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);
......