From f1ecbcc829bcb8793d1d38a9ed746358a9795e57 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 4 Oct 2012 16:33:16 +0200 Subject: [PATCH] Add counter for number of packets per vif Change-Id: Ie1ef833998f4e706a2292614fbac33ec409bfe70 Signed-off-by: Julien Danjou --- ceilometer/compute/libvirt.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ceilometer/compute/libvirt.py b/ceilometer/compute/libvirt.py index fd198844b0..1ecf32f9b5 100644 --- a/ceilometer/compute/libvirt.py +++ b/ceilometer/compute/libvirt.py @@ -200,18 +200,32 @@ class NetPollster(plugin.ComputePollster): else: domain = conn._conn.lookupByName(instance.name) for vnic in vnics: - rx, _, _, _, tx, _, _, _ = domain.interfaceStats(vnic['name']) + rx_bytes, rx_packets, _, _, \ + tx_bytes, tx_packets, _, _ = \ + domain.interfaceStats(vnic['name']) self.LOG.info(self.NET_USAGE_MESSAGE, instance.name, - vnic['name'], rx, tx) + vnic['name'], rx_bytes, tx_bytes) yield make_vnic_counter(instance, name='network.incoming.bytes', type=counter.TYPE_CUMULATIVE, - volume=rx, + volume=rx_bytes, vnic_data=vnic ) yield make_vnic_counter(instance, name='network.outgoing.bytes', type=counter.TYPE_CUMULATIVE, - volume=tx, + volume=tx_bytes, + vnic_data=vnic + ) + yield make_vnic_counter(instance, + name='network.incoming.packets', + type=counter.TYPE_CUMULATIVE, + volume=rx_packets, + vnic_data=vnic + ) + yield make_vnic_counter(instance, + name='network.outgoing.packets', + type=counter.TYPE_CUMULATIVE, + volume=tx_packets, vnic_data=vnic )