python docker stats

Solutions on MaxInterview for python docker stats by the best coders in the world

showing results for - "python docker stats"
Lia
24 Mar 2018
1
2import docker
3import multiprocessing as mp
4
5output = mp.Queue()
6
7def stats(server):
8    client=docker.from_env()
9    client_lowlevel = docker.APIClient(base_url='unix://var/run/docker.sock')
10    client_stats=client_lowlevel.stats(container=server,decode=True, stream=False)
11    output.put(client_stats)
12
13processes =[ mp.Process(target=stats, args=(server)) for server in ['server1','server2']]
14
15# Run processes
16for p in processes:
17    p.start()
18
19# Exit the completed processes
20for p in processes:
21    p.join()
22
23
24