In my previous article, I talked about the new Service Manager API that was introduced in vSphere 5.1 and how you can retrieve ESXTOP performance data using this new vSphere API. In this article I will show you how to collect vscsiStats data using this same interface. If you are not familiar or have not used vscsiStats before, I would highly recommend you take a look at the Using vscsiStats for Storage Performance Analysis as it goes over some of the basics of vscsiStats and how it works.
Disclaimer: You should try to limit the use of these interfaces for statistics collection or debugging/troubleshooting purposes as there is a certain amount of overhead when running these commands. It is also important to note that since the output is based on the implementer of the service, there is no guarantee that output would not change from one release to the other.
The first step is to get a reference to the vscsiStats service via the Service Manager (must connect directly to an ESXi 5. host, this is not supported when connecting to vCenter Server) and to invoke an operation for vscsiStats, you will need to use the ExecuteSimpleCommand. For vscsiStats, there are four valid operations:
To demonstrate the vscsiStats interface, I have written a sample vSphere SDK for Perl script called getVscsiStats.pl which I will use to explain each operation. Please note the data set that is retrieved is in it’s raw data form and requires a bit of data processing.
This operation starts the vscsiStats collection for ALL virtual machines residing on your ESXi hosts. This is exactly the same operation if you were to only specify the -s option to the vscsiStats command-line. Here is a screenshot of the “start” operation implemented in the script:
You should see a response of OK from the output and this would indicate the vscsiStats collection has started.
- VM Display Name
- VM VMX Configuration Path
- VM BIOS UUID
- vCenter Server UUID
This is then followed by the
VSCSIVsi_DistanceHistogram: Histogram: distance (in LBNs) between successive commands
- VSCSIVsi_DistanceLast16Histogram: Histogram: distance (in LBNs) between each command from the closest of previous 16
- VSCSIVsi_DistanceReadsHistogram: Histogram: distance (in LBNs) between successive Read commands
- VSCSIVsi_DistanceWritesHistogram: Histogram: distance (in LBNs) between successive Write commands
- VSCSIVsi_IoLatencyHistogram: Histogram: latency of IOs in Microseconds (us)
- VSCSIVsi_IoLatencyReadsHistogram: Histogram: latency of Read IOs in Microseconds (us)
- VSCSIVsi_IoLatencyWritesHistogram: Histogram: latency of Write IOs in Microseconds (us)
- VSCSIVsi_IoLengthHistogram: Histogram: IO lengths of commands
- VSCSIVsi_IoLengthReadsHistogram: Histogram: IO lengths of Read commands
- VSCSIVsi_IoLengthWritesHistogram: Histogram: IO lengths of Write commands
- VSCSIVsi_OutstandingIOsHistogram: Histogram: number of outstanding IOs when a new IO is issued
- VSCSIVsi_OutstandingIOsReadsHistogram: Histogram: number of outstanding Read IOs when a new Read IO is issued
- VSCSIVsi_OutstandingIOsWritesHistogram: Histogram: number of outstanding Write IOs when a new Write IO is issued
- Histogram: latency of IO interarrival time in Microseconds (us)
- Histogram: latency of IO interarrival time for Reads in Microseconds (us)
- Histogram: latency of IO interarrival time for Writes in Microseconds (us)
This operation will reset the vscsiStats collection similar to the -r option in the vscsiStats command-line. Here is a screenshot of the “reset” operation implemented in the script:
This operation will stop the vscsiStats collection similar to the -x option in the vscsiStats command-line. Make sure you perform this operation once you are done retrieving your vscsiStats data. Here is a screenshot of the “stop” operation implemented in the script:
In addition to the four operations, you can also save the output to a file by specifying the –output option along with the name of the file. vscsiStats is an extremely useful tool to help vSphere administrators profile their virtual machine’s IO workload and now you can easily collect this information using the vSphere API. Some really cool things you can do with this data is to create some nifty graphs such as the ones here and here.