mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Display CPU usage percentage with 2 decimal points (#2000)
Signed-off-by: Alex Culliere <alozhkin@mirantis.com>
This commit is contained in:
parent
f8c111ddd8
commit
9da349ce42
@ -51,6 +51,10 @@ export class Nodes extends React.Component<Props> {
|
|||||||
if (!metrics || !metrics[1]) return <LineProgress value={0}/>;
|
if (!metrics || !metrics[1]) return <LineProgress value={0}/>;
|
||||||
const usage = metrics[0];
|
const usage = metrics[0];
|
||||||
const cores = metrics[1];
|
const cores = metrics[1];
|
||||||
|
const cpuUsagePercent = Math.ceil(usage * 100) / cores;
|
||||||
|
const cpuUsagePercentLabel: String = cpuUsagePercent % 1 === 0
|
||||||
|
? cpuUsagePercent.toString()
|
||||||
|
: cpuUsagePercent.toFixed(2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LineProgress
|
<LineProgress
|
||||||
@ -58,7 +62,7 @@ export class Nodes extends React.Component<Props> {
|
|||||||
value={usage}
|
value={usage}
|
||||||
tooltip={{
|
tooltip={{
|
||||||
preferredPositions: TooltipPosition.BOTTOM,
|
preferredPositions: TooltipPosition.BOTTOM,
|
||||||
children: `CPU: ${Math.ceil(usage * 100) / cores}\%, cores: ${cores}`
|
children: `CPU: ${cpuUsagePercentLabel}\%, cores: ${cores}`
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user