An important statistic to always be aware of is CPU Ready Time.

CPU Ready Time is the amount of time a VM is ready with a workload to use CPU but has to wait to be assigned a slot on the actual hardware CPU. Having a High CPU time can mean you have a host that is under CPU Contention.

CPUGUI

Looking at the pic above, that is the CPU Ready of a VM over the past week. On average, it seems this VM has to wait over 1 second(>1000ms) each time it wants to use CPU cycles. That kind of seems like a lot to me.

But we have to rememeber that the above is a sample taken over a period of time so all is not as it seems. A better way is to look at the CPU Ready Percentage….it involves math 🙂

Straight from a KB Article:

To calculate the CPU ready % from the CPU ready summation value, use this formula:

(CPU summation value / (<chart default update interval in seconds> * 1000)) * 100 = CPU ready %

Perfect sense right!!! Maybe not so let’s do it with our example

(1421/1800 seconds * 1000)*100= .08%(rounded)

So around .08% of time it has to wait for CPU resources. Said a different way 99.02% of the time it doesn’t have to wait.

This means that despite what we may have concluded just by looking at the summation value, this VM almost never has to wait on CPU resources, which is good!

So let’s look at the PowerCLI


param($vms="*", $interval)
 Switch ($interval)
 {
 "day" {$days=-1;$mins=5;$divider=3000}
 "week" {$days=-7;$mins=30;$divider=18000}
 "month" {$days=-30;$mins=120;$divider=72000}
 }

$groups=Get-Stat -Entity (get-vm $vms ) -Stat cpu.ready.summation -start (get-date).adddays($days) -finish (get-date) -interval $mins -instance "" -ea silentlycontinue|group entity

$output=@()

ForEach ($group in $groups)
 {
 $temp= ""|select-Object Name, "Ready%"
 $temp.name=$group.name

$temp."ready%"= “{0:n2}” -f (($group.group |measure-object value -ave).average/$divider)

$output+=$temp
 }

$output

It is pretty straightforward. You give it a vm/vms, or it will grab all of them. You give the script an interval: day, week,month. Then it is on its way. Be warned any time you are grabbing stats with PowerCLI it might take a while. This becomes even more true for the number of VMs you are grabbing stats for….

CPUCLI

Hope this helps and here are two places you can get even more info!

CPU Ready Time in VMware and How to Interpret its Real Meaning

Converting between CPU summation and CPU % ready values


11 Comments

Cedric · December 18, 2013 at 9:42 am

Hi,
thanks for this script.
Ready summation is also given for an ESXi… Is it like the worst CPU Ready VM stat ? Is it maximum or average.
It would be easier for us to look at ESXi to get contention evolution.

Cedric.

    C-Rad · February 19, 2014 at 1:01 pm

    Cedric, I am not sure I understand your question…

JC · February 12, 2014 at 4:09 am

Very useful thanks. Can you tell me how it could be modified so it can be run with a vmname as a switch? i.e .\getcpuready -interval week -server “servername”

    C-Rad · February 19, 2014 at 1:01 pm

    ./getcpuready -vms vmname1,vmname2 -interval week

    It is already built in, by default it just does all vms 🙂

Ducrocq · November 25, 2014 at 5:33 am

Hi,
I don’t understand, i’ve got error : “param not recognized”
I’m noobs on powershell.
Could you help me ?
Regards

    C-Rad · March 27, 2015 at 9:24 am

    When you grabbed the script, are you sure you also grabbed the first line of it?

      GSXRMAN · October 3, 2015 at 12:57 am

      Sorry, I’m a noob at this…so when you say give it a vm/vms I’m a little confused. I’m trying to feed it two or more like this “linuxabc,unixbca” it its not liking that format, any suggestions as to what I’m doing wrong?
      example
      you – param($vms=”*”, $interval)
      me – param($vms=”linuxabc,unixbca”, $interval)

        C-Rad · October 3, 2015 at 3:33 pm

        So when you run it like the screenshot I posted, you don’t need to change anything, just run it like

        .\cpuready.ps1 -vms ”linuxabc”,”unixbca”

        That should make it work.

        The vms=”*” is the script just acts as a default value when the script is run in case a value isn’t specified.

        Hope that helps!

          GSXRMAN · October 5, 2015 at 5:40 pm

          That totally did, thanks so much. We have over 7K hosts yup hosts and looking at CPUReady from an Application perspective vrs an Administrator view helps…the admins are after overall whereas I’m targeting a handful like 20 servers that could be on any number of hosts, clusters, vCenters and so on…so I’m logging on to about 5 vCenters and issuing commands to capture data for thoes servers, thanks for the assistance….

Christopher A Albert · May 14, 2020 at 2:11 pm

How would you run this on an entire cluster?

    C-Rad · June 10, 2020 at 12:10 pm

    If you run it as is, it will run against all VMs in the cluster

Leave a Reply