When checking a customers environment, I discovered a strange GUI issue in vCenter regarding CPU shares for a VM. I usually use a PowerShell script to check if the customer has set any limits, reservations or changed the default shares settings. With this customer I received a number of warnings about shares. I received the following output:
You can see that according to the PowerShell query, the VM cs01 has 1 vCPU and 2000 shares. When the default setting of “normal” would be used, the 1 vCPU VM would have 1000 shares. For a 2 vCPU VM this would be 2000 shares, 4 vCPU VM would be 4000 shares, etc. In the vCenter properties of the VM however, it shows as 1000 shares and a setting of “normal”.
When I change this setting to “High”, click OK and then again change them to “Normal”, it now shows correctly in both vCenter GUI and in the PowerShell output:
Just a small quirk, but something to pay attention to when visually checking if all shares are set properly.
Below is the PowerShell script I used to perform the check. Credits for the script go to Mr. Alan Renouf and his VMware Community PowerPack. I only added the CPUOK and MEMOK columns.
Foreach ($VM in (Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} | Sort Name)){ $Details = "" |select-Object VMName, CPUReservation, CPULimit, CPUShares, CPUNum, CPUOK, MEMSize, MEMReservation, MEMLimit, MEMShares, MEMOK $Details.VMName = $VM.Name $Details.CPUReservation = $VM.Config.CpuAllocation.Reservation If ($VM.Config.CpuAllocation.Limit -eq "-1"){ $Details.CPULimit = "Unlimited" } Else { $Details.CPULimit = $VM.Config.CpuAllocation.Limit } $Details.CPUShares = $VM.Config.CpuAllocation.Shares.Shares $Details.CPUNum = $VM.Config.Hardware.NumCPU If ( ($Details.CPUNum * 1000) -eq $Details.CPUShares) { $Details.CPUOK = "OK" } else { $Details.CPUOK = "Not default" } $Details.MEMSize = $VM.Config.Hardware.MemoryMB $Details.MEMReservation = $VM.Config.MemoryAllocation.Reservation If ($VM.Config.MemoryAllocation.Limit -eq "-1"){ $Details.MEMLimit = "Unlimited" } Else{ $Details.MEMLimit = $VM.Config.MemoryAllocation.Limit } $Details.MEMShares = $VM.Config.MemoryAllocation.Shares.Shares if ( ($Details.MEMShares / $Details.MEMSize ) -eq 10) { $Details.MEMOK = "OK" } else { $Details.MEMOK = "Not default" } $Details.PSTypeNames.Clear() $Details.PSTypeNames.Add('Virtu-al.PowerPack.VMRSL') $Details.PSTypeNames.Add('Virtu-al.PowerPack.VM') $Details }