一个在多台机器上批量执行命令的工具, 支持分组

简单例子

 $ dsh -a -r ssh -c uptime
 10:53:36 up 44 days,  1:01,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 7 days, 19:34,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 47 days,  1:27,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 44 days, 19:29,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 44 days,  1:01,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 18 days, 20:39,  0 users,  load average: 0.00, 0.01, 0.05
 10:53:37 up 49 days, 19:33,  0 users,  load average: 0.00, 0.01, 0.05

在多台机器上执行uptime命令。

dsh可以从~/.dsh/machines.list下面读服务器列表

$ cat .dsh/machines.list
deploy@gitlab
deploy@puppet
deploy@php-staging
deploy@web01
deploy@web02
deploy@web03
deploy@db01

也可以使用-m选项指定主机

$ dsh -r ssh -m deploy@web01,deploy@web02 -c uptime
 11:16:44 up 44 days, 19:52,  0 users,  load average: 0.00, 0.01, 0.05
 11:16:44 up 44 days,  1:24,  0 users,  load average: 0.23, 0.08, 0.06

主配置文件是/etc/dsh/dsh.conf 或者是~/.dsh/dsh.conf

比如

$ cat .dsh/dsh.conf
remoteshell = ssh

设置remoteshell为ssh


lidashuang
6.7k 声望165 粉丝

$ Ruby/Elixir/Golang