-
Notifications
You must be signed in to change notification settings - Fork 316
Description
Checklist
- I've looked through the documentation and existing open issues for similar feature requests.
Describe the feature request
Hello,
First, I'd like to say thank you for creating bottom. It's an excellent and highly useful tool.
Problem Description
When running bottom inside a standard Docker container on my own host, it displays the host's total resources (CPU cores, Memory) instead of the limits allocated to the container via cgroup.
This makes the overall resource usage percentages misleading. For example, a container running at 100% of its CPU quota might only show a small fraction of usage relative to the host's total cores, which doesn't accurately reflect the resource pressure within the container.
Steps to Reproduce
-
On a Linux host, run a new Docker container with specific resource limits. The
debian:12image is used here to match my environment.# Launch a container limited to 2 CPU cores and 2GB of memory docker run --rm -it --cpus="2" --memory="2g" debian:12 /bin/bash
-
Inside the container, download
bottomand make it executable.# Install wget first apt update && apt install -y wget # Download bottom (static musl build is great for containers) wget https://github.com/ClementTsang/bottom/releases/download/0.10.2/bottom_x86_64-unknown-linux-musl.tar.gz # Extract and run tar -xzvf bottom_x86_64-unknown-linux-musl.tar.gz chmod +x btm ./btm
Actual Behavior
bottom displays the total resources of the host machine. For instance, it might show 16 cores and 64GB of RAM, ignoring the cpus="2" and memory="2g" limits.
Expected Behavior
bottom should detect it's running within a cgroup-limited environment and display the container's allocated resources as the total. In the example above, it should show:
- Total CPU cores: 2
- Total Memory: 2 GB
This would make the usage percentages meaningful within the container's context.
Environment
- Bottom Version:
0.10.2 - Operating System (inside container):
Linux fc67602e-2644-4ef6-bc44-81c87d67e86b 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux - Context: Running inside a Docker container on a self-managed host.
Thank you for your time and for considering this feature request. It would greatly improve the user experience for developers and sysadmins working with containers.
------------- this is a line for spliting -----------------
您好,
首先,我想感谢您创建了 bottom,这是一款非常出色且非常有用的工具。
问题描述
当我在我自己的宿主机上,在一个标准的 Docker 容器内部运行 bottom 时,它显示的是宿主机的总资源(CPU核心数、内存),而不是通过 cgroup 分配给该容器的资源限制。
这导致总资源使用率的百分比数据具有误导性。例如,一个正在以其 100% CPU 配额运行的容器,相对于宿主机的总核心数可能只显示了很小的使用率,这无法准确反映容器内部的资源压力。
复现步骤
-
在一台 Linux 宿主机上,使用指定的资源限制运行一个新的 Docker 容器。这里使用
debian:12镜像以匹配我的环境。# 启动一个被限制为 2 CPU 核心和 2GB 内存的容器 docker run --rm -it --cpus="2" --memory="2g" debian:12 /bin/bash
-
在容器内部,下载
bottom并赋予其执行权限。# 首先安装 wget apt update && apt install -y wget # 下载 bottom (静态 musl 版本非常适合容器) wget https://github.com/ClementTsang/bottom/releases/download/0.10.2/bottom_x86_64-unknown-linux-musl.tar.gz # 解压并运行 tar -xzvf bottom_x86_64-unknown-linux-musl.tar.gz chmod +x btm ./btm
实际行为
bottom 显示的是宿主机的总资源。例如,它可能会显示 16 个核心和 64GB 内存,完全忽略了 cpus="2" 和 memory="2g" 的限制。
期望行为
bottom 应该能检测到它正运行在一个受 cgroup 限制的环境中,并显示该容器分配到的资源作为总量。在上面的例子中,它应该显示:
- 总 CPU 核心数:2
- 总内存:2 GB
这将使得百分比使用率在容器的上下文中变得有意义。
我的环境
- Bottom 版本:
0.10.2 - 操作系统 (容器内):
Linux fc67602e-2644-4ef6-bc44-81c87d67e86b 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux - 运行环境: 在一台自己管理的宿主机上的 Docker 容器内。
感谢您的宝贵时间并考虑此功能请求。这将会极大地改善开发者和系统管理员在容器环境下的使用体验。