PowerCLI

 View Only
  • 1.  Problem with Get-Stats

    Posted Nov 15, 2012 12:41 AM

    Hi All,

    I am trying to run a basic cluster config & performance overview script. It's working to 80%. The issue that I have is running Get-Stat against 32 host clusters. It just never finishes.

    Can you review this code and see if its efficient and suggest why its not currently work and how I can change it.

    # Cluster Memory Usage as %
    $smem = $cluster | Get-Stat -Start $Start -Stat mem.usage.average | Measure-Object Value -ave
    $ClusterMemUsagePercent = "Cluster Average Memory Usage (%)"
    Add-Member -Inputobject $reportedCluster -MemberType noteProperty -name $ClusterMemUsagePercent -value $smem.average
    # Cpu Usage as %
    $scpu = $cluster | Get-Stat -Start $Start -Stat cpu.usage.average | Measure-Object Value -ave
        $ClusterCPUUsagePercent = "Cluster Average CPU Usage (%)"
    Add-Member -Inputobject $reportedCluster -MemberType noteProperty -name $ClusterCPUUsagePercent -value $scpu.average

    I have run this against small 3/4 host clusters and it returns in 4 mins. Doing the same against a 32 host cluster and it never finishes.

    Help!

    Thanks All.



  • 2.  RE: Problem with Get-Stats

    Posted Nov 15, 2012 05:58 AM

    You didn't say over which interval you collect the statistics and if the $cluster variable contains all 32 cluster objects, but the performance of the Get-Stat cmdlet depends on many factors.

    It can be the amount of data you want to retrieve, the performance of the client from where you run the cmdlet (especialy available memory), the responsiveness of the vCenter(s), the responsiveness of the DB engine where the statistics records are kept, ...

    Normally I advise to limit the number of Get-Stat calls and use the Group-Object cmdet to split out the results.

    But in this case, I would advise to combine the 2 metrics in 1 Get-Stat call and do a call for each cluster individually.

    If that returns in 3-4 minutes, as you say, you can try combining more clusters in 1 Get-Stat call.

    For a more profound analysis I would need to see the complete script and more details on where the most time is spend..



  • 3.  RE: Problem with Get-Stats

    Posted Nov 15, 2012 10:03 PM

    $cluster variable contains a single object as it part of a for loop.

    You're right I didn't set an interval. I was going to use whatever the default was as I'm only collecting an hours worth of stats. But I'll take your advice and set one to 10 mins as I only need a broad view of performance in this case.

    If I combine metrics into a single call I'm not sure how I access the resulting data. Right now it easy as it's in a specific variable.

    I'll have a read of the following : http://www.lucd.info/2011/07/08/powercli-vsphere-statistics-part-5-rollup-types/ (Nice work, thank you for sharing) and try and figure this out.

    You know how it is, too many work requests coming in to be able to put time aside and learn a little and then apply.

    Cheers Buddy.



  • 4.  RE: Problem with Get-Stats

    Posted Nov 15, 2012 10:23 PM

    Feel free to ask if you're stuck :smileyhappy: