-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Gitpod CLI] New command gp top
- Display workspace used/available resources
#10570
Conversation
b912569
to
4bb1cb6
Compare
gp top
- Display workspace used/available resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold
if you want to make any small adjustments, otherwise it looks good
4bb1cb6
to
a8894de
Compare
4f177ff
to
c48cf02
Compare
c48cf02
to
6c7ee0a
Compare
6c7ee0a
to
6ed34a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @andreafalzetti 🚀!
I just have two questions:
- Would it be a common use case for users to run this with
watch
? Maybe we could add a way to run continuously to behave more liketop
? - Is there a way to consume the info via other means? Can I use these values in my app somehow? I would like to for instance output JSON so it can be consumed by tools like https://github.com/akosyakov/gitpod-monitor (still the best VS Code extension there is).
These are good points, I've also mentioned them in this PR - see: 1 and 2 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good points, I've also mentioned them in this PR - see: #10570 (comment) and #10570 (comment) :)
Thanks for the pointers, @andreafalzetti, I have tried the command and it LGTM ✅.
6ed34a6
to
0ef012a
Compare
Thanks @akosyakov and @filiptronicek There was a typo in the OSS header (2020 -> 2022). Fixed and pushed. Waiting for the build to finish and it will be merged 🙏 /unhold |
Description
Introducing a new command for gitpod-cli:
$ gp top
Command line interface for Gitpod Usage: gp [command] Available Commands: ... top Display workspace resource (CPU/Memory usage)
This command similarly to
gp ports list
andgp tasks list
use colors. It's a best practice for CLI tools to be accessible and allow disabling colors in certain circumstances.I've followd this approach, which seems to be very common and community sanctioned:
I've enclosed this logic in a utility so that, if we like it, we can re-use it also for the other commands.
Without disabling colors, running
watch gp top
it would display the following:By detecting if the CLI is being used without any wrapper or being piped into a command, it disables the colors and it looks good:
Related Issue(s)
Fixes #9521
How to test
gp top
, observe the cpu/memory usagegp top --no-color
Optionally, to test the colors based on usage:
4. To stress the CPU, run:
yes > /dev/null &
multiple times5. Run
gp top
again and obsere the CPU usage6. To get the CPU back to a lower value, run:
killall yes
7. To stress the Memory, run
cat /dev/zero | head -c 5G | tail
once or twiceIn prev env, it easily hangs before you can actually test
gp top
for this, I've also attached some screenshots taken from my dev branch in gitpod.io.Release Notes
Documentation
https://github.com/gitpod-io/website/pull/2207