0

I have couple of nodes in docker swarm but both the nodes shows only container running on them when "docker stats" command is run

But i would like list container stats (cpu,memory) from all nodes when docker stats is run on any one of the node.

Is this possible?

Any insight will be of great help.

Karthick
  • 1
  • 2

2 Answers2

0

There's no direct way to retrieve all container stats of a given service in a Swarm.

if you want information about CPU, memory and other info, you can use combinations docker node, cut, xargs and ssh then docker stats on each node:

docker node ls | cut -c 31-49 | grep -v HOSTNAME | xargs -I"SERVER" sh -c "echo SERVER; ssh SERVER /usr/local/bin/docker stats --no-stream"

Above command will show you each container CPU,Memory group by node like

Node1

b95a83497c91 awesome_brattain 0.28% 5.629MiB / 1.952GiB 0.28% 916B / 0B 147kB / 0B 9
e5c383697914 test-1951.1.kay7x1lh1twk9c0oig50sd5tr 0.00% 196KiB / 1.952GiB 0.01% 71.2kB / 0B 770kB / 0B 1

Node2

  67b2525d8ad1   foobar      0.00%     1.727MiB / 1.952GiB   0.09%   2.48kB / 0B         4.11MB / 0B         2
    4bda148efbc0 random. 0.00% 1.672MiB / 1.952GiB 0.08% 110kB / 0B 578kB / 0B 2

Also ref. https://stackoverflow.com/questions/45907274/docker-stats-in-swarm-mode

sanjayparmar
  • 633
  • 8
  • 19
0

this is nos possible with pure docker, or you could use CAdvisor tha make monitor on nodes from the cluster an get metrics form containers. If you wish you could also monitor those metrics with prometheus and grafana.