PowerCLI

 View Only
  • 1.  How to get the list of VMhost CPU Ready

    Posted Aug 31, 2012 06:22 AM

    Hi,

    Can anyone please assist me in getting the report of VMHost CPU ready in total ?

    this is so that i know which ESX host got issue with CPU ready or overly allocated.

    Thanks.



  • 2.  RE: How to get the list of VMhost CPU Ready

    Posted Aug 31, 2012 06:36 AM

    Hi there,

      there was already a question like this previously, can you try out what Luc has written ?

    http://communities.vmware.com/thread/334185

    Greg



  • 3.  RE: How to get the list of VMhost CPU Ready

    Posted Aug 31, 2012 07:00 AM

    Hm...

    I got this error:

    $vm = Get-VMHost | Get-VM

    $metric = "cpu.ready.summation"

    $start = (Get-Date).AddDays(-1)

    $stats = Get-Stat -Entity $vm -Stat $metric -Start $start $stats | Group-Object -Property {$_.Entity.Host.Name} | %{

        New-Object PSObject -Property @{

            Name = $_.Group[0].Entity.Name

            CpuReadyAvg = ($_.Group | Measure-Object -Property Value -Average).Average

        }

    }

    Get-Stat : A positional parameter cannot be found that accepts argument '$null'.
    At C:\Users\Administrator\AppData\Local\Temp\c6aabbfa-38d0-4b26-9a48-5c2063eaf544.ps1:6 char:18
    + $stats = Get-Stat <<<<  -Entity $vm -Stat $metric -Start $start $stats | Group-Object -Property {$_.Entity.Host.Name} | %{
        + CategoryInfo          : InvalidArgument: (:) [Get-Stat], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats


  • 4.  RE: How to get the list of VMhost CPU Ready

    Posted Aug 31, 2012 07:18 AM

    $stats = Get-Stat -Entity $vm -Stat $metric -Start $start | Group-Object -Property {$_.Entity.Host.Name} | %{

        New-Object PSObject -Property @{

            Name = $_.Group[0].Entity.Name

            CpuReadyAvg = ($_.Group | Measure-Object -Property Value -Average).Average

        }

    }

    i was not writing this script, but i think you have to ream the $stat in the $stats = .....



  • 5.  RE: How to get the list of VMhost CPU Ready

    Posted Aug 31, 2012 07:51 AM

    I don't know how to get the cpu ready time for host. To be honest i am really green if it comes to counters. I checked this script :

    http://www.peetersonline.nl/2009/06/examine-vmware-cpu-ready-times-with-powershell/

    It was not working when copied/pasted.

    I did few modifications to it. First run it against 1 host

    You can then see if this suits you. If yes, then use only get-vmhost with no parameters, so it will download all esx hosts.

    After this is done you can do : $myCol |export-csv c:\file1111.csv

    $myCol = New-Object System.Collections.ArrayList
    ForEach ($VMHost in (Get-VMHost "1_vm_host_name"| Sort Name))
        {
        ForEach ($VM in ($VMHost | Get-VM | Sort Name))
            {
            # Gather Stats
            $Ready = $VM | Get-Stat -Stat Cpu.Ready.Summation -RealTime
            $Used = $VM | Get-Stat -Stat Cpu.Used.Summation -RealTime
            $Wait = $VM | Get-Stat -Stat Cpu.Wait.Summation -RealTime
            For ([int]$a = 0; $a -lt $VM.NumCpu; $a++)
                {
                $myObj = "" | Select VMHost, VM, Instance, %RDY, %USED, %WAIT
                $myObj.VMHost = $VMHost.Name
                $myObj.VM = $VM.Name
                $myObj.Instance = $a
                $myObj."%RDY" = [Math]::Round((($Ready | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1)
                $myObj."%USED" = [Math]::Round((($Used | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1)
                $myObj."%WAIT" = [Math]::Round((($Wait | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1)
                $myCol += $myObj
                }
            Clear-Variable Ready -ErrorAction SilentlyContinue
            Clear-Variable Wait -ErrorAction SilentlyContinue
            Clear-Variable Used -ErrorAction SilentlyContinue
            Clear-Variable myObj -ErrorAction SilentlyContinue
            }
        }



  • 6.  RE: How to get the list of VMhost CPU Ready

    Posted Sep 02, 2012 11:40 AM

    There could be several causes why you would get that error.

    Are you connected to a vCenter or an ESXi host when you run the script ?

    Were the VMs for which you query statistics active during the interval ? If the VM was powered off, there are no statistical data and you might see the error as well.

    Is there anything in the $vm variable ?