Difference between revisions of "Script Extracts and Examples (PowerCLI)"

Jump to navigation Jump to search
m
→‎Performance Stats: Added intro and "Available Metrics"
m (→‎ESX Host: Added VML)
m (→‎Performance Stats: Added intro and "Available Metrics")
Line 129: Line 129:
|}
|}


== Performance Stats ==
== Performance Statistics ==
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.
It's important to understand how ESX's generate and manage performance data before going any further...
# An ESX collects performance metrics every 20 sec (know as the Realtime interval), this is retained on the server for 1 hour.
# 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).
<source lang="powershell">[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....</source>
=== Available Metrics ===
Metrics are available for each of the following types of object
* Virtual Machines
* Virtual machines Hosts (ESX's)
* Resource Pools
* Datastores
The easiest way to ascertain what metric is available for what object is to use Get-StatType...
<source lang="powershell">[vSphere PowerCLI] E:\> Get-vm "winstg" | Get-StatType
cpu.usage.average
cpu.usagemhz.average
mem.usage.average
mem.granted.average
mem.active.average
mem.shared.average
mem.zero.average
mem.swapped.average
mem.swaptarget.average
mem.swapin.average
mem.swapout.average
mem.vmmemctl.average
mem.vmmemctltarget.average
mem.overhead.average
disk.usage.average
net.usage.average
sys.uptime.latest
sys.heartbeat.summation
mem.consumed.average
[vSphere PowerCLI] E:\> Get-vmHost "uklonesxt1*" | 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
mem.swapused.average
mem.sharedcommon.average
mem.heap.average
mem.heapfree.average
mem.state.latest
mem.swapin.average
mem.swapout.average
mem.vmmemctl.average
mem.overhead.average
disk.usage.average
net.usage.average
sys.uptime.latest
clusterServices.cpufairness.latest
clusterServices.memfairness.latest
cpu.reservedCapacity.average
mem.reservedCapacity.average
mem.consumed.average
mem.sysUsage.average</source>


== Script Extracts ==
== Script Extracts ==

Navigation menu