Changeset 222 for drbl-virt/sbin
- Timestamp:
- Nov 8, 2010, 10:22:43 AM (14 years ago)
- Location:
- drbl-virt/sbin
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/check_drbl_VM
r219 r222 17 17 drbl_vm_file="/tmp/drbl_vm_status.$$" 18 18 drbl_vm_xentop_file="/tmp/drbl_vm_xentop.$$" 19 # check Xen or KVM 20 hypervisior=$(cat $Work_Home/etc/hypervisior) 21 19 22 20 23 # [Main] 21 24 check_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 26 case $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" 36 42 37 if [ $IP_status == "online" ]; then38 ssh -o StrictHostKeyChecking=no $client_IP "xentop -d1 -b -i2 | awk '/^.*NAME/{i++}i==2'" > $drbl_vm_xentop_file39 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}')" 40 46 41 #printf "[$client_hostname] " >> $drbl_vm_file42 printf "[$client_hostname] "43 declare -i i=147 # printf "[$client_hostname] " >> $drbl_vm_file 48 printf "[$client_hostname] " 49 declare -i i=1 44 50 45 vm_numbers=$(echo $vm_hostnames | wc -w)51 vm_numbers=$(echo $vm_hostnames | wc -w) 46 52 47 #printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file48 printf "[Running VM: $vm_numbers]\n"53 # printf "[Running VM: $vm_numbers]\n" >> $drbl_vm_file 54 printf "[Running VM: $vm_numbers]\n" 49 55 50 for vm_hostname in $vm_hostnames51 do52 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_file57 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+159 done60 echo ""61 else62 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 !" 63 69 64 fi70 fi 65 71 66 done 72 done 73 ;; 67 74 75 "KVM") 76 echo "KVM" 77 ;; 78 esac 68 79 # dlete tmp file 69 80 rm -f $drbl_vm_xentop_file -
drbl-virt/sbin/drbl_client_cmd
r212 r222 22 22 # = 2. Functions declation = 23 23 Usage(){ 24 echo "Usage: drbl_xen_cmd .shoptions"24 echo "Usage: drbl_xen_cmd options" 25 25 echo "Options:" 26 26 echo "-c|--client client name" 27 27 echo "-x|--execute execute command" 28 28 echo "Example:" 29 echo "drbl_xen_cmd .sh-c drbl101 -x 'shutdown'"29 echo "drbl_xen_cmd -c drbl101 -x 'shutdown'" 30 30 } 31 31 … … 46 46 client_name=$1 47 47 else 48 echo "-h host_value is null"48 echo "-h client value is null" 49 49 Usage && exit 2 50 50 fi
Note: See TracChangeset
for help on using the changeset viewer.