Skip to content

Commit 20490a0

Browse files
committed
feat(FR-1611): add more types of agent stats in the agent list page
1 parent 971d534 commit 20490a0

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

react/src/components/AgentList.tsx

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
BAIFlex,
4141
BAIPropertyFilter,
4242
BAIFlexProps,
43+
BAIText,
4344
} from 'backend.ai-ui';
4445
import dayjs from 'dayjs';
4546
import _ from 'lodash';
@@ -478,6 +479,7 @@ const AgentList: React.FC<AgentListProps> = ({
478479
return (
479480
<BAIFlex direction="column" gap="xxs">
480481
<BAIFlex
482+
// CPU
481483
justify="between"
482484
style={{ minWidth: 200, width: '100%' }}
483485
>
@@ -496,6 +498,7 @@ const AgentList: React.FC<AgentListProps> = ({
496498
/>
497499
</BAIFlex>
498500
<BAIFlex
501+
// MEM
499502
justify="between"
500503
style={{ minWidth: 200, width: '100%' }}
501504
>
@@ -519,7 +522,7 @@ const AgentList: React.FC<AgentListProps> = ({
519522
/>
520523
</BAIFlex>
521524
{_.map(_.keys(parsedValue?.node), (statKey) => {
522-
if (['cpu_util', 'mem'].includes(statKey)) {
525+
if (['cpu_util', 'mem', 'disk'].includes(statKey)) {
523526
return;
524527
}
525528
if (_.includes(statKey, '_util')) {
@@ -605,6 +608,72 @@ const AgentList: React.FC<AgentListProps> = ({
605608
</BAIFlex>
606609
);
607610
}
611+
if (_.includes(statKey, '_power')) {
612+
const deviceName =
613+
_.split(statKey, '_').slice(0, -1).join('-') + '.device';
614+
const humanReadableName =
615+
mergedResourceSlots?.[deviceName]?.human_readable_name;
616+
return (
617+
<BAIFlex
618+
key={statKey}
619+
justify="between"
620+
style={{ minWidth: 200, width: '100%' }}
621+
gap="xxs"
622+
>
623+
<BAIText>{`${humanReadableName}(power)`}</BAIText>
624+
<BAIText>{`${toFixedFloorWithoutTrailingZeros(parsedValue.node[statKey]?.current, 2)} ${parsedValue.node[statKey].unit_hint}`}</BAIText>
625+
</BAIFlex>
626+
);
627+
}
628+
if (_.includes(statKey, '_temperature')) {
629+
const deviceName =
630+
_.split(statKey, '_').slice(0, -1).join('_') + '.device';
631+
const humanReadableName =
632+
mergedResourceSlots?.[deviceName]?.human_readable_name;
633+
return (
634+
<BAIFlex
635+
key={statKey}
636+
justify="between"
637+
style={{ minWidth: 200, width: '100%' }}
638+
gap="xxs"
639+
>
640+
<BAIText>{`${humanReadableName}(temp)`}</BAIText>
641+
<BAIText>{`${toFixedFloorWithoutTrailingZeros(parsedValue.node[statKey]?.current, 2)} °C`}</BAIText>
642+
</BAIFlex>
643+
);
644+
}
645+
if (_.includes(['net_rx', 'net_tx'], statKey)) {
646+
const convertedValue = convertToDecimalUnit(
647+
parsedValue.node[statKey]?.current,
648+
'auto',
649+
);
650+
return (
651+
<BAIFlex
652+
key={statKey}
653+
justify="between"
654+
style={{ minWidth: 200, width: '100%' }}
655+
gap="xxs"
656+
>
657+
<BAIText>
658+
{statKey === 'net_rx' ? 'Net Rx' : 'Net Tx'}
659+
</BAIText>
660+
<BAIText>
661+
{`${convertedValue?.numberFixed ?? 0} ${convertedValue?.unit.toUpperCase() ?? ''}bps`}
662+
</BAIText>
663+
</BAIFlex>
664+
);
665+
}
666+
return (
667+
<BAIFlex
668+
key={statKey}
669+
justify="between"
670+
style={{ minWidth: 200, width: '100%' }}
671+
gap="xxs"
672+
>
673+
<BAIText>{statKey}</BAIText>
674+
<BAIText>{`${toFixedFloorWithoutTrailingZeros(parsedValue.node[statKey]?.current ?? 0, 2)}${parsedValue.node[statKey]?.unit_hint ? ` ${parsedValue.node[statKey].unit_hint}` : ''}`}</BAIText>
675+
</BAIFlex>
676+
);
608677
})}
609678
</BAIFlex>
610679
);

0 commit comments

Comments
 (0)