source: drbl-virt/sbin/check_drbl_total_vm @ 247

Last change on this file since 247 was 219, checked in by rock, 14 years ago

Add: KVM PXE VM deployment

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/bin/bash
2# Program:
3#   Check DRBL total vm status
4# Author:
5#   Jazz, Rock {jazz, rock}@nchc.org.tw
6# Version:
7#    1.0
8# History:                                                                                         
9#   2010/09/09  Rock    First release (1.0)
10
11source /opt/drbl-virt/conf/drbl-virt.conf
12source $Work_Path/functions_drbl_virt
13
14
15# [Varliables]
16vm_total_status_file=/tmp/vm_totoal_status.$$
17vm_IP_files=$(ls $Work_Home/etc/IP_VM_eth[0-9])
18
19# [Main]
20check_root
21
22echo -e "VM_IP       VM_Hostname \t VM_Status" >> $vm_total_status_file
23echo "------------------------------------------------------" >> $vm_total_status_file
24
25for vm_IP_file in $vm_IP_files
26do
27    # local variables
28    vm_IPs=$(cat $vm_IP_file | awk '{print $1}')
29
30    for vm_IP in $vm_IPs
31    do
32        # check network status
33        IP_status="online"
34        ping -c1 -w1 $vm_IP > /dev/null 2>&1 || IP_status="offline"
35        vm_IP_Hostname=$(sed -n "/$vm_IP/p" $vm_IP_file)
36        echo -e "$vm_IP_Hostname \t\t $IP_status" >> $vm_total_status_file
37    done
38
39done
40   
41cat $vm_total_status_file
42
43# dlete tmp file
44rm -f $vm_total_status_file
Note: See TracBrowser for help on using the repository browser.