Wednesday, 26 February 2014

new vCheck plugin: Orphaned VMDK File (v0.1)

What is an orphaned VMDK file?

I believe that it really depends on your perspective, or in this case the vCenter Server's. I would suggest that a file is orphaned (at least from the perception of a given vCenter) when it (the vCenter) is not aware of what purpose the VMDK file serves; or, to which virtual machine it belongs. This does not always hold true, but that's my general explanation.

Here are a couple of examples of when a VMDK file may appear to be orphaned, but in reality is not:

  • virtual machines that exist on datastores shared by two or more vCenter servers
    • In this case, the virtual machine (and associated VMDKs) may only be known by one of the vCenter servers; therefore, from the perspective of the other vCenter server, these VMDKs may be appear to be orphaned.
  • virtual machine placeholders used by Site Recovery Manager

What is the purpose of scanning for orphaned VMDKs?

Here are a couple:

  • it may be able to detect residual snapshot delta files (i.e. snapshots not being consolidated properly)
  • it might potentially detect virtual disks (including RDMs) that have been detached from a virtual machine file, and may no longer be required

Anyway, on to giving credit where credit is due. I found the core algorithm for this plugin on Jason Coleman's blog in the post Orphaned VMDK Files. It was originally written by HJA van Bokhoven, and has since been modified by LucD, Jason Coleman, and myself. I decided to use this as a starting point to create a plugin for Alan Renouf's vCheck.

The plugin 109 Orphaned VMDK File.ps1.disabled has been published and can be found on the vCheck github under the Plugins directory.

The settings are mostly self-explanatory:

  • $excludeDatastoreRegex
    • Regex pattern used to exclude datastores by name, which can be useful for omitting unused datastores, and those shared between vCenter Servers.
  • $excludeVMPathRegex
    • Regex pattern used to exclude VMs by VM path. This can be useful for omitting SRM placeholders, and other VMs that should not appear in the report.

Please be advised, this plugin can take quite a while run, depending on the size of the environment. Because of this, I have disabled by default in vCheck. (the plugin has the extension .ps1.disabled) I have found it useful, but I suggest understanding its purpose prior to enabling it.

Disclaimer: This plugin is only for informational purposes. It detects what it believes to be orphaned files from the perspective of the vCenter Server that it is run against. This does not imply that any file it detects is not required. It is not recommending or suggesting any specific actions. It is simply providing data, which can be used to investigate further. Use at own risk.

Normally this is where I would finish my post, but on a more serious note I'd like to direct your attention to some great work that is being done in the #vCommunity by the VMware Foundation and some of our fellow bloggers. Please read Duncan Epping's blog post: Serve, Learn and Inspire – support the cause and donate/contribute! As Duncan states, they are helping by "working on improving the delivery of computer classes to various orphanages in Vietnam." Read more about this on his blog.

Keep on virtualizing!

No comments:

Post a Comment