Block device performance

OpenLMI-Storage provider reports I/O statistics of all block devices. Every instance of CIM_StorageExtent or its subclass has associated LMI_BlockStorageStatisticalData instance, which reports current I/O statistics like nr. of kbytes read/written etc.

Following instance diagram shows two block devices and their associated statistics:

There are many more classes related to block device performance, but these are provided mainly for compatibility with SMI-S. See following instance diagram, which shows the same two block devices, but now with all SMI-S classes:

The only useful method is LMI_BlockStatisticsService.GetStatisticsCollection, which returns I/O statistics of all block devices as semicolon-separated-list. The order of fields in this list is described in LMI_BlockStatisticsManifest.CSVSequence property.

Note

Even though properties in LMI_BlockStorageStatisticalData are 64-bit, they are tracked as 32-bit on 32-bit systems like i686 or ppc by Linux kernel. They can wrap pretty quickly on modern hardware.

For example, with iSCSI drive on 10Gb/s link, the KBytesRead counter can wrap in around 27 minutes.

On 64-bit systems, these counters are tracked in 64-bits in Linux kernel and they wrap once in a few years.

Useful methods

LMI_BlockStatisticsService.GetStatisticsCollection

Return I/O statistics of all block devices as CSV-formatted string. (CSV = semicolon-separated list).

Note that this method is currently synchronous and does not return a Job.

Use cases

Note

All example scripts expect properly initialized lmishell.

Get I/O statistics of a block device

Find LMI_BlockStorageStatisticalData associated to appropriate CIM_StorageExtent:

# Find the /dev/sda3 device
sda3 = ns.CIM_StorageExtent.first_instance({"Name": "/dev/sda3"})

# Find its statistics
stat = sda3.first_associator(ResultClass="LMI_BlockStorageStatisticalData")
print "KBytesRead:", stat.KBytesRead

Get I/O statistics of all block devices I

Enumerate all LMI_BlockStorageStatisticalData instances on the system:

# Find all LMI_BlockStorageStatisticalData instances
stats = ns.LMI_BlockStorageStatisticalData.instances()
for stat in stats:
    print "Device", stat.ElementName, "KBytesRead:", stat.KBytesRead

This approach can return huge list of LMI_BlockStorageStatisticalData instances on systems with lot of block devices.

Get I/O statistics of all block devices II

Use LMI_BlockStatisticsService.GetStatisticsCollection method to get all statistics in one method call:

# Print column headers
manifest = ns.LMI_BlockStatisticsManifest.first_instance()
print ";".join(manifest.CSVSequence)

# Print the real data
service = ns.LMI_BlockStatisticsService.first_instance()
(ret, outparams, err) = service.GetStatisticsCollection()
stats = outparams['Statistics']
for stat in stats:
    print stat

Note that this method is currently synchronous and does not return a Job.