Obtaining Disk I/O Statistics
The virtual machine disk I/O statistics are obtained using the PrlVm_GetPerfStats function. The function is a part of the PHT_VIRTUAL_MACHINE handle.
The PrlVm_GetPerfStats function obtains a handle of type PHT_EVENT . The objects referenced by PHT_EVENT handle can contain one or more PHT_EVENT_PARAMETER objects, each of which is used as a container for a particular type of performance statistics. Statistics are identified by a corresponding performance counter which name is also contained in the PHT_EVENT_PARAMETER container. The following disk I/O performance counters are available:
Counter Name
|
Description
|
PRL_IDE_READ_REQUESTS_PTRN
|
Total count of read requests to IDE controller.
|
PRL_IDE_READ_TOTAL_PTRN
|
Total count of bytes read through IDE controller.
|
PRL_IDE_WRITE_REQUESTS_PTRN
|
Total count of write requests to IDE controller.
|
PRL_IDE_WRITE_TOTAL_PTRN
|
Total count of bytes written through IDE controller.
|
PRL_SCSI_READ_REQUESTS_PTRN
|
Total count of read requests to SCSI controller.
|
PRL_SCSI_READ_TOTAL_PTRN
|
Total count of bytes read through SCSI controller.
|
PRL_SCSI_WRITE_REQUESTS_PTRN
|
Total count of write requests to SCSI controller.
|
PRL_SCSI_WRITE_TOTAL_PTRN
|
Total count of bytes written through SCSI controller.
|
PRL_SATA_READ_REQUESTS_PTRN
|
Total count of read requests to SATA controller.
|
PRL_SATA_READ_TOTAL_PTRN
|
Total count of bytes read through SATA controller.
|
PRL_SATA_WRITE_REQUESTS_PTRN
|
Total count of write requests to SATA controller.
|
PRL_SATA_WRITE_TOTAL_PTRN
|
Total count of bytes written through SATA controller.
|
Example
The following example shows how to obtain the virtual machine disk I/O statistics.
PRL_HANDLE hVm, hJob, hResult, hEvent, hPerfCounter;
// Obtain performance statistics.
// In this example, we are getting the total count of read
// requests to IDE controller by passing the corresponding
// performance counter name. The performance counter names are
// defined in the PrlPerfCounters.h header file.
hJob = PrlVm_GetPerfStats(hVm, PRL_IDE_READ_REQUESTS_PTRN);
// Wait for the job to complete.
PrlJob_Wait(hJob, 15000);
// Obtain the PHT_RESULT object from the job.
PrlJob_GetResult(hJob, &hResult);
// Obtain the PHT_EVENT object from the result.
PrlResult_GetParam(hResult, &hEvent);
// Get the PHT_EVENT_PARAMETER object containing
// the actual performance counter value.
PrlEvent_GetParam(hEvent, 0, &hPerfCounter);
// Get the performance counter value.
PRL_UINT32 nValue;
PrlEvtPrm_ToInt32(hPerfCounter, &nValue);
// Process the nValue here...
|