#!/bin/bash
for i in `cat /home/lee/hosts`
do
ssh -i /home/lee root@$i "free -m >/root/${i}_memory.txt ;/bin/hostname >>/root/${i}_memory.txt"
sleep 1
scp -i /home/lee $i:/root/${i}_memory.txt /root/
sleep 1
done
if [ ! -f /root/get_memory.txt ]
then
touch /root/get_memory.txt
fi
echo >/root/get_memory.txt
for j in `ls 192*`
do
sed -n 3p $j | awk '{print $4}' >>/root/get_memory.txt
host=`sed -n '$p' $j`
ipadd=`ls $j`
echo "${ipadd%_*}-$host" >>/root/get_memory.txt
done
gzexe加密
注意:在ssh密匙登录执行命令遇到一台主机老是提示输入密码,找了半天终于在日志里面找到说/root目录的权限有问题,看来如果是设置好了免密登录,不管是密匙文件本身还是上层目录的权限都很重要.
本文转自chenzudao51CTO博客,原文链接: http://blog.51cto.com/victor2016/1917410,如需转载请自行联系原作者