| 1 |
<!-- |
| 2 |
~ Copyright 2009-2013 Roland Huss |
| 3 |
~ |
| 4 |
~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
~ you may not use this file except in compliance with the License. |
| 6 |
~ You may obtain a copy of the License at |
| 7 |
~ |
| 8 |
~ http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
~ |
| 10 |
~ Unless required by applicable law or agreed to in writing, software |
| 11 |
~ distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
~ See the License for the specific language governing permissions and |
| 14 |
~ limitations under the License. |
| 15 |
--> |
| 16 |
|
| 17 |
<html> |
| 18 |
<head> |
| 19 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 20 |
<title>Jolokia plot demo</title> |
| 21 |
<script type="text/javascript" src="../scripts/jquery-1.7.1.js"></script> |
| 22 |
<script type="text/javascript" src="../scripts/support/jquery.flot.js"></script> |
| 23 |
<script type="text/javascript" src="../scripts/lib/jolokia.js"></script> |
| 24 |
<script type="text/javascript" src="../scripts/lib/jolokia-simple.js"></script> |
| 25 |
<script type="text/javascript" src="../scripts/lib/json2.js"></script> |
| 26 |
</head> |
| 27 |
<body> |
| 28 |
<h1>Jolokia Memory Plot Demo</h1> |
| 29 |
|
| 30 |
<div id="memory" style="width:600px;height:300px;margin-top: 20px;"></div> |
| 31 |
<input type="submit" id="gc" value="Garbage Collection"/> |
| 32 |
|
| 33 |
<script id="source" language="javascript" type="text/javascript"> |
| 34 |
|
| 35 |
var j4p = new Jolokia("/jolokia"); |
| 36 |
var data = []; |
| 37 |
|
| 38 |
function run() { |
| 39 |
j4p.request({ |
| 40 |
type: "read", |
| 41 |
mbean: "java.lang:type=Memory", |
| 42 |
attribute: "HeapMemoryUsage" |
| 43 |
}, |
| 44 |
{ |
| 45 |
success: function(resp) { |
| 46 |
var value = resp.value.used / (1024 * 1024); |
| 47 |
var time = resp.timestamp * 1000; |
| 48 |
data.push([time, value]); |
| 49 |
$.plot($("#memory"),[data], |
| 50 |
{ |
| 51 |
xaxis: { mode: "time" }, |
| 52 |
grid: { backgroundColor: { colors: ["#fff", "#eee"] }} |
| 53 |
}); |
| 54 |
setTimeout(run,1000); |
| 55 |
} |
| 56 |
}); |
| 57 |
|
| 58 |
} |
| 59 |
$("#gc").click(function() { |
| 60 |
j4p.execute("java.lang:type=Memory","gc", { |
| 61 |
success: function() { |
| 62 |
console.log("Garbage collection performed"); |
| 63 |
} |
| 64 |
}); |
| 65 |
}); |
| 66 |
run(); |
| 67 |
</script> |
| 68 |
</body> |
| 69 |
|
| 70 |
</html> |