Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit1a1b6e3

Browse files
committed
Remove resource top utilization metrics
1 parenteff753a commit1a1b6e3

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

‎internal/cmd/resourcemanager.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
funcmakeResourceCmd()*cobra.Command {
1616
cmd:=&cobra.Command{
1717
Use:"resources",
18-
Short:"manager Coder resources with platform-level context (users, organizations, environments)",
18+
Short:"manage Coder resources with platform-level context (users, organizations, environments)",
1919
Hidden:true,
2020
}
2121
cmd.AddCommand(resourceTop())
@@ -141,8 +141,10 @@ func printResourceTop(writer io.Writer, groups []groupable, labeler envLabeler)
141141

142142
varuserResources []aggregatedResources
143143
for_,group:=rangegroups {
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,jint)bool {
148150
returnuserResources[i].cpuAllocation>userResources[j].cpuAllocation
@@ -220,7 +222,30 @@ type resources struct {
220222
}
221223

222224
func (aresources)String()string {
223-
returnfmt.Sprintf("[cpu: alloc=%.1fvCPU, util=%.1f]\t[mem: alloc=%.1fGB, util=%.1f]",a.cpuAllocation,a.cpuUtilization,a.memAllocation,a.memUtilization)
225+
returnfmt.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 (aresources)cpuUtilPercentage()string {
238+
ifa.cpuAllocation==0 {
239+
return"N/A"
240+
}
241+
returnfmt.Sprintf("%.1f%%",a.cpuUtilization/a.cpuAllocation*100)
242+
}
243+
244+
func (aresources)memUtilPercentage()string {
245+
ifa.memAllocation==0 {
246+
return"N/A"
247+
}
248+
returnfmt.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)

[8]ページ先頭

©2009-2025 Movatter.jp