@@ -141,8 +141,10 @@ func printResourceTop(writer io.Writer, groups []groupable, labeler envLabeler)
141
141
142
142
var userResources []aggregatedResources
143
143
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
+ )
146
148
}
147
149
sort .Slice (userResources , func (i , j int ) bool {
148
150
return userResources [i ].cpuAllocation > userResources [j ].cpuAllocation
@@ -220,7 +222,30 @@ type resources struct {
220
222
}
221
223
222
224
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 )
224
249
}
225
250
226
251
// truncate the given string and replace the removed chars with some replacement (ex: "...")
0 commit comments