PowerCLI

 View Only
  • 1.  Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 01:48 PM

    I need to create e PowerCLI script to collect performance information (PCU, RAM, ...) about a (free) ESXi host and the guest VMs.

    Is there any sample I can start from?

    Regards

    marius



  • 2.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 02:02 PM

    An ESXi node keeps all Realtime performance data for +/- 1 hour.

    You should be able to retrieve those via the regular Get-Stat cmdlet.

    For example

    Get-Stat -Entity $esx -Stat 'cpu.usage.average' -Realtime -MaxSamples 10



  • 3.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 04:06 PM

    Thabnk you very muck.

    Let me ask another question: how can I connect to my (free) ESXi host?

    Can I use something like:

    $myfreeesxi = connect-viserver 192.1.68.1.1 -user "Root"

    Is it correct?

    Regards

    marius



  • 4.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 04:18 PM

    Let me try to put everything together:

    I wrote the following script:

    Add-PSSsnapin VMware.VimAutomation.Core

    $myesxi = Connect-Viserver 192.168.1.1 -user root

    $cpu = Get-Stat -entity $myesxi -Stat 'cpu.usage.average' - Realtime -maxsamples 1

    but there is something wrong with the -entity parameter....

    Can anybody please help?

    Regards

    marius



  • 5.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 05:16 PM

    The object returned by Connect-VIServer is not an object type that is accepted by the Entity parameter on the Get-Stat cmdlet.

    You could do:

    $esx = Get-VMHost 192.168.1.1

    $cpu = Get-Stat -entity $esx -Stat 'cpu.usage.average' - Realtime -maxsamples 1



  • 6.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 09:09 PM

    How can I authenticate to my ESXi host?



  • 7.  RE: Collecting performance data from a free ESXi host

    Posted Jan 27, 2015 09:17 PM

    With the root account from the ESXi server



  • 8.  RE: Collecting performance data from a free ESXi host

    Posted Jan 28, 2015 10:45 AM

    Thank you for the whole of your help.

    I am a PowerCLI novice, so I tryied all the possible syntaxes I can imagine with no success...

    Can anybody please help providing a working sample based on a free ESXi hos?

    Regards

    marius



  • 9.  RE: Collecting performance data from a free ESXi host
    Best Answer

    Posted Jan 28, 2015 12:13 PM

    Does this work ?

    Try {

      Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction Stop

    }

    Catch{

      Add-PSSnapin VMware.VimAutomation.Core

    }

    Connect-Viserver -Server 192.168.1.1 -user root | Out-Null

    $esx = Get-VMHost

    Get-Stat -entity $esx -Stat 'cpu.usage.average' -Realtime -MaxSamples 1

    Disconnect-VIServer -Server 192.168.1.1