[et-mgmt-tools] [PATCH 6/9]: virt-manager: block device and network statistics

Daniel P. Berrange berrange at redhat.com
Mon Oct 6 10:37:42 UTC 2008


On Sat, Oct 04, 2008 at 10:24:25PM +0200, Guido G?nther wrote:
> This is the actual patch to calculate the block and net stats:
> 
> Display block device I/0 and network I/O in the overview as well as in
> the vm details. The sparkline widget in the vm overview only draws the
> rx and read rates.This is fixed up by a followup patch, since this way
> we're independent of the sparkline patches.

> diff -r 30dc0d5939d4 src/virtManager/domain.py
> --- a/src/virtManager/domain.py	Sat Oct 04 20:41:20 2008 +0200
> +++ b/src/virtManager/domain.py	Sat Oct 04 21:52:04 2008 +0200
> @@ -149,6 +155,34 @@
>              self.lastStatus = status
>              self.emit("status-changed", status)
>  
> +    def _network_traffic(self):
> +        rx = 0
> +        tx = 0
> +        for netdev in self.get_network_devices():
> +            io = self.vm.interfaceStats(netdev[2])
> +            if io:
> +                rx += io[0]
> +                tx += io[4]

The standard behaviour libvirt python binding is to raise an exception
if something fails, so checking for io == None isn't sufficient here.
You should also wrap the call

            try:
                io = self.vm.interfaceStats(netdev[2])
            except:
                pass
            if io:
                rx += io[0]
                tx += io[4]

> +        return rx, tx
> +
> +    def _disk_io(self):
> +        rd = 0
> +        wr = 0
> +        for disk in self.get_disk_devices():
> +            io = self.vm.blockStats(disk[3])
> +            if io:
> +                rd += io[1]
> +                wr += io[3]
> +        return rd, wr


Likewise here.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the et-mgmt-tools mailing list