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 VM_Shutdown_Count.sh
Should be run specifying number of days.
For example.
#VM_Shutdown_Count.sh 30
Will list all the vm machines powered off since 30 days.i.e 1 Month.
Arg=$1
if [ -z $Arg ]
then
echo "Please Enter Argument"
exit
fi
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
do
cat /tmp/file2.txt | grep $line >> /tmp/final.txt
done < /tmp/file1.txt
while read line
do
ls -ltrh $line
done < /tmp/final.txt
No comments:
Post a Comment