This post provides several methods of determining whether any VMs in a Virtual Center 2 environment have any active snapshots. This is a useful monitoring task in production environments, as taking a snapshot and forgetting to remove the snapshot can cause problems when consolidating in the future. Included is a SQL query, a sqlcmd query, and a simple 'ls' command to run from the service console.
Method 1 - Run a query through SQL Management Studio against the Virtual Center database
select ENT.Name as 'Name', DNS_Name as 'DNS Name', Guest_OS as 'OS', Mem_Size_MB as 'Mem', IP_Address as 'IP', VM.FILE_Name as 'VMX location', VM.Suspend_Time as 'Suspend Time', VM.Suspend_Interval as 'Suspend Interval', VMS.Snapshot_Name as 'Snapshot Name', VMS.Snapshot_Desc 'Snapshot Description', DateAdd("Hour", 10, VMS.Create_Time) as 'Snapshot Time', VMS.Is_Current_Snapshot 'Current Snapshot' from vpx_vm VM
inner join VPX_GUEST_NET_ADAPTER NET on VM.ID = NET.VM_ID
inner join VPX_ENTITY ENT on VM.ID = ENT.ID
inner join VPX_SNAPSHOT VMS on VM.ID = VMS.VM_ID
Method 2 - Query the Virtual Center database for Virtual Machine snapshots (GMT+10) using sqlcmd
sqlcmd -S %server% -d %database% -W -s "," -Q "select ENT.Name as 'Name', DNS_Name as 'DNS Name', Guest_OS as 'OS', Mem_Size_MB as 'Mem', IP_Address as 'IP', VM.FILE_Name as 'VMX location', VM.Suspend_Time as 'Suspend Time', VM.Suspend_Interval as 'Suspend Interval', VMS.Snapshot_Name as 'Snapshot Name', VMS.Snapshot_Desc 'Snapshot
Description', DateAdd(Hour, 10, VMS.Create_Time) as 'Snapshot Time', VMS.Is_Current_Snapshot 'Current Snapshot' from vpx_vm VM inner join VPX_GUEST_NET_ADAPTER NET on VM.ID = NET.VM_ID inner join VPX_ENTITY ENT on VM.ID = ENT.ID inner join VPX_SNAPSHOT VMS on VM.ID = VMS.VM_ID"
Example output:
VM1,VM1.domain.com,winXPProGuest,768,192.168.0.1,sanfs://vmfs_uuid:47445a61-08269406-d462-0419b6f67087/VM1/VM1.vmx,NULL,0,Test Snapshot,,2008-03-29 07:24:31.170,1
Method 3 - View vmsn files from the service console
ls -Ral /vmfs/volumes/*.* grep .vmsn
Note that VMware would not recommend querying SQL directly, and I suspect would instead suggest using their very (in my opinion) unintuitive SDK and object model. Bring on the PowerShell management interface.
Wayne's World of IT (WWoIT), Copyright 2008 Wayne Martin.
Information regarding Windows Infrastructure, centred mostly around commandline automation and other useful bits of information.
No comments:
Post a Comment