Getting current CPU usage for vCloud Director Organization VDC

In vCloud API (via REST, vCO PlugIn, or PowerCLI) you can query CPU, memory and disk usage for VDCs. However, when retrieving the values for current CPU usage you always get ‘0’ – regardless of real current usage.

PS > $Ovdc| fl * -force
Href : https://vCloud/api/admin/vdc/deaddead-dead-dead-dead-deaddeaddead
AllocationModel : AllocationPool
Enabled : True
ProviderVdc : PvDC-Site-01
Org : Appclusive
CpuUsedGhz : 0
CpuLimitGhz : 5
CpuAllocationGhz : 5
CpuOverheadGhz : 0
MemoryUsedGB : 2.1298828125
MemoryLimitGB : 10
MemoryAllocationGB : 10
MemoryOverheadGB : 0
StorageUsedGB : 303
StorageLimitGB : 500
StorageAllocationGB : 500
StorageOverheadGB : 0

Values for memory and storage seem correct.

There is a workaround for this via querying the underlying vCenter resource pool for that VDC. You can get the vCenter resource pool easily as described in my earlier post. And from there it is just another call:

PS > $resPoolVc.ExtensionData.Summary.Runtime.Cpu
ReservationUsed : 0
ReservationUsedForVm : 0
UnreservedForPool : 0
UnreservedForVm : 0
OverallUsage : 68
MaxUsage : 5000
DynamicType :
DynamicProperty :

The number shown is measured in MHz.

According to VMware (see SR 13288663402) this is not a bug in vCD but a consequence of the underlying OvDC characteristics. Please read and judge for yourself:

I further had a discussion with engineering. They informed us that in 5.1/5.1.1 environment, the allocation pool model by default is elastic. Thus, you will be able to fetch CPU usage values in 5.1/5.1.1 environment.

 

To further elaborate on this, below are three types of allocation model in vCD:

1: Pay As You Go

2: Allocation Pool Model

3: Reservation Pool Model

 

Below are the calculations how CPU used is computed for different types mentioned above:

1: Pay As You Go

CPU used = vcpu_count * ovdc_vcpu_in_mhz

 

where,

ovdc_vcpud_in_mhz is vcpu speed given for the OVDC

vcpu_count is only for the powered on VMs. It is taken for all powered on VMs in the OVDC.

 

2: Allocation Pool Model

In 1.5.x, this is 0 as this model is not elastic.

In 5.1/5.1.1, this model by default is elastic. The CPU used is reported in this model similar to Pay as you go model.

In upcoming update release of vCD, one will be able to turn off the elasticity of allocation pool VDCs. The non-elastic allocation pools will behave similar to how they do on 1.5.

 

3: Reservation Pool Model

This is mapped to runtime.cpu.reservationUsed in vSphere environment

 

Thus, based on different models above, appropriate value will be displayed in vCD GUI, and correspondingly can be fetched through APIs/SDK.

 

As of now, the above information is not available in form of documentation. I have already submitted a feedback to our documentation team to incorporate above details in our guides. This is presently under review by them.

 

Comments

  1. zelig8 says:

    Hi Ronald;
    thanks for this post! this question might have an obvious answer, and if so i apologize but how did you find the storage usage in your output? a Get against the vdc in my case shows the storage profiles associated with the org, and gets against those vdcStorageProfiles show the allocation, but i don’t see where you can get the amount used against that allocation.

    • Ronald Rink says:

      The example was performed on a vCloud Director without storage profiles. That is probably why you get different results. I currently cannot tell you by heart how to resolve that call with storage profiles and have no access to a vCD with profiles but will have a look tomorrow. I will let you as soon as I know. Regards, Ronald

      • zelig8 says:

        Thanks Ronald i appreciate your reply and any information you can provide! I imagine this must be possible to collect, as you can view allocation usage through the vCD web interface for each organization vdc from Administration/monitor/storage. I hope they are not adding up all of the storage provisioned to each vApp to get the totals displayed.

      • Ronald Rink says:

        My colleague checked and confirmed that you can still get the actual used amount of storage when you look at the properties of an Organisational DataCenter via Get-OvDC. The cmdlet seems to sum up all the information of different storage tiers. Which call did you actually execute where you did not get the expected results?

      • zelig8 says:

        Hi Ronald – i’m doing a GET on a specific org vDC (../api/vdc/XXXX). what i see in the result is a block that shows the storage profiles allocated to the vDC, but not the specific allocation or usage amount. Performing a get on those specific VdcStorageProfiles for the org vDC returns a block that shows the amount of the allocation to the org vDC, but i don’t see the usage against that allocation. My apologies if i’ve overlooked something, as i’m fairly new to working with the API.

      • Ronald Rink says:

        No I seem to understand what you are trying to do. In my example I just executed the PoweCLI cmdlet. But you are executing the diect REST call. so it seems that the PowerCLI Cmdlet resolves and calucates this automatically for you. So I suggest you run sth like Fiddler to see the actual REST calls in the background so that you can do the same coding in your REST script.

      • zelig8 says:

        ah, i see, i will do just that. Thank you Ronald, i truly appreciate your help and again, thank you for this post!

  2. zelig8 says:

    I mean to include in that last post that the second get against the org vDCs storage profile returns the allocation in a tag which displays the organizations allocation from the specific storage profile, but again nothing about actual usage against the allocation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: