mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
fix(container-stat): fix cpu/mem charts on Windows containers
* Fixing the CPU and Memory charts on Windows containers * Fixing the CPU and Memory charts on Windows containers
This commit is contained in:
parent
55b50c2a49
commit
309620545c
3 changed files with 42 additions and 17 deletions
|
@ -23,21 +23,21 @@ function ($q, $scope, $transition$, $document, $interval, ContainerService, Char
|
|||
if (stats.Networks.length > 0) {
|
||||
var rx = stats.Networks[0].rx_bytes;
|
||||
var tx = stats.Networks[0].tx_bytes;
|
||||
var label = moment(stats.Date).format('HH:mm:ss');
|
||||
var label = moment(stats.read).format('HH:mm:ss');
|
||||
|
||||
ChartService.UpdateNetworkChart(label, rx, tx, chart);
|
||||
}
|
||||
}
|
||||
|
||||
function updateMemoryChart(stats, chart) {
|
||||
var label = moment(stats.Date).format('HH:mm:ss');
|
||||
var label = moment(stats.read).format('HH:mm:ss');
|
||||
|
||||
ChartService.UpdateMemoryChart(label, stats.MemoryUsage, stats.MemoryCache, chart);
|
||||
}
|
||||
|
||||
function updateCPUChart(stats, chart) {
|
||||
var label = moment(stats.Date).format('HH:mm:ss');
|
||||
var value = calculateCPUPercentUnix(stats);
|
||||
var label = moment(stats.read).format('HH:mm:ss');
|
||||
var value = stats.isWindows ? calculateCPUPercentWindows(stats) : calculateCPUPercentUnix(stats);
|
||||
|
||||
ChartService.UpdateCPUChart(label, value, chart);
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ function ($q, $scope, $transition$, $document, $interval, ContainerService, Char
|
|||
return cpuPercent;
|
||||
}
|
||||
|
||||
function calculateCPUPercentWindows(stats) {
|
||||
var possIntervals = stats.NumProcs * parseFloat(
|
||||
moment(stats.read, 'YYYY-MM-DDTHH:mm:ss.SSSSSSSSSZ').valueOf() - moment(stats.preread, 'YYYY-MM-DDTHH:mm:ss.SSSSSSSSSZ').valueOf());
|
||||
var windowsCpuUsage = 0.0;
|
||||
if(possIntervals > 0) {
|
||||
windowsCpuUsage = parseFloat(stats.CurrentCPUTotalUsage - stats.PreviousCPUTotalUsage) / parseFloat(possIntervals * 100);
|
||||
}
|
||||
return windowsCpuUsage;
|
||||
}
|
||||
|
||||
|
||||
$scope.changeUpdateRepeater = function() {
|
||||
var networkChart = $scope.networkChart;
|
||||
var cpuChart = $scope.cpuChart;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue