#!/bin/bash
for HOST in `cat /root/list`
do
expect<<EOF
sleep 1
spawn scp /root/DR-server-chk.sh root@$HOST:/root
expect -re "yes"
send "yes\r"
expect -re "password"
send "root5192\r"
spawn ssh root@$HOST
expect -re "password"
send "root5192\r"
expect -re "#"
send "/root/DR-server-chk.sh\r"
expect -re "#"
send "scp /root/*rock 10.25.203.101:/root/drchk-result\r"
expect -re "yes"
send "yes\r"
expect -re "password"
send "root5192\r"
expect -re "#"
send "exit\r"
EOF
done
[root@m14pfdca01 ~]#
[root@Aserver ~]# cat total.sh
#!/bin/bash
for HOST in `ls /root/*rock`
do
echo "====================================================" >>total.txt
cat $HOST >> total.txt
echo "====================================================" >>total.txt
done
[root@Aserver ~]#
[root@Aserver ~]# cat test.sh
#!/bin/bash
clear
HOST=`hostname`rock
echo -e "[ Hosts Information ]------------------------------" > /root/$HOST
cat /etc/hosts >> /root/$HOST
echo "" >> /root/$HOST
echo -e "[ partition Information ]-------------------------" >> /root/$HOST
cat /etc/fstab >> /root/$HOST
echo "" >> /root/$HOST
echo -e "[ Fstab Information ]------------------------------" >> /root/$HOST
df -h >> /root/$HOST
echo "" >> /root/$HOST
echo -e "[ Multipath Information ]--------------------------" >> /root/$HOST
multipath -ll >> /root/$HOST
echo "" >> /root/$HOST
echo -e "[ Ntp Information ]--------------------------------" >> /root/$HOST
ntpq -p >> /root/$HOST
echo "" >> /root/$HOST
echo -e "[ Gate ping Information ]--------------------------" >> /root/$HOST
ping -c 5 192.168.122.2 /root/$HOST
echo "" >> /root/$HOST