1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

#446 fix(container-stats): fix issue in stats view with empty network data (#502)

This commit is contained in:
lpfeup 2017-01-21 05:01:32 +00:00 committed by Anthony Lapenna
parent 3a6e9d2fbe
commit 7d78871eee

View file

@ -162,6 +162,7 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
$scope.networkName = Object.keys(data.networks)[0]; $scope.networkName = Object.keys(data.networks)[0];
data.network = data.networks[$scope.networkName]; data.network = data.networks[$scope.networkName];
} }
if(data.network) {
var rxBytes = 0, txBytes = 0; var rxBytes = 0, txBytes = 0;
if (lastRxBytes !== 0 || lastTxBytes !== 0) { if (lastRxBytes !== 0 || lastTxBytes !== 0) {
// These will be zero on first call, ignore to prevent large graph spike // These will be zero on first call, ignore to prevent large graph spike
@ -173,6 +174,7 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
networkChart.addData([rxBytes, txBytes], new Date(data.read).toLocaleTimeString()); networkChart.addData([rxBytes, txBytes], new Date(data.read).toLocaleTimeString());
networkChart.removeData(); networkChart.removeData();
} }
}
function calculateCPUPercent(stats) { function calculateCPUPercent(stats) {
// Same algorithm the official client uses: https://github.com/docker/docker/blob/master/api/client/stats.go#L195-L208 // Same algorithm the official client uses: https://github.com/docker/docker/blob/master/api/client/stats.go#L195-L208