给大家带来批量copy文件shell剧本
欢迎大家来到仓酷云论坛!称号:satoolPS:(可让同事门叫成了“傻兔”)功效:此剧本能够批量实行下令,拷贝文件,浅易登录,无需记着使用办事用具体IP便可快速登录
申明:能够分组批量办理,单线程,不合用每组过百台装备(用也能够,就是守候前往了局工夫是非成绩)
用法:必要做ssh免暗码登录。由于是分组办理,以是必要分组设置文件/tools/function-all-ips(称号能够本人定,可是前面剧本必要援用此设置文件)设置文件格局
log_server="10.88.1.7810.88.1.47192.168.3.117"
lvs="192.168.1.141192.168.1.142"
组名=“IPIPIPIP”这类格局
工具参数:
-l浅易登录形式
satool-l组名
代码:
1
2
3
4
#satool-llvs
1)192.168.1.141
2)192.168.1.142
选择要毗连的办事器编号(Ctrl+C加入):
只必要输出1,大概2就能够间接登录,我们就不必要记着LVS的详细IP是几了
-g批量实行下令【能够加索引】下令必要
satool-g组名"cmd""num"(可选)
代码:
#satool-glvs"df-h"
192.168.1.141
FilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup00-LogVol00
13G6.9G5.5G56%/
/dev/sda199M13M82M14%/boot
tmpfs1006M01006M0%/dev/shm
192.168.1.142
FilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup00-LogVol00
13G6.9G5.5G56%/
/dev/sda199M13M82M14%/boot
tmpfs1006M01006M0%/dev/shm
这个功效年夜多半公司城市有,可是我们有这类情形,好比修正了一切某营业办事器的设置文件,办事器有20台,我不克不及一会儿全体重启,那样就会影响营业了,我们必要的是先重启前5个察看一下,没成绩以后在全体重启。为懂得决这个成绩-g到场了第四个参数就是索引(必要引号),比方:WWW组中有15台呆板,我只看前5台的负载情形。
代码:
#satool-lwww
1)192.168.1.26)192.168.1.16611)192.168.7.18716)192.168.7.153
2)192.168.1.37)192.168.3.112)192.168.7.14917)192.168.7.154
3)192.168.1.48)192.168.10.613)192.168.7.15018)192.168.7.155
4)192.168.1.59)192.168.7.18514)192.168.7.151
5)192.168.1.16410)192.168.7.18615)192.168.7.152
选择要毗连的办事器编号(Ctrl+C加入):
#satool-gwww"w""3"
192.168.1.2
23:47:34up57days,8:48,0users,loadaverage:0.00,0.01,0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.1.3
23:47:34up57days,8:48,0users,loadaverage:1.04,0.70,0.66
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.1.4
23:47:34up57days,8:48,0users,loadaverage:3.29,1.34,0.84
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
索引参数还能够撑持正数,即反向拔取
代码:
#satool-gwww"w""-3"
192.168.7.155
23:50:36up164days,21:52,0users,loadaverage:0.80,0.40,0.24
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.7.154
23:50:36up168days,11min,0users,loadaverage:0.11,0.23,0.19
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.7.153
23:50:37up160days,6:02,0users,loadaverage:0.91,0.33,0.21
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
还能够撑持非一连的单选
代码:
#satool-gwww"w""146"
192.168.1.2
23:51:37up57days,8:52,0users,loadaverage:0.00,0.00,0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.1.5
23:51:37up57days,9:34,0users,loadaverage:0.00,0.01,0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
192.168.1.166
23:51:37up301days,11:22,0users,loadaverage:0.17,0.31,0.48
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
-cp批量把当地的文件推送到远端办事器上(单向)【能够加索引】
satool-cp组名srcdest“num"(可选)
代码
#satool-cplvsshdmt.txt/tmp/
192.168.1.141
shdmt.txt100%49734.9KB/s00:00
192.168.1.142
shdmt.txt100%49734.9KB/s00:00
次要功效就是以上这些,其他功效都是帮助的了上面是完全代码共300多行,有点痴肥,接待会商优化
#!/bin/bash
##2012-11-21#######
##makebyG.M######
##version3.0######
red="