mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 13:09:31 +01:00
Fix: Lint docker stats throughput PR
This commit is contained in:
parent
7f50f6cfaa
commit
6316de6fa6
@ -41,7 +41,7 @@ export default function Component({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rx_bytes, tx_bytes } = calculateThroughput(statsData.stats);
|
const { rxBytes, txBytes } = calculateThroughput(statsData.stats);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
@ -51,8 +51,8 @@ export default function Component({ service }) {
|
|||||||
)}
|
)}
|
||||||
{statsData.stats.networks && (
|
{statsData.stats.networks && (
|
||||||
<>
|
<>
|
||||||
<Block label="docker.rx" value={t("common.bytes", { value: rx_bytes })} />
|
<Block label="docker.rx" value={t("common.bytes", { value: rxBytes })} />
|
||||||
<Block label="docker.tx" value={t("common.bytes", { value: tx_bytes })} />
|
<Block label="docker.tx" value={t("common.bytes", { value: txBytes })} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -18,16 +18,16 @@ export function calculateUsedMemory(stats) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function calculateThroughput(stats) {
|
export function calculateThroughput(stats) {
|
||||||
let rx_bytes = 0;
|
let rxBytes = 0;
|
||||||
let tx_bytes = 0;
|
let txBytes = 0;
|
||||||
if (stats.networks?.network) {
|
if (stats.networks?.network) {
|
||||||
rx_bytes = stats.networks?.network.rx_bytes;
|
rxBytes = stats.networks?.network.rx_bytes;
|
||||||
tx_bytes = stats.networks?.network.tx_bytes;
|
txBytes = stats.networks?.network.tx_bytes;
|
||||||
} else if (stats.networks && Array.isArray(Object.values(stats.networks))) {
|
} else if (stats.networks && Array.isArray(Object.values(stats.networks))) {
|
||||||
Object.values(stats.networks).forEach((containerInterface) => {
|
Object.values(stats.networks).forEach((containerInterface) => {
|
||||||
rx_bytes += containerInterface.rx_bytes;
|
rxBytes += containerInterface.rx_bytes;
|
||||||
tx_bytes += containerInterface.tx_bytes;
|
txBytes += containerInterface.tx_bytes;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return { rx_bytes, tx_bytes };
|
return { rxBytes, txBytes };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user