Skip to content
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

Feature Request: docker stats #313

Open
uri200 opened this issue Feb 11, 2021 · 9 comments
Open

Feature Request: docker stats #313

uri200 opened this issue Feb 11, 2021 · 9 comments

Comments

@uri200
Copy link

uri200 commented Feb 11, 2021

Hey @mikaku ,
One more suggestion: what about docker stats? It'd be cool to have something like docker_processes where we could throw names of containers to be tracked.

$ docker stats redis1 redis2 CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O
 redis1 0.07% 796 KB / 64 MB 1.21% 788 B / 648 B 3.568 MB / 512 KB
 redis2 0.07% 2.746 MB / 64 MB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B

Just a suggestion. No rush at all.

Thanks!

@uri200
Copy link
Author

uri200 commented Jun 25, 2021

Just touching this, in case it could be look through again :)

@mikaku
Copy link
Owner

mikaku commented Jun 28, 2021

Yes, I'm a bit busy lately at work, so that's why this and other issues may seem freezed.
Sorry for the inconveniences.

@mikaku
Copy link
Owner

mikaku commented Sep 7, 2021

@uri200,

I don't have docker but podman since I'm using Fedora, but I think they are similar, if not the same.
I'm not very versed with containers so, excuse my ignorance.

I've create a test docker with podman run -it fedora bash under my regular desktop user. I'm able to see the stats of this docker with:

$ podman stats -a --no-stream
ID            NAME             CPU %       MEM USAGE / LIMIT  MEM %       NET IO      BLOCK IO    PIDS        CPU TIME    AVG CPU %
2e61a62db12f  nostalgic_allen  2.88%       7.066MB / 8.188GB  0.09%       -- / --     -- / --     1           46.959ms    2.88%

But I've seen that executing the same command under root it returns nothing.
Since Monitorix runs under root, do you know a way to get the same statistics using the root user?

@ehnwebmaster
Copy link

See docker stats with Monitorix will be really nice

docker stats -a --no-stream and sudo docker stats produces the same behaviour::

CONTAINER ID   NAME        CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O        PIDS
ade4d2b8366d   ubuntu      0.00%     0B / 0B               0.00%     0B / 0B           0B / 0B          0
955b4fd616b3   mobsf       0.01%     57.61MiB / 7.812GiB   0.72%     1.23MB / 816kB    22.6MB / 0B      3
860688fc4d71   portainer   0.00%     23.86MiB / 31.05GiB   0.08%     1.22MB / 2.29MB   10.2MB / 5.6MB   9

Dependencies will be docker-py

Currently I'm using glances (python) to seed docker stats

https://github.com/nicolargo/glances

CONTAINERS 2 (served by Docker 20.10.12)
Name Status CPU% MEM IOR/s IOW/s RX/s TX/s Command
mobsf running 0.0 60.0M 0b 0b 0b 0b
portainer running 0.0 29.9M 0b 0b 0b 0b ["/portainer"]

Another tool is ctop

@mikaku
Copy link
Owner

mikaku commented Nov 10, 2022

@ehnwebmaster,

I see differences when running podman stats -a --no-stream either under the regular user which is running a container, and root:

$ podman stats -a --no-stream

ID            NAME                CPU %       MEM USAGE / LIMIT  MEM %       NET IO       BLOCK IO    PIDS        CPU TIME    AVG CPU %
6725ce9cb235  compassionate_bose  0.00%       57.34kB / 16.63GB  0.00%       430B / 110B  0B / 0B     1           7.45ms      0.00%
$ 

It seems that root user is unable to see all running containers (Fedora 36):

# podman stats -a --no-stream
ID          NAME        CPU %       MEM USAGE / LIMIT  MEM %       NET IO      BLOCK IO    PIDS        CPU TIME    AVG CPU %

Also, the same command under root clears the screen before showing any stats.

What am I missing?

@foxbg
Copy link

foxbg commented Nov 24, 2023

It looks that this is podman feature.

to see containers for user with uid 1000 run:
systemd-run --uid=1000 --pty --wait --collect --service-type=exec /usr/bin/podman ps -a
Source: https://unix.stackexchange.com/questions/680171/list-containers-from-other-users

For docker this "hack" is not required as root can see all containers.

@mikaku
Copy link
Owner

mikaku commented Nov 25, 2023

Yes, but this would complicate the configuration on a system with multiple users using podman.
I'd like to know if there is a way to list all containers of all users with a single command.

@foxbg
Copy link

foxbg commented Nov 25, 2023

Not a podman expert. As far as I know not for podman. And my understanding is that this is by design for Rootless. Maybe we can ask in podman (https://github.com/containers/podman).
Docker (the request is for docker) lists all containers for all users (again AFAIK) by default.

@mikaku
Copy link
Owner

mikaku commented Nov 26, 2023

I think you're right, as you said, podman is rootless by design, so I guess it won't be possible to do it with it.
So, better focus on Docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants