Monday, January 8, 2018

vCenter database queries

Log into SQL where the vCenter database is on and run the following query:

How many VMs have been deployed.

    select CREATE_TIME,VM_NAME from VPX_EVENT where EVENT_TYPE='vim.event.VMBeingDeployedEvent' and CREATE_TIME>='2012-01-01' and CREATE_TIME<='2013-01-01' and VM_NAME     like 'searchname%' and VM_NAME not like 'vm_name%' and VM_NAME not like 'vm_name%'and VM_NAME not like 'vm_name%' and VM_NAME not like 'vm_name%'    select CREATE_TIME, VM_NAME from VPX_EVENT where EVENT_TYPE= 'vim.event.VMRemovedEvent' and CREATE_TIME >= '2012-01-01' and CREATE_TIME <= '2013-01-01'    select CREATE_TIME, VM_NAME from VPX_EVENT where EVENT_TYPE= 'vim.event.VMCreatedEvent' and CREATE_TIME >= '2012-01-01' and CREATE_TIME <= '2013-01-01'

Memory usage for the year.

    select sample_time, stat_name, stat_value from VPXV_HIST_STAT_YEARLY where stat_group='mem' and stat_name='usage'