Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit f5c42ae

Browse files
committed
Remove resource top utilization metrics
1 parent b415d3a commit f5c42ae

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

internal/cmd/resourcemanager.go

+28-3
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ func printResourceTop(writer io.Writer, groups []groupable, labeler envLabeler)
141141

142142
var userResources []aggregatedResources
143143
for _, group := range groups {
144-
// truncate user names to ensure tabwriter doesn't push our entire table too far
145-
userResources = append(userResources, aggregatedResources{groupable: group, resources: aggregateEnvResources(group.environments())})
144+
userResources = append(
145+
userResources,
146+
aggregatedResources{groupable: group, resources: aggregateEnvResources(group.environments())},
147+
)
146148
}
147149
sort.Slice(userResources, func(i, j int) bool {
148150
return userResources[i].cpuAllocation > userResources[j].cpuAllocation
@@ -220,7 +222,30 @@ type resources struct {
220222
}
221223

222224
func (a resources) String() string {
223-
return fmt.Sprintf("[cpu: alloc=%.1fvCPU, util=%.1f]\t[mem: alloc=%.1fGB, util=%.1f]", a.cpuAllocation, a.cpuUtilization, a.memAllocation, a.memUtilization)
225+
return fmt.Sprintf(
226+
"[cpu: alloc=%.1fvCPU]\t[mem: alloc=%.1fGB]",
227+
a.cpuAllocation, a.memAllocation,
228+
)
229+
230+
// TODO@cmoog: consider adding the utilization info once a historical average is considered or implemented
231+
// return fmt.Sprintf(
232+
// "[cpu: alloc=%.1fvCPU, util=%s]\t[mem: alloc=%.1fGB, util=%s]",
233+
// a.cpuAllocation, a.cpuUtilPercentage(), a.memAllocation, a.memUtilPercentage(),
234+
// )
235+
}
236+
237+
func (a resources) cpuUtilPercentage() string {
238+
if a.cpuAllocation == 0 {
239+
return "N/A"
240+
}
241+
return fmt.Sprintf("%.1f%%", a.cpuUtilization / a.cpuAllocation * 100)
242+
}
243+
244+
func (a resources) memUtilPercentage() string {
245+
if a.memAllocation == 0 {
246+
return "N/A"
247+
}
248+
return fmt.Sprintf("%.1f%%", a.memUtilization / a.memAllocation * 100)
224249
}
225250

226251
// truncate the given string and replace the removed chars with some replacement (ex: "...")

0 commit comments

Comments
 (0)