Performance Statistics (PowerCLI): Difference between revisions

From vwiki
Jump to navigation Jump to search
(Move of content from original PowerCLI/VIToolkit page)
 
m (Added Ad)
 
Line 1: Line 1:
{{#widget:Widget:GoogleAdSenseSkyscraper}}
The full wealth of performance metrics that are collated by virtual centre are available via the PowerCLI.  This can be very useful for creating custom reports, feeding data into other tools etc.
The full wealth of performance metrics that are collated by virtual centre are available via the PowerCLI.  This can be very useful for creating custom reports, feeding data into other tools etc.



Latest revision as of 12:28, 2 November 2016

{{#widget:Widget:GoogleAdSenseSkyscraper}} The full wealth of performance metrics that are collated by virtual centre are available via the PowerCLI. This can be very useful for creating custom reports, feeding data into other tools etc.

It's important to understand how ESX's generate and manage performance data before going any further...

  1. An ESX collects performance metrics every 20 sec (know as the Realtime interval), this is retained on the server for 1 hour.
  2. The ESX rolls the Realtime data up into 5 min interval data
    • [Stand-alone ESX] This 5 min data is retained for 1 day
    • [VC managed ESX] The data is uploaded to the VC database

Once in the Virtual Centre database, the data is then rolled up into Historical Interval tables via SQL jobs...

  • 5 min interval, 1 day retention
  • 30 min interval, 1 week retention
  • 2 hr interval, 1 month retention
  • 1 day interval, 1 year retention

Note that the following are configurable (to a varying degree) via the VI Client.

  • The VC rollup intervals and retention periods
  • The statistics depth (typically certain metrics are discarded as the retention period grows)

To see the available intervals for which metrics are available, use the following command (the results will vary depending on whether you're connected to an ESX or a Virtual Centre).

[vSphere PowerCLI] E:\> Get-StatInterval

Name                           SamplingPeriodSecs          StorageTimeSecs Client
----                           ------------------          --------------- ------
Past Day                                      300                    86400 VMware.VimAutomation....
Past Week                                    1800                   604800 VMware.VimAutomation....
Past Month                                   7200                  2592000 VMware.VimAutomation....
Past Year                                   86400                 31536000 VMware.VimAutomation....

Available Metrics

Metrics are available for all objects you'd expect (and probably more), not limited to the following...

  • Virtual Machines
  • Virtual machines Hosts (ESX's)
  • Resource Pools
  • Datastores

For a full list of what objects have what performance counters, and what those counters mean see http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.PerformanceManager.html.

The easiest way to ascertain what metric is available for what object is to use Get-StatType...

[vSphere PowerCLI] E:\> Get-VM "vm-server" | Get-StatType
cpu.usage.average
cpu.usagemhz.average
mem.usage.average
mem.granted.average
mem.active.average
...

[vSphere PowerCLI] E:\> Get-VMHost "esx-server*" | Get-StatType
cpu.usage.average
cpu.usagemhz.average
mem.usage.average
mem.granted.average
mem.active.average
mem.shared.average
mem.zero.average
mem.unreserved.average
...

In order to determine which sampling periods are available, you need to use the Get-StatInterval command. Remember that there is also the Realtime interval, at which all metrics are available. The results depend on whether you're connected to a Virtual Centre (and how its configured) or an ESX (and whether that's being managed by a VC)...

[vSphere PowerCLI] E:\> Get-StatInterval

Name                           SamplingPeriodSecs          StorageTimeSecs Client
----                           ------------------          --------------- ------
Past Day                                      300                    86400 VMware.VimAutomation....
Past Week                                    1800                   604800 VMware.VimAutomation....
Past Month                                   7200                  2592000 VMware.VimAutomation....
Past Year                                   86400                 31536000 VMware.VimAutomation....

However, just because a metric is available, doesn't make it available in the interval you'd like. In order to find out whether a statistic is available in the interval you'd like, you need to use the Get-StatType -Interval <secs/name> ...

[vSphere PowerCLI] E:\> Get-VMHost "esx-server*" | Get-Stat -MaxSamples 5 -IntervalSecs 300


MetricId                  Timestamp                                Value Unit
---------                 ----------                               ----- ----
cpu.usage.average         19/01/2010 09:15:00                       7.64 %
cpu.usage.average         19/01/2010 09:10:00                        6.5 %
cpu.usage.average         19/01/2010 09:05:00                       6.37 %
cpu.usage.average         19/01/2010 09:00:00                       6.39 %
cpu.usage.average         19/01/2010 08:55:00                       6.35 %
cpu.usagemhz.average      19/01/2010 09:15:00                        813 MHz
cpu.usagemhz.average      19/01/2010 09:10:00                        692 MHz
cpu.usagemhz.average      19/01/2010 09:05:00                        678 MHz
cpu.usagemhz.average      19/01/2010 09:00:00                        680 MHz
cpu.usagemhz.average      19/01/2010 08:55:00                        676 MHz
mem.usage.average         19/01/2010 09:15:00                      24.89 %
mem.usage.average         19/01/2010 09:10:00                      24.88 %
mem.usage.average         19/01/2010 09:05:00                      24.89 %
mem.usage.average         19/01/2010 09:00:00                       24.9 %
mem.usage.average         19/01/2010 08:55:00                      24.91 %
disk.usage.average        19/01/2010 09:15:00                        156 KBps
disk.usage.average        19/01/2010 09:10:00                        124 KBps
disk.usage.average        19/01/2010 09:05:00                        131 KBps
disk.usage.average        19/01/2010 09:00:00                        126 KBps
disk.usage.average        19/01/2010 08:55:00                        136 KBps
net.usage.average         19/01/2010 09:15:00                          7 KBps
net.usage.average         19/01/2010 09:10:00                          8 KBps
net.usage.average         19/01/2010 09:05:00                          7 KBps
net.usage.average         19/01/2010 09:00:00                          7 KBps
net.usage.average         19/01/2010 08:55:00                          7 KBps
sys.uptime.latest         19/01/2010 09:15:00                    5173577 second
sys.uptime.latest         19/01/2010 09:10:00                    5173277 second
sys.uptime.latest         19/01/2010 09:05:00                    5172977 second
sys.uptime.latest         19/01/2010 09:00:00                    5172677 second
sys.uptime.latest         19/01/2010 08:55:00                    5172376 second

A couple of final points to note

  • To retrieve data for the Realtime interval, use the -Realtime option, not -IntervalSecs 20
    • All Realtime metrics are averages (as they're an average over the sampling period)
  • Virtual Centre generally drops metrics during roll-ups etc (subject to configuration), therefore for the fullest range of metrics, use the Realtime interval.
    • I'd suggest always trying to go via the Virtual Centre, but the data you're after isn't available, check with the ESX direct.
  • Be careful when retrieving metrics that might have multiple instances (eg CPU), this is relatively obvious in vSphere as it'll show an instance column, not so in VI3. You can filter so as to see, for example, only the aggregate instance
    • get-vmhost "esx-server*" | get-stat -Stat cpu.usage.average -MaxSamples 1 -Realtime | Where{$_.Instance -eq ""}