Project

General

Profile

Download (1.45 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
$(document).ready(function(){
3

    
4
  function updateMemoryStatus() {
5
     $.getJSON(
6
        "MemoryService.jsp",
7
        function(data){
8
          $("#status").html(''); // make empty
9
          $("#status").html('<div>CPU Cores: ' + data.availableProcessors + '</div>'); // make empty
10
          $("#status").append(memoryUsageEntry(data.heapMemoryUsage, data.recommendedMinimumHeap, "HeapUsage", "100%", "#F48B65", "#65B1F4"));
11
          $("#status").append(memoryUsageEntry(data.permGenSpaceUsage, data.recommendedMinimumPermGenSpace, "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4"));
12
     }); // end JSON
13

    
14

    
15
    setTimeout(function(){
16
        updateMemoryStatus()
17
        }, 1000);
18

    
19
  } // end updateMemory
20

    
21
  function memoryUsageEntry(memoryUsage, recommended, label, barWidth, cssColorUsed, cssColorMax){
22
    var mb = 1024 * 1024;
23
    var gb = mb * 1024;
24
    var max = memoryUsage.max / mb;
25
    var used = memoryUsage.used / mb;
26
    var percent = used * 100 / max;
27
    var recommendedMB = recommended / mb;
28
    var html = '';
29

    
30
    html += '<span class="memory-usage">';
31
    html += label + '(' + used + ' of '  + max+ ' MB, recommended: '  + recommendedMB + ' MB)&nbsp;';
32
    html += '<div style="height: 100%; width:' + barWidth + ';background-color:' + cssColorMax + '">';
33
    html += '<div style="background-color:' + cssColorUsed + '; width:' + percent + '%">&nbsp;</div></div></span>';
34

    
35
    return html;
36
  }
37

    
38
  updateMemoryStatus()
39

    
40
});
(4-4/6)