Libvirt Functions
PHP Manual


(php-libvirt 0.3)

libvirt_domain_block_statsprovide block device statistics for the block device on domain.


array libvirt_domain_block_stats ( resource $domain , string $path )

This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.

The returned array contains members in accoridng to the libvirt structure virDomainBlockStatsStruct.

Members of the array returned by libvirt_domain_interface_stats
rd_reqnumber of read requests
rd_bytesnumber of read bytes
wr_reqnumber of write requests
wr_bytesnumber of written bytes
errsIn Xen this returns the mysterious 'oo_req'.

Note: Warning
This is the first implementation of this function in phplibvirt. There are some unsolved issues regarding integer ranges between PHP and Libvirt. We may change the beahviour of this function in future.



Domain resource of domain the block device is attached to


Path to the block device, i.e. "hda"

Return Values

Array with statistics.


Example #1 libvirt_domain_block_stats() example

Get interface statistics on blockdevice hda on domain test


The above example will output something similar to:

    [rd_req] => 0
    [rd_bytes] => 0
    [wr_req] => 0
    [wr_bytes] => 0
    [errs] => -1

See Also

Libvirt Functions
PHP Manual