VMware Cloud Community
johntrask
Contributor
Contributor

vCenter Database - Datastore Statistics

Hello All,


I am trying to create a custom report on usage outside of vCenter by querying the database. I have the usage statics for MEM and CPU. I am unable to find the datastore stats. Does anyone know where it is? I am specifically looking for the used or free space at the end of every day.


vCenter is 5.5 Update 2

Tags (3)
0 Kudos
3 Replies
virtualg_uk
Leadership
Leadership

Rather than query the databse I would use PowerCLI's get-stat cmdlet  Get-Stat - vSphere PowerCLI Cmdlets Reference

combined with get-datastore Get-Datastore - vSphere PowerCLI Cmdlets Reference

which will return a datastore object with the following properties such as freespaceMB:  Datastore



Graham | User Moderator | https://virtualg.uk
0 Kudos
UmeshAhuja
Commander
Commander

Hi,

If you are looking for the Datastore capacity and free space report kind of stuff then below is the query which you help you.

SELECT VMS.[NAME] AS VM_NAME ,VH.NAME AS [HOST_NAME] , DS.NAME

,((CONVERT(Bigint,DS.[CAPACITY]))/(1024*1024*1024)) as DataStoreCapacityGB

,((CONVERT(Bigint,DS.FREE_SPACE))/(1024*1024*1024)) as DataStoreFreeGB

FROM [VCDB].[dbo].[VPXV_VMS] AS VMS WITH (NOLOCK,NOWAIT)

       INNER JOIN [VCDB].[dbo].[VPXV_HOSTS] AS VH WITH (NOLOCK,NOWAIT)

       ON VMS.HOSTID = VH.HOSTID

       INNER JOIN [VCDB].[dbo].[VPXV_VM_DATASTORE] AS VD WITH (NOLOCK,NOWAIT)

       ON  VD.VM_ID = VMS.VMID

       LEFT OUTER JOIN [VCDB].[dbo].[VPX_DATASTORE] AS DS WITH (NOLOCK,NOWAIT)

       ON  DS.ID = VD.DS_ID 

WHERE DS.NAME Like '%DatastoreName%'

ORDER BY VMS.[NAME]

Thanks n Regards
Umesh Ahuja

If your query resolved then please consider awarding points by correct or helpful marking.
0 Kudos
Kahonu84
Hot Shot
Hot Shot

Have you tried RVTools?

0 Kudos