Releases: eyjian/redis-tools
0
包括的批量工具:
mooon_ssh 批量命令工具
mooon_upload 批量上传工具
mooon_download 批量下载工具
C++版本:
mooon-tools-glibc2.4_i386.tar.gz
mooon-tools-glibc2.17_x86_64.tar.gz
GO版本:
mooon-tools-glibc2.4_i386_go.tar.gz(依赖glibc)
mooon-tools-glibc2.17_x86_64_go.tar.gz(依赖glibc)
mooon-tools-i386_go.tar.gz(不依赖glibc)
mooon-tools-x86_64_go.tar.gz(不依赖glibc)
使用示例1:上传/etc/hosts
mooon_upload -s=/etc/hosts -d=/etc
使用示例2:检查/etc/profile文件是否一致
mooon_ssh -c='md5sum /etc/hosts'
使用示例3:批量查看crontab
mooon_ssh -c='crontab -l'
使用示例4:批量清空crontab
mooon_ssh -c='rm -f /tmp/crontab.empty;touch /tmp/crontab.empty'
mooon_ssh -c='crontab /tmp/crontab.emtpy'
使用示例5:批量更新crontab
mooon_ssh -c='crontab /tmp/crontab.online'
使用示例6:取远端机器IP
因为awk用单引号,所以参数“-c”的值不能使用单引号,所以内容需要转义,相对其它来说要复杂点:
mooon_ssh -c="netstat -ie | awk -F[\ :]+ 'BEGIN{ok=0;}{if (match($0, "eth1")) ok=1; if ((1==ok) && match($0,"inet")) { ok=0; if (7==NF) printf("%s\n",$3); else printf("%s\n",$4);} }'"
不同的环境,IP在“netstat -ie”输出中的位置稍有不同,所以awk中加了“7==NF”判断,但仍不一定适用于所有的环境。需要转义的字符包含:双引号、美元符和斜杠。