Search This Blog

Monday, April 18, 2011

How to find Old powered off machines in oracle vm .

With VM environment consisting of more than 500 virtual machines,You may find this helpful .

It might not be possible to observe each and every virtual machines to find instances of powered off machines since long time .

A little bit of scripting will help you find such machines.

Create a file called
Should be run specifying number of days.
For example. 30
Will list all the vm machines powered off since 30 days.i.e 1 Month.


if [ -z $Arg ]
echo "Please Enter Argument"

cat `find /var/ovs/mount/ -name vm.cfg` | grep "disk" | awk -F ":" '{print $2}'| awk -F "," '{print $1}' |grep running_pool| grep -v "^$" > /tmp/file1.txt

find /var/ovs/mount/ -name *.img -mtime +$Arg > /tmp/file2.txt

rm -rf /tmp/final.txt
while read line
cat /tmp/file2.txt | grep $line >> /tmp/final.txt
done < /tmp/file1.txt

while read line
ls -ltrh $line
done < /tmp/final.txt

No comments:

Post a Comment