Hi, I'm sure this is quite simple but I can't figure it out:
In my case, I want to count how many vCPU's are used up in a farm managed by vCenter. I go about finding the Powered On VM's as such:
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"}
(My thanks to Ricky El-Qasem http://read.virtualizeplanet.com)
So this gives me a listing of all powered on VM's, broken down in the following columns:
Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
VM1... PoweredOn 4 1024
VM2... PoweredOn 2 1024
VM3... PoweredOn 1 1024
So my question is: how can I then add up the values in Num CPUs to get me the total number of vCPUs currently used?
Thanks in advanced.
You can get the total number of vCPU's with:
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Measure-Object -Property NumCPU -Sum
Regards, Robert
You can get the total number of vCPU's with:
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Measure-Object -Property NumCPU -Sum
Regards, Robert
Worked like a beaut! Thanks.
Hi, is it possible to get the NumCpu over a period of time (from the past)?
I understand that NumCpu is returned via Get-VM and Get-VM returns data regarding the VM's current state (obviously). I haven't come across any forums/posts on how to do this or if it's even possible?
I have a basic script that generates a report with various stats ("cpu.usage.average","mem.active.average",etc) and I wanted to add a NumCpu entry as well. The script gets stats for a specified date range
$report = Get-Stat -Entity $entities -Stat $metrics -Start $startDate -Finish $endDate | `
Group-Object -Property EntityId,Timestamp | %{
New-Object PSObject -Property @{
NoOfCpu = $_.Group[0].Entity.NumCpu
}
}
The above code does not return NumCpu stats from the past.
Thanks in advance,
Regards