Hi
I need help creating a script that extracts every recorded occurrence of VM CPU ready => 5% during the past 24 hours.
Example output:
DateTime | ClusterName | VMName | CPURdy |
---|---|---|---|
2015-06-16 03:40:00 | Cluster1 | VM1 | 6.2 |
2015-06-16 03:45:00 | Cluster1 | VM1 | 5.6 |
2015-06-16 08:15:00 | Cluster1 | VM1 | 7.6 |
2015-06-16 15:45:00 | Cluster3 | VM2 | 11.3 |
2015-06-16 19:05:00 | Cluster2 | VM3 | 8.1 |
I'm struggling to work out the most efficient way to do this, considering I need to pull this info daily from 100+ clusters and 20.000+ VM's.
Can anyone help?
Thanks,
Martin
You can try something like this
$start = (Get-Date).AddDays(-1)
$stat = 'cpu.ready.summation'
$tgtPCT = 0.1
$clusterName = 'MyCluster'
$vms = Get-Cluster -Name $clusterName | Get-VM
Get-Stat -Entity $vms -Stat $stat -Start $start -Instance '' |
Group-Object -Property {$_.Entity.Name} | %{
$_.Group | %{
$readyPCT = $_.Value/($_.IntervalSecs*100)
if($readyPCT -ge $tgtPCT){
$_ | Select Timestamp,
@{N='Cluster';E={$clusterName}},
@{N='VM';E={$_.Entity.Name}},
@{N='CPURdy';E={[math]::Round($readyPCT,1)}}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can try something like this
$start = (Get-Date).AddDays(-1)
$stat = 'cpu.ready.summation'
$tgtPCT = 0.1
$clusterName = 'MyCluster'
$vms = Get-Cluster -Name $clusterName | Get-VM
Get-Stat -Entity $vms -Stat $stat -Start $start -Instance '' |
Group-Object -Property {$_.Entity.Name} | %{
$_.Group | %{
$readyPCT = $_.Value/($_.IntervalSecs*100)
if($readyPCT -ge $tgtPCT){
$_ | Select Timestamp,
@{N='Cluster';E={$clusterName}},
@{N='VM';E={$_.Entity.Name}},
@{N='CPURdy';E={[math]::Round($readyPCT,1)}}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Many thanks LucD,
I'll try that out ASAP but have a couple of questions first please
1.
If I'd like to divide the cpu ready value with number of vCPU's assigned, would this change be correct?:
$readyPCT = $_.Value/($_.IntervalSecs*100)/$_.entity.numcpu
(I've read somewhere that the "aggregation instance CPU ready value" should be divided by the number of vCPUs. Aggregation CPU ready of 20% might be misleadingly bad on an 8 vCPU system (only 2.5% per vCPU). I might be wrong, what's your opinion?)
2.
If I run the same script against several clusters, would this change work?
@{N='Cluster';E={$_.entity.vmhost.parent.name}},
Thanks,
Martin
1. Yes and no.
The division is indeed is indeed required to get a better view on the overall RDY% for the VM.
But it would also be useful, in some cases, to check if there are 1 or more vCPU with high RDY%, while the rest of vCPU has a low RDY%.
This could be for example a single-threaded process running in the VM.
2. Yes, that should work
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Much appreciated, many thanks!