Tuesday, 14 June 2011

vCentre Useful Queries: Part I

After posting on twitter last week that I needed something to write a blog post about my good friend Christian Dadswell (Blog|Twitter) suggested I post the queries I wrote for him awhile back to dig him out of hole. Chris has dug me out of many a hole when I have needed advice on vSphere, Chris is a full time vSphere guru and part-time Android developer, which  he is very good at. Go and check out his BBC Browse Cast app for yourself. Not having an android phone myself I haven’t used his app, he refuses to get involved with Apple products which is a shame but if he gets enough encouragement I’m sure he could be persuaded. 

Chris needed me to get some information out of the vSphere vCentre database. Firstly he wanted a quick and dirty way of getting information from vCentre database  on VM snapshots. Snapshots are great tool that can allow you take a snapshot or ‘point in time’ view of the VM. I find it easiest to imagine vSphere snapshots to be similar to database snapshots in SQL Server. We don’t go into the specific  details of how these work here but if you create a snapshot on a VM, as the VM changes the changes are written to the snapshot. This enables you to restore the VM to the state it was when the snapshot was taken. This can be useful when applying OS patches and the like.

You can get problems  when you forget that the snapshot exists and it can fill up the space on disk. If this happens it can cause your VM to stop working properly. Chris wanted to find all VMs that had a snapshot over 14 days old. The theory behind it was if a snapshot was older than 14 days it was unlikely to ever be used to restore the VM and he could then get onto the person who created it and hopefully delete it before it causes problems.

This is the query that was used

select  e.NAME,


I hope you find it useful. I ended up plugging this query into a SSRS report to allow all sys admins find old snapshots.

There will be a second post in this series looking at monitoring which VMs are running on what host and why that can be useful

1 comment:

  1. Nice article Gethyn,

    Many thanks for the mention.

    To clarify the usefulness of your upcoming second post, when a HA event occurs and all VM's are moved to other hosts there is sometimes a requirement to know what was running on the host that has gone into host isolation.

    The ability for any of the support teams to be able to get a report to show what VM's were on a particular host is very useful for troubleshooting services that were affected by the VM's shutdown/restart.



Featured post

OUT OF SUPPORT: SQL Server 2008 and SQL Server 2008 R2

Welcome to this post, on SQL Server 2008 and 2008 R2, both of these versions of SQL server will go out of  extended support with Microsoft t...