mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-18 18:49:50 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -12,7 +12,7 @@ export default function Component({ service }) {
|
|||
const { widget } = service;
|
||||
|
||||
const { data: statusData, error: statusError } = useSWR(
|
||||
`api/docker/status/${widget.container}/${widget.server || ""}`
|
||||
`api/docker/status/${widget.container}/${widget.server || ""}`,
|
||||
);
|
||||
|
||||
const { data: statsData, error: statsError } = useSWR(`api/docker/stats/${widget.container}/${widget.server || ""}`);
|
||||
|
@ -46,9 +46,9 @@ export default function Component({ service }) {
|
|||
return (
|
||||
<Container service={service}>
|
||||
<Block label="docker.cpu" value={t("common.percent", { value: calculateCPUPercent(statsData.stats) })} />
|
||||
{statsData.stats.memory_stats.usage &&
|
||||
{statsData.stats.memory_stats.usage && (
|
||||
<Block label="docker.mem" value={t("common.bytes", { value: calculateUsedMemory(statsData.stats) })} />
|
||||
}
|
||||
)}
|
||||
{network && (
|
||||
<>
|
||||
<Block label="docker.rx" value={t("common.bytes", { value: network.rx_bytes })} />
|
||||
|
|
|
@ -12,5 +12,7 @@ export function calculateCPUPercent(stats) {
|
|||
|
||||
export function calculateUsedMemory(stats) {
|
||||
// see https://github.com/docker/cli/blob/dcc161076861177b5eef6cb321722520db3184e7/cli/command/container/stats_helpers.go#L239
|
||||
return stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats.inactive_file ?? 0)
|
||||
}
|
||||
return (
|
||||
stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats.inactive_file ?? 0)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue