-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show cpu and disk usage in instance list. distinguish memory cached a…
…nd used (#1075) ## Done - Show memory and disk usage in instance list - Distinguish memory cached and used Fixes #928 #1062 ## QA 1. Run the LXD-UI: - On the demo server via the link posted by @webteam-app below. This is only available for PRs created by collaborators of the repo. Ask @mas-who or @edlerd for access. - With a local copy of this branch, [build and run as described in the docs](../CONTRIBUTING.md#setting-up-for-development). 2. Perform the following QA steps: - check instance list, enable disk and memory columns - check instance detail page with metrics
- Loading branch information
Showing
8 changed files
with
189 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { FC } from "react"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { queryKeys } from "util/queryKeys"; | ||
import { fetchMetrics } from "api/metrics"; | ||
import { humanFileSize } from "util/helpers"; | ||
import { getInstanceMetrics } from "util/metricSelectors"; | ||
import Meter from "components/Meter"; | ||
import type { LxdInstance } from "types/instance"; | ||
import { useAuth } from "context/auth"; | ||
|
||
interface Props { | ||
instance: LxdInstance; | ||
} | ||
|
||
const InstanceUsageDisk: FC<Props> = ({ instance }) => { | ||
const { isRestricted } = useAuth(); | ||
|
||
const { data: metrics = [] } = useQuery({ | ||
queryKey: [queryKeys.metrics], | ||
queryFn: fetchMetrics, | ||
refetchInterval: 15 * 1000, // 15 seconds | ||
enabled: !isRestricted, | ||
}); | ||
|
||
const instanceMetrics = getInstanceMetrics(metrics, instance); | ||
|
||
return instanceMetrics.disk ? ( | ||
<div> | ||
<Meter | ||
percentage={ | ||
(100 / instanceMetrics.disk.total) * | ||
(instanceMetrics.disk.total - instanceMetrics.disk.free) | ||
} | ||
text={ | ||
humanFileSize( | ||
instanceMetrics.disk.total - instanceMetrics.disk.free, | ||
) + | ||
" of " + | ||
humanFileSize(instanceMetrics.disk.total) | ||
} | ||
/> | ||
</div> | ||
) : ( | ||
"" | ||
); | ||
}; | ||
|
||
export default InstanceUsageDisk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { FC } from "react"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { queryKeys } from "util/queryKeys"; | ||
import { fetchMetrics } from "api/metrics"; | ||
import { humanFileSize } from "util/helpers"; | ||
import { getInstanceMetrics } from "util/metricSelectors"; | ||
import Meter from "components/Meter"; | ||
import type { LxdInstance } from "types/instance"; | ||
import { useAuth } from "context/auth"; | ||
|
||
interface Props { | ||
instance: LxdInstance; | ||
} | ||
|
||
const InstanceUsageMemory: FC<Props> = ({ instance }) => { | ||
const { isRestricted } = useAuth(); | ||
|
||
const { data: metrics = [] } = useQuery({ | ||
queryKey: [queryKeys.metrics], | ||
queryFn: fetchMetrics, | ||
refetchInterval: 15 * 1000, // 15 seconds | ||
enabled: !isRestricted, | ||
}); | ||
|
||
const instanceMetrics = getInstanceMetrics(metrics, instance); | ||
|
||
return instanceMetrics.memory ? ( | ||
<div> | ||
<Meter | ||
percentage={ | ||
(100 / instanceMetrics.memory.total) * | ||
(instanceMetrics.memory.total - | ||
instanceMetrics.memory.free - | ||
instanceMetrics.memory.cached) | ||
} | ||
secondaryPercentage={ | ||
(100 / instanceMetrics.memory.total) * instanceMetrics.memory.cached | ||
} | ||
text={ | ||
humanFileSize( | ||
instanceMetrics.memory.total - instanceMetrics.memory.free, | ||
) + | ||
" of " + | ||
humanFileSize(instanceMetrics.memory.total) | ||
} | ||
/> | ||
</div> | ||
) : ( | ||
"" | ||
); | ||
}; | ||
|
||
export default InstanceUsageMemory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters