Skip to main content

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,
s.SNAPSHOT_NAME,
s.CREATE_TIME

from VPX_SNAPSHOT s
INNER JOIN VPX_ENTITY e ON s.VM_ID = e.ID
WHERE s.CREATE_TIME < GETDATE()-14
ORDER BY s.CREATE_TIME asc

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

Comments

  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.

    Christian.

    ReplyDelete

Post a Comment

Popular posts from this blog

Always Encrypted

By David Postlethwaite

Always Encrypted is new features in SQL Server 2016 and it is also available in Azure SQL Database. Here you can encrypt columns in a table with a master key and a certificate so that they will appear as encrypted strings to those who don’t have the required certificate installed on their pc.
Once the certificate is installed on the computer then the unencrypted data can then be seen as normal.

The data passes from database to your application as the encrypted value, only the application with the correct certificate can unencrypt the data so it is secure across the wire. This will go some way to resolving the concern of people worried about putting their sensitive data on a shared server in the cloud such as Microsoft Azure and accessing the data across the Internet.

At the time of writing Always Encrypted is only supported with ADO.NET 4.6, JDBC 6.0 and ODBC 13.1 but expect other driver to become available.

The calling application (including SSMS) must also hav…

SQL Server 2012 and Virtual Service Accounts

This post is written by David Postlethwaite
If you are using SQL Server 2012 you will probably have noticed that the default account for the SQL services has changed from that used in previous versions. With SQL 2005 and 2008 the default account for SQL service and SQL Agent service was “NT Authority\System”. This is one the built in accounts on a Windows machine, managed by the machine and selectable from a dedicated dropdown list

The Network Service account was introduced in Windows 2003 as an alternative to using the LocalSystem account, which has full local system privileges on the local machine, a major security concern.
The Network Service has limited local privileges easing these security concerns but when many services on a machine use the Network Service account it becomes harder to track which service is actually accessing resources and performing actions, because all the services are using the one Network Service account.
Also, this account, by default, has sysadmin per…

SQL Server Express v SQL Server Developer Edition

SQL Server Express v  SQL Server Developer Edition
Over the weekend I received the following in an email from Ali Ahmad who asked me some questions about learning SQL Server. We exchanged a couple of emails so I have boiled this down to the most salient points.

Question:
Goal: I want to learn SQL Server inside out… for career progression as DBA/BI/data mining. I'm a data analyst and want to learn inside out about data warehousing.
•I understand relational database concepts...
•I have SQL Server 2014 express installed…
•I need to download the adventure works sample in order to play with it.
•So much knowledge on Microsoft website it's easy to get lost… where do I begin?

SQL Server Express v SQL Server Developer
This is interesting. If you want to learn SQL Server inside out including the Business Intelligence suite of applications I would suggest downloading the developer edition of SQL Server which since 2016 has been made available free of charge. Prior to that there was a f…