Libvirt Functions
PHP Manual


(php-libvirt 0.3)

libvirt_domain_interface_statsprovide interface statistics for the virtual network interface on domain.


array libvirt_domain_interface_stats ( resource $domain , string $path )

This function returns network interface stats for interfaces attached to the domain. The path parameter is the name of the network interface. Domains may have more than one network interface. 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 virDomainInterfaceStatsStruct.

Members of the array returned by libvirt_domain_interface_stats
rx_bytesBytes received
rx_packetsPackets received
rx_errsErrors on receive
rx_dropDrops on receive
rx_bytesBytes transmitted
rx_packetsPackets transmitted
rx_errsErrors on transmit
rx_dropDrops on transmit

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 interface is attached to


Path to the interface, i.e. "vnet1"

Return Values

Array with statistics.


Example #1 libvirt_domain_interface_stats() example

Get interface statistics on interface vnet1 on domain test


The above example will output something similar to:

    [rx_bytes] => 94699317
    [rx_packets] => 794389
    [rx_errs] => 0
    [rx_drop] => 0
    [tx_bytes] => 0
    [tx_packets] => 0
    [tx_errs] => 0
    [tx_drop] => 0

See Also

Libvirt Functions
PHP Manual