Quick and simple VMware ESX Host Statistics

Just a small oneliner to display all the servers, their overall status, CPU and Memory usage in all your Datacenters (can be handy if you have multiple datacenters).

Get-Datacenter | Sort | Get-VMHost | Sort | Get-View |`
Select Name, OverallStatus, `
@{N="CPU Usage (GHz)";E={[math]::round(
$_.Summary.QuickStats.OverallCpuUsage/1024,2)}}, `
@{N="Memory Usage (GB)";E={[math]::round(
$_.Summary.QuickStats.OverallMemoryUsage/1024,2)}} 

And it will give you an output that looks like this:

image

You may not find it very useful like this, but you can also add a Where statement to this line to filter on several things. For example, you can decide you only want to see the servers that have yellow or red Overall Status due to high memory or CPU usage:

Get-Datacenter | Sort | Get-VMHost | Sort | Get-View | `
Select Name, OverallStatus, `
@{N="CPU Usage (GHz)";E={[math]::round(
$_.Summary.QuickStats.OverallCpuUsage/1024,2)}}, `
@{N="Memory Usage (GB)";E={[math]::round(
$_.Summary.QuickStats.OverallMemoryUsage/1024,2)}} | `
Where { $_.OverallStatus -ne "green" }

Which will give you something like this:

image

Ofcourse these onliners are cool and handy to use, but you can also use these oneliners to write a script around it to monitor your servers. I will post a script like that soon to show you different interpretations of this script.

    • Robin
    • August 16th, 2011 8:43am

    Hi,

    Very nice skript.
    Is it also possible to get the Cluster from this VM Host in the same skript?
    So that i have the rows: VMHostName, ClusterName, OverallStatus, CPU Usage, Memory Usage

    And it would be also great if i have a row with Host count.

      • Robin
      • August 16th, 2011 10:00am

      Get-Datacenter | Sort | Get-Cluster | Sort | Get-VMHost | Sort | Get-View | `
      Select Name, OverallStatus, `
      @{N=”CPU Usage (GHz)”;E={[math]::round(
      $_.Summary.QuickStats.OverallCpuUsage/1024,2)}}, `
      @{N=”Memory Usage (GB)”;E={[math]::round(
      $_.Summary.QuickStats.OverallMemoryUsage/1024,2)}}, `
      @{N=”Cluster”;E={get-cluster -vmhost $_.Name}}

    • Kris
    • September 9th, 2011 2:03pm

    This script definitely good. But some information missing. It would be great if the output has total CPU and Total Memory along with the current utilization.

    Br,

  1. No trackbacks yet.