2016年5月4日 星期三

How to get docker node ip with awk

 

###  docker query swarm node 

Images: 26
Role: replica
Primary: 192.168.200.24:2378
Strategy: spread
Filters: health, port, dependency, affinity, constraint
Nodes: 3
cl-master: 192.168.200.1:2375
└ Status: Healthy
└ Containers: 57
└ Reserved CPUs: 0 / 4
└ Reserved Memory: 0 B / 971.8 MiB
└ Labels: executiondriver=native-0.2, hypriot.arch=armv7l, hypriot.hierarchy=leader, kernelversion=4.4.8-v7+, operatingsystem=Raspbian GNU/Linux 8 (jessie), storagedriver=overlay
└ Error: (none)
└ UpdatedAt: 2016-05-04T03:12:06Z
cl-node-1: 192.168.200.24:2375
└ Status: Healthy
└ Containers: 5
└ Reserved CPUs: 0 / 4
└ Reserved Memory: 0 B / 971.8 MiB
└ Labels: executiondriver=native-0.2, hypriot.arch=armv7l, hypriot.hierarchy=follower, kernelversion=4.4.8-v7+, operatingsystem=Raspbian GNU/Linux 8 (jessie), storagedriver=overlay
└ Error: (none)
└ UpdatedAt: 2016-05-04T03:12:22Z
cl-node-2: 192.168.200.42:2375
└ Status: Healthy
└ Containers: 5
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 456.4 MiB
└ Labels: executiondriver=native-0.2, hypriot.arch=armv6l, hypriot.hierarchy=follower, kernelversion=4.4.8+, operatingsystem=Raspbian GNU/Linux 8 (jessie), storagedriver=overlay
└ Error: (none)
└ UpdatedAt: 2016-05-04T03:12:19Z
Plugins:
Volume:
Network:
Kernel Version: 4.4.8-v7+
Operating System: linux
Architecture: arm
CPUs: 9
Total Memory: 2.344 GiB
Name: 74190158d072

 

 

## 使用awk split function 去做组合

awk “print $2”  会印出  192.168.200.42L2375 

$ docker -H 192.168.200.1:2378 info|grep cl|awk '{split($2,ip,":");print ip[1]}'
192.168.200.1
192.168.200.24
192.168.200.42

沒有留言:

How to restore a deleted onenote page

復原不小心誤刪的onenote