All things are difficult before they are easy. 没有软件的裸机是一具僵尸,没有硬件的软件是一个幽灵。2012,专注于Linux和C语言,关注自动化、性能测试,关注开源社区和开源测试工具、方法,尝试测试团队管理!

记录Xen测试中的两个Shell脚本

上一篇 / 下一篇  2011-08-14 13:20:30 / 个人分类:Shell

最近都很忙,一直在测试Novell公司的SLES操作系统的virtualization相关 功能。其中stress部分要做Xen的hotplug SR-IOV VF 500遍以及当guest中assign一个VF时做24小时scp,写了两个简单Shell脚本,贴一下,留个纪念吧。
#!/bin/bash
#hot plug VF for 500 times
DomId=$(xl list | grep SLES | awk '{print $2}')
vf="01:10.0"
i=1
/root/pciback.sh -h $vf
echo "DomId=$DomId"
while [ $i -le 500 ]
do
    xl pci-attach $DomId $vf
    echo "${i}th time: hot pulg VF:$vf"
    if [ $i -ge 20 ]; then
        echo "please check VF in guest"
        sleep 30
    fi
    sleep 5
    xl pci-detach $DomId $vf
    echo "Detach VF:$vf"
    sleep 5
    i=$(($i+1))
done

另一个SCP 24小时:
#!/bin/bash
#scp for 24 hours
scp_log=/root/jay/scp-24h.log
begin_date=$(date +%s)
end_date=$(($begin_date+86400))
md5_host="$(md5sum file-4-scp)"
guest_ip="192.168.87.150"

function ping_guest()
{
    ping -c1 $guest_ip
    if [ $? -ne 0 ]; then
        echo "ping $guest_ip fails at $(date)" >> $scp_log
        return 1
    fi
    return 0
}

echo "--------scp-24.sh  begins at $(date) --------------" > $scp_log
present_date=$(date +%s)
counter=1
while [ $present_date -le $end_date ]
do
    ping_guest
    if [ $? = 1 ]; then
        sleep 10
        continue
    fi
    scp file-4-scp 192.168.87.150:/root/
    sleep 1
    md5_guest="$(ssh root@192.168.87.150 'md5sum file-4-scp')"
    if [ "xx$md5_host" = "xx$md5_guest" ]; then
        echo "${counter} time scp succeeds." >> $scp_log
    else
        echo "${counter} time scp fails at $(date)." >> $scp_log
        echo "md5_host=$md5_host"  >> $scp_log
        echo "md5_guest=$md5_guest" >> $scp_log
    fi
    counter=$(($counter+1))
    present_date=$(date +%s)
done
echo "--------scp-24.sh  ends at $(date) --------------" >> $scp_log

TAG: Linux linux shell Shell Xen xen

 

评分:0

我来说两句

smile665

smile665

Stay hungry, stay foolish. 得意之时谨记,一半命运还掌握在上帝手里;失意之时须知,一半命运还掌握在自己手里。

日历

« 2024-03-21  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 951993
  • 日志数: 220
  • 建立时间: 2008-11-06
  • 更新时间: 2012-10-06

RSS订阅

Open Toolbar