Changeset 222 for drbl-virt/sbin


Ignore:
Timestamp:
Nov 8, 2010, 10:22:43 AM (14 years ago)
Author:
rock
Message:

Add: migration command

Location:
drbl-virt/sbin
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/check_drbl_VM

    r219 r222  
    1717drbl_vm_file="/tmp/drbl_vm_status.$$"
    1818drbl_vm_xentop_file="/tmp/drbl_vm_xentop.$$"
     19# check Xen or KVM
     20hypervisior=$(cat $Work_Home/etc/hypervisior)
     21
    1922
    2023# [Main]
    2124check_root
    22 for client_IP in $client_IPs
    23 do
    24     # local variables
    25     IP_status="online"
    26     client_hostname="$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | grep $client_IP | awk '{print $2}')"
    27     vm_numbers=""
    28     vm_hostnames=""
    29     vm_IP=""
    30     vm_CPU_core=""
    31     vm_Ram=""
    32     vm_CPU_loading=""
    33     vm_Ram_loading=""
    34     # check network status
    35     ping -c1 -w1 $client_IP > /dev/null 2>&1 || IP_status="offline"
     25
     26case $hypervisior in
     27    "Xen")
     28    for client_IP in $client_IPs
     29    do
     30        # local variables
     31        IP_status="online"
     32        client_hostname="$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | grep $client_IP | awk '{print $2}')"
     33        vm_numbers=""
     34        vm_hostnames=""
     35        vm_IP=""
     36        vm_CPU_core=""
     37        vm_Ram=""
     38        vm_CPU_loading=""
     39        vm_Ram_loading=""
     40        # check network status
     41        ping -c1 -w1 $client_IP > /dev/null 2>&1 || IP_status="offline"
    3642   
    37     if [ $IP_status == "online" ]; then
    38         ssh -o StrictHostKeyChecking=no $client_IP "xentop -d1 -b -i2 | awk '/^.*NAME/{i++}i==2'" > $drbl_vm_xentop_file
    39         vm_hostnames="$(cat $drbl_vm_xentop_file | sed -n '3,$p' | awk '{print $1}')"
     43        if [ $IP_status == "online" ]; then
     44            ssh -o StrictHostKeyChecking=no $client_IP "xentop -d1 -b -i2 | awk '/^.*NAME/{i++}i==2'" > $drbl_vm_xentop_file
     45            vm_hostnames="$(cat $drbl_vm_xentop_file | sed -n '3,$p' | awk '{print $1}')"
    4046   
    41 #        printf "[$client_hostname] " >> $drbl_vm_file
    42         printf "[$client_hostname] "
    43         declare -i i=1
     47            # printf "[$client_hostname] " >> $drbl_vm_file
     48            printf "[$client_hostname] "
     49            declare -i i=1
    4450
    45         vm_numbers=$(echo $vm_hostnames | wc -w)
     51            vm_numbers=$(echo $vm_hostnames | wc -w)
    4652
    47 #        printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file
    48         printf "[Running VM: $vm_numbers]\n"
     53           # printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file
     54            printf "[Running VM: $vm_numbers]\n"
    4955
    50         for vm_hostname in $vm_hostnames
    51         do 
    52             vm_CPU_core="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $9}')"
    53             vm_Ram="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $5}')"
    54             vm_CPU_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $4}')"
    55             vm_Ram_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $6}')"
    56 #            printf "VM$i: $vm_hostname $vm_CPU_core ${vm_Ram}K $vm_CPU_loading%% $vm_Ram_loading%%\n" >> $drbl_vm_file
    57             printf "VM$i: $vm_hostname VCPU=$vm_CPU_core Mem=${vm_Ram}K VCPU_loading=$vm_CPU_loading%% Mem_usage=$vm_Ram_loading%%\n"
    58             i=i+1
    59         done
    60         echo ""
    61     else
    62         echo "[Error] $client_hostname $client_IP is offline !"
     56            for vm_hostname in $vm_hostnames
     57            do 
     58                vm_CPU_core="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $9}')"
     59                vm_Ram="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $5}')"
     60                vm_CPU_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $4}')"
     61                vm_Ram_loading="$(cat $drbl_vm_xentop_file | grep $vm_hostname | awk '{print $6}')"
     62               # printf "VM$i: $vm_hostname $vm_CPU_core ${vm_Ram}K $vm_CPU_loading%% $vm_Ram_loading%%\n" >> $drbl_vm_file
     63                printf "VM$i: $vm_hostname VCPU=$vm_CPU_core Mem=${vm_Ram}K VCPU_loading=$vm_CPU_loading%% Mem_usage=$vm_Ram_loading%%\n"
     64                i=i+1
     65            done
     66            echo ""
     67        else
     68            echo "[Error] $client_hostname $client_IP is offline !"
    6369
    64     fi
     70        fi
    6571
    66 done
     72    done
     73    ;;
    6774
     75    "KVM")
     76        echo "KVM"
     77    ;;
     78esac
    6879# dlete tmp file
    6980rm -f $drbl_vm_xentop_file
  • drbl-virt/sbin/drbl_client_cmd

    r212 r222  
    2222# = 2. Functions declation =
    2323Usage(){
    24 echo "Usage: drbl_xen_cmd.sh options"
     24echo "Usage: drbl_xen_cmd options"
    2525echo "Options:"
    2626echo "-c|--client         client name"
    2727echo "-x|--execute        execute command"
    2828echo "Example:"
    29 echo "drbl_xen_cmd.sh -c drbl101 -x 'shutdown'"
     29echo "drbl_xen_cmd -c drbl101 -x 'shutdown'"
    3030}
    3131
     
    4646                    client_name=$1
    4747                else
    48                     echo "-h host_value is null"
     48                    echo "-h client value is null"
    4949                    Usage && exit 2
    5050                fi
Note: See TracChangeset for help on using the changeset viewer.