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

沒有留言:

Obsidian 插件介紹:Text Generator

Text Generator 是 Obsidian 的一個插件,它可以根據給定的提示自動生成文本。這個插件使用 GPT-3 語言模型,能夠產生類似人類的文本,非常適合編寫故事、文章、電子郵件和其他類型文本。 主要功能: **生成文本:**根據提示生成各種長度的...