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

feat(cli): addcoder stat command#8005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 48 commits intomainfromcj/coder-stat
Jun 20, 2023
Merged

feat(cli): addcoder stat command#8005

mtojek merged 48 commits intomainfromcj/coder-stat
Jun 20, 2023

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedJun 13, 2023
edited
Loading

Adds acoder stat command that emits resource information about the current workspace host or container.

$ coder statHOST CPU        HOST MEMORY     HOME DISK         CONTAINER CPU   CONTAINER MEMORY  7.5/64.0 cores  246.5/251.4 GB  1225.8/3050.4 GB  0.1/64.0 cores  4.6/15.4 GB   $ coder stat cpu0.7/8.0 cores$ coder stat cpu --host0.1/16.0 cores$ coder stat disk --path $HOME --prefix Ti0.3/0.9 TiB$ coder stat disk --path $HOME 308.3/926.4 GiB

Usage in agent metadata:

  metadata {    display_name = "Host CPU"    interval     = 1    timeout      = 1    key          = "0_host_cpu"    script       = "coder stat cpu --host"  }  metadata {    display_name = "Host Memory"    interval     = 1    timeout      = 1    key          = "1_host_mem"    script       = "coder stat mem --host"  }  metadata {    display_name = "Home Disk"    interval     = 1    timeout      = 1    key          = "2_home_disk"    script       = "coder stat disk --path $${HOME}"  }  metadata {    display_name = "Container CPU"    interval     = 1    timeout      = 1    key          = "3_container_cpu"    script       = "coder stat cpu"  }  metadata {    display_name = "Container Memory"    interval     = 1    timeout      = 1    key          = "4_container_cpu"    script       = "coder stat mem"  }

What this looks like in practice:

image

Also updated docs and sample docker/kubernetes templates with example usage.

Open question: would it make sense to break thestat command into individual sub-commands (coder stat cpu,coder stat container_mem)?

Partially repairsFixes#7076

matifali, ammario, and bpmct reacted with heart emojimatifali reacted with rocket emoji
johnstcnand others added27 commitsJune 13, 2023 17:33
@johnstcnjohnstcn self-assigned thisJun 13, 2023
ammario
ammario previously requested changesJun 14, 2023
Copy link
Member

@ammarioammario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  • In the style of v1, I think we should show percentages alongside the resource values
  • To make room for percentages and reduce noise, I think we should show at most 3 levels of precision

So246.5/251.4 GB would be246 / 251 GB (90%)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Happy that you split a lot of this logic into its own package.

@bpmct
Copy link
Member

This is AWESOME! How doescoder stat work if run on a VM?

@johnstcn
Copy link
MemberAuthor

johnstcn commentedJun 14, 2023
edited
Loading

In the style of v1, I think we should show percentages alongside the resource values
To make room for percentages and reduce noise, I think we should show at most 3 levels of precision
So 246.5/251.4 GB would be 246 / 251 GB (90%)

  1. Isn't that 0 levels of precision?
  2. For quantities that are genenerally in the region of 10^1 - 10^2 (such as cores), such precision isn't really useful. For example,2/8 cores (36%).

I'm in favour of percentages, agree with limiting precision up to a point.

@johnstcn
Copy link
MemberAuthor

This is AWESOME! How doescoder stat work if run on a VM?

There's no difference from its perspective between running in a VM and running on a real piece of metal.

@ammario
Copy link
Member

ammario commentedJun 14, 2023
edited
Loading

2. For quantities that are genenerally in the region of 10^1 - 10^2 (such as cores), such precision isn't really useful. For example,2/8 cores (36%).

Precision may not be the right word, I guess I just mean the number of numbers shown.2.23223 or22.3 would all be fine.

johnstcn reacted with thumbs up emoji

@matifali
Copy link
Member

  1. For quantities that are genenerally in the region of 10^1 - 10^2 (such as cores), such precision isn't really useful. For example,2/8 cores (36%).

Precision may not be the right word, I guess I just mean the number of numbers shown.2.23223 or22.3 would all be fine.

The number of significant figures. I agree with showing 3 at max. for cores that can be limited to 2.

Comment on lines +50 to +56
// If the unit prefixes of the used and total values are different,
// display the used value's prefix to avoid confusion.
if usedPrefix != totalPrefix || totalDisplay == "" {
_, _ = sb.WriteString(" ")
_, _ = sb.WriteString(usedPrefix)
_, _ = sb.WriteString(r.Unit)
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

review: this means you will see output like16.7 mcores/64 cores (0%) or1 B/100 TB (0%). I investigated scaling to use the same units, but this was non-trivial.

@johnstcnjohnstcn requested a review fromammarioJune 15, 2023 15:30
@ammarioammario dismissed theirstale reviewJune 15, 2023 16:10

I don't have enough time today to give the code a good review

@mtojekmtojek self-requested a reviewJune 19, 2023 11:03
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good job!

@bpmct
Copy link
Member

Partially repairs#7076

Is there more to be done after this PR?

@ammarioammario removed their request for reviewJune 19, 2023 19:21
@johnstcn
Copy link
MemberAuthor

Partially repairs#7076

Is there more to be done after this PR?

I was originally intending to update the templates and documentation separately, but eneded up doing it here. So, no.

@mtojek
Copy link
Member

I synced with@johnstcn today. I'm going to merge this PR.

@mtojekmtojek merged commitd6f8bd7 intomainJun 20, 2023
@mtojekmtojek deleted the cj/coder-stat branchJune 20, 2023 09:16
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 20, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@mtojekmtojekmtojek approved these changes

@ammarioammarioammario left review comments

@spikecurtisspikecurtisAwaiting requested review from spikecurtis

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

agent metadata: addcoder stat to identify Kubernetes cgroup usage
6 participants
@johnstcn@matifali@ammario@bpmct@mtojek@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp