VMware {code} Community
TomKol
Contributor
Contributor
Jump to solution

Mapping between instance in metric and VirtualDevice

Hi,

does anyone know how to map instance attribute in PerfMetricId to VirtualDevice?

I need to call QueryPerf for virtual disk in VM. I do not know what to fill in instance attribute in PerfMetricId that I fill in PerfQuerySpec. I tried to put there filename of virtual disk but it does not return anything.

Enumeration of available metrics show instances for disk counters like: t10.ATA_____WDC_WD1600HLFS2D75G6U0________________________WD2DWXL908009625

but filename, that looks like some id is: \[templates-datastore] test/test.vmdk

Where can I get instance id for Virtual disk or how QueryPerf process instance attribute?

Thanks,

Tomas

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
dmitrif
Enthusiast
Enthusiast
Jump to solution

Tomas,

When you go through collection of virtual machine virtual devices and identify that this device a virtual disk, you can collect its property of VirtualDeviceFileBackingInfo type that points to a datastore.

The datastore has information about volumes, this is HostVmfsVolumeInfo type property in case of VMFS, and that points to a partition name.

VirtualDisk -> FileBackingInfo -> Datastore -> VolumeInfo -> the partition name.

The partition name + number -> the partition name - > VirtualDisk := number.

This partition name that you receive along with the performance metric number uniquely identifies the virtual disk. I look at it as a "slice" of the whole partition data that belongs to a particular virtual disk.

For a different virtual machine you might receive the same pair (partition name + number) but that would be a different virtual disk, the disk that belongs to that virtual machine.

I wish I could share something simpler and of course I cannot guarantee it will fit your particular situation. Yes, the code to handle it is not primitive.

BTW, there is no reliable way to generate a unique key for a virtual disk or other virtual device. I use a combination of datastore name, partition and device index (looks like "My Store 1-vmhba33:2:31-2000"). And repopulate related internal structures when I detect changes in virtual device indexes.

Alright, I better stop now before I get carried away and start publishing my company's "know-how" ;-).

Cheers,

Dmitri

D.

View solution in original post

Reply
0 Kudos
6 Replies
lamw
Community Manager
Community Manager
Jump to solution

The Disk I/O metrics is at a per device/LUN level, it does go down to the VMDK level. If you're looking for some basic IO metrics, you may want to look at vscsiStats: http://communities.vmware.com/docs/DOC-10095

There are no APIs for accessing this data, it's executed on the classic Service Console of ESX or busybox console for ESXi

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

specify it as all: "*"

then you'll receive values for each disk separately

the instance name will be the partition name from HostVmfsVolumeInfo the virtual disk associated with

by matching these values you can figure out what virtual disk this performance metric is from.

notice that this is applicable only to VMFS volumes

D.
TomKol
Contributor
Contributor
Jump to solution

Dmitrif,

that was very helpful, but I do not undestand how can I associate it vith VirtualDisk. I know filename that looks like \[datastore] test/test.vmdk. And now I know that this datastore has partitions that really looks like instances in metrics. But I do not see what attribute should I use to associate partition to VirtualDisk. I did not find filename in partition.

Or if I have two VirtualDisk on the same partition, I am not able to measure these separatelly? Metrics are just for partitions?

Thanks a lot

Tomas

Reply
0 Kudos
dmitrif
Enthusiast
Enthusiast
Jump to solution

Tomas,

When you go through collection of virtual machine virtual devices and identify that this device a virtual disk, you can collect its property of VirtualDeviceFileBackingInfo type that points to a datastore.

The datastore has information about volumes, this is HostVmfsVolumeInfo type property in case of VMFS, and that points to a partition name.

VirtualDisk -> FileBackingInfo -> Datastore -> VolumeInfo -> the partition name.

The partition name + number -> the partition name - > VirtualDisk := number.

This partition name that you receive along with the performance metric number uniquely identifies the virtual disk. I look at it as a "slice" of the whole partition data that belongs to a particular virtual disk.

For a different virtual machine you might receive the same pair (partition name + number) but that would be a different virtual disk, the disk that belongs to that virtual machine.

I wish I could share something simpler and of course I cannot guarantee it will fit your particular situation. Yes, the code to handle it is not primitive.

BTW, there is no reliable way to generate a unique key for a virtual disk or other virtual device. I use a combination of datastore name, partition and device index (looks like "My Store 1-vmhba33:2:31-2000"). And repopulate related internal structures when I detect changes in virtual device indexes.

Alright, I better stop now before I get carried away and start publishing my company's "know-how" ;-).

Cheers,

Dmitri

D.
Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Here's a script that does the mapping:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

TomKol
Contributor
Contributor
Jump to solution

Thank you so much all of you. Now it is more clear to me.

Tomas

Reply
0 Kudos