VMware Communities > Developer Community > VMware vSphere™ PowerCLI > Discussions

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
1 Replies Last post: Oct 5, 2008 9:54 AM by LucD
Reply

VM File Monitoring

Oct 2, 2008 3:19 PM

Click to view SetClear's profile Enthusiast SetClear 24 posts since
Aug 24, 2007

So, heres another scripting format to get use to...

I would like to do what I have been doing in the form of perl from the console from a VM offloading the processing from the host.

What I am doing presently is recursivly reading through /vmfs/volumes/.. to find each vmx file and verifying that all pointers to the vmdk's etc are all readable.

The reason I have to do this is I had someone re-present a LUN to another VM as a raw device and the device got formatted as ntfs whihmade the ESX host unable to manage the volume.

I would have never known about this if it wasnt that one of the systems was rebooted. the power init forced esx to reread from the lun which it couldnt do. The other systems that were also on the volume but not rebooted were fine and would remain so until the systems were rebooted, power cycled, etc..

So, now I have been told by management that I need to monitor this.

Does anyone have a starting point for me using powershell. I have used perl for the longest time and quite good at vbs.. but powershell is all new...

Thanks in advance!

Bill

Reply Re: VM File Monitoring Oct 5, 2008 9:54 AM
Click to view LucD's profile Virtuoso LucD 1,757 posts since
Oct 31, 2005
To start you of, in the VITK it is quit easy to get a list of each VM and it's corresponding .VMX file.
$vmsImpl = Get-VM
$vms = $vmsImpl | Get-View
foreach($vm in $vms){
  Write-Host  $vm.Name $vm.Config.Files.VmPathName
}


Carter has recently added the function get-tkevmx to the VI Toolkit Extensions.
See how can I read the contents of *.vmx file.

From there you can get at all the entries in the .VMX file.

How would you proceed further to validate that a raw disk is not (mis)used by multiple guests ?
I could imagine situations where it is intentional (MS Clustering for example).
Actions