mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Fix: sum throughput data for docker stats (#2334)
This commit is contained in:
@@ -16,3 +16,18 @@ export function calculateUsedMemory(stats) {
|
||||
stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats?.inactive_file ?? 0)
|
||||
);
|
||||
}
|
||||
|
||||
export function calculateThroughput(stats) {
|
||||
let rx_bytes = 0;
|
||||
let tx_bytes = 0;
|
||||
if (stats.networks?.network) {
|
||||
rx_bytes = stats.networks?.network.rx_bytes;
|
||||
tx_bytes = stats.networks?.network.tx_bytes;
|
||||
} else if (stats.networks && Array.isArray(Object.values(stats.networks))) {
|
||||
Object.values(stats.networks).forEach((containerInterface) => {
|
||||
rx_bytes += containerInterface.rx_bytes;
|
||||
tx_bytes += containerInterface.tx_bytes;
|
||||
});
|
||||
}
|
||||
return { rx_bytes, tx_bytes };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user