Hi,
My environment is vCenter Server 4, vSphere ESX 4, and PowerCLI 5.1
Right now I am gathering the resource pool cpu performance data using powercli for a monthly performance report..
I use the get-stat command to obtain the data and then export that into a csv file.
When I look at the data I retrieved and compare it with the performance report which you can generate from the vCenter GUI, the data is inconsistent. I get about twice as much MHz from the get-stat command then that of the vCenter report. Why does this happen and is there a way to correct this problem? Maybe my commands aren’t right….
Here are the commands I use to get resource pool cpu performance.
$midnight = (Get-Date -Hour 0 -Minute 0 -Second 0)
$rp1 = Get-ResourcePool -Location cluster1
$metrics = "cpu.usagemhz.average"
Get-Stat -Entity ($rp1) -Stat $metrics -Start $midnight.adddays(-1).addminutes(-1) -Finish $midnight.addminutes(-1) | Select-Object timestamp,value,unit,metricid,entity | Export-Csv "C:/csvfiles/file1.csv"
any help would be appreciated!
My original reply was wrong, there are of course no Instances for CPU usage for resourcepools.
Can you include some data you retrieved with Get-Stat and a sample screenshot from the Performance tab ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did some further research, and I can confirm that the metrics returned by Get-Stat are incorrect for a resourcepool.
I queried the same counters over the same interval for several resourcepools with my Get-Stat2 function, and the returned metrics corresponded with what one sees in the Performance tab. The metrics returned by Get-Stat are indeed nearly twice as high.
Looks like you discovered a bug :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD, thank you for the reply.
So I guess making a resource pool monthly report based on data from get-stat won't be reliable at all...
or I could make an approximate report by dividing the result data by two.
I hope they fix this bug.
Until this is fixed you could use my Get-Stat2 function :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I was looking at your "Get-Stat2" but can't make heads or tails because of my lack of comprehension....
Do you mean all I have to do is set all the variables in the first param block and i'm all set??
What would I have to do if I wanted to do the following.
1. Stat data on specific resource pool on a specific cluster.
2. Data worth one whole day
3. the stat string would be "cpu.usagemhz.average" because it would be a resource pool
4. data interval would be 300 seconds
thank you.
First thing you'll have to do, before calling the Get-Stat2 function, is to make the function known to PowerShell.
There are a couple of methods to achieve this.
One of these is to copy the function into a .ps1 file, and then add your call at the end of this .ps1 file.
Then you call the .ps1 file from the PowerCLI prompt.
Attached a sample .ps1 file that gets the statistics for the full previous day
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference