Skip to content

Commit

Permalink
Calculate memoryIO using dockerAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
vermakhushboo committed Jun 8, 2024
1 parent 45416cb commit f980c73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Orchestration/Adapter/DockerAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public function getStats(string $container = null, array $filters = []): array
cpuUsage: $cpuUsage,
memoryUsage: $memoryUsage,
diskIO: ['in' => $read_bytes, 'out' => $write_bytes],
memoryIO: ['in' => 0, 'out' => 0], // TODO: Implement (API does not provide these values
memoryIO: ['in' => $stats['memory_stats']['usage'], 'out' => $stats['memory_stats']['limit']],
networkIO: ['in' => $networkIn, 'out' => $networkOut],
);
}
Expand Down
21 changes: 11 additions & 10 deletions src/Orchestration/Adapter/DockerCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,18 @@ public function getStats(string $container = null, array $filters = []): array
*/
private function parseIOStats(string $stats)
{
$stats = strtolower($stats);
$units = [
'B' => 1,
'kB' => 1000,
'MB' => 1000000,
'GB' => 1000000000,
'TB' => 1000000000000,

'kiB' => 1000,
'MiB' => 1000000,
'GiB' => 1000000000,
'TiB' => 1000000000000,
'b' => 1,
'kb' => 1000,
'mb' => 1000000,
'gb' => 1000000000,
'tb' => 1000000000000,

'kib' => 1000,
'mib' => 1000000,
'gib' => 1000000000,
'tib' => 1000000000000,
];

[ $inStr, $outStr ] = \explode(' / ', $stats);
Expand Down

0 comments on commit f980c73

Please sign in to comment.