Commit 39afa3b8 by Johannes Edmeier

Fix memory units for dorpwizard metrics-jvm

In case dropwizard is used the heap metrics are in bytes and not in kilobytes. This is deteceted by the presence of heap.max. For Spring Boot 2.0 there is an issue filed to deliver bytes see spring-projects/spring-boot#6413 fixes #234
parent 911f8e83
......@@ -26,7 +26,8 @@ module.exports = {
ctrl.$onChanges = function () {
ctrl.memory = {
total: ctrl.metrics.mem,
used: ctrl.metrics.mem - ctrl.metrics['mem.free']
used: ctrl.metrics.mem - ctrl.metrics['mem.free'],
unit: 'K'
};
ctrl.memory.percentUsed = $filter('number')(ctrl.memory.used / ctrl.memory.total * 100, 2);
......@@ -34,7 +35,8 @@ module.exports = {
total: ctrl.metrics['heap.committed'],
used: ctrl.metrics['heap.used'],
init: ctrl.metrics['heap.init'],
max: ctrl.metrics.heap
max: ctrl.metrics['heap.max'] || ctrl.metrics.heap,
unit: ctrl.metrics['heap.max'] ? 'B' : 'K'
};
ctrl.heap.percentUsed = $filter('number')(ctrl.heap.used / ctrl.heap.total * 100, 2);
......@@ -42,7 +44,8 @@ module.exports = {
total: ctrl.metrics['nonheap.committed'],
used: ctrl.metrics['nonheap.used'],
init: ctrl.metrics['nonheap.init'],
max: ctrl.metrics.nonheap
max: ctrl.metrics.nonheap,
unit: 'K'
};
ctrl.nonheap.percentUsed = $filter('number')(ctrl.nonheap.used / ctrl.nonheap.total * 100, 2);
};
......
<table class="table">
<tr>
<td colspan="2"> <span>Memory ({{ $ctrl.memory.used | humanBytes:'K' }} / {{ $ctrl.memory.total | humanBytes:'K' }})</span>
<td colspan="2"> <span>Memory ({{ $ctrl.memory.used | humanBytes:$ctrl.memory.unit }} / {{ $ctrl.memory.total | humanBytes:$ctrl.memory.unit }})</span>
<div class="progress" style="margin-bottom: 0px;">
<div class="bar" ng-class="$ctrl.getBarClass($ctrl.memory.percentUsed)" style="width: {{$ctrl.memory.percentUsed}}%;">{{$ctrl.memory.percentUsed}}%</div>
</div>
</td>
</tr>
<tr>
<td colspan="2"> <span>Heap Memory ({{ $ctrl.heap.used | humanBytes:'K' }} / {{ $ctrl.heap.total | humanBytes:'K' }})</span>
<td colspan="2"> <span>Heap Memory ({{ $ctrl.heap.used | humanBytes:$ctrl.heap.unit }} / {{ $ctrl.heap.total | humanBytes:$ctrl.heap.unit }})</span>
<div class="progress" style="margin-bottom: 0px;">
<div class="bar" ng-class="$ctrl.getBarClass($ctrl.heap.percentUsed)" style="width: {{$ctrl.heap.percentUsed}}%;">{{$ctrl.heap.percentUsed}}%</div>
</div>
......@@ -15,14 +15,14 @@
</tr>
<tr>
<td>Initial Heap (-Xms)</td>
<td>{{$ctrl.heap.init | humanBytes:'K' }}</td>
<td>{{$ctrl.heap.init | humanBytes:$ctrl.heap.unit }}</td>
</tr>
<tr>
<td>Maximum Heap (-Xmx)</td>
<td>{{$ctrl.heap.max | humanBytes:'K' }}</td>
<td>{{$ctrl.heap.max | humanBytes:$ctrl.heap.unit }}</td>
</tr>
<tr>
<td colspan="2"> <span>Non-Heap Memory ({{ $ctrl.nonheap.used | humanBytes:'K' }} / {{ $ctrl.nonheap.total | humanBytes:'K' }})</span>
<td colspan="2"> <span>Non-Heap Memory ({{ $ctrl.nonheap.used | humanBytes:$ctrl.nonheap.unit }} / {{ $ctrl.nonheap.total | humanBytes:$ctrl.nonheap.unit }})</span>
<div class="progress" style="margin-bottom: 0px;">
<div class="bar" ng-class="$ctrl.getBarClass($ctrl.nonheap.percentUsed)" style="width: {{$ctrl.nonheap.percentUsed}}%;">{{$ctrl.nonheap.percentUsed}}%</div>
</div>
......@@ -30,11 +30,11 @@
</tr>
<tr>
<td>Initial Non-Heap</td>
<td>{{$ctrl.nonheap.init | humanBytes:'K' }}</td>
<td>{{$ctrl.nonheap.init | humanBytes:$ctrl.nonheap.unit }}</td>
</tr>
<tr>
<td>Maximum Non-Heap</td>
<td ng-show="$ctrl.nonheap.max > 0">{{$ctrl.nonheap.max | humanBytes:'K' }}</td>
<td ng-show="$ctrl.nonheap.max > 0">{{$ctrl.nonheap.max | humanBytes:$ctrl.nonheap.unit }}</td>
<td ng-show="$ctrl.nonheap.max <= 0">unbounded</td>
</tr>
</table>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment