From 009053061a4cbd1f9fa0a56df7e5cf84085c0eff Mon Sep 17 00:00:00 2001 From: liuqing Date: Tue, 17 Jun 2014 23:15:01 +0800 Subject: [PATCH] Remove meter hardware.network.bandwidth.bytes The metering is just the speed of nic, if the nic is Gigabit-NIC, the value will always be Gigabit:) and it is better to shown in the metadata. Change-Id: Iaf95f4e9a0ff0a36fe1e8d03d5c87bf5b24bd24b Closes-Bug: #1331001 --- ceilometer/hardware/inspector/base.py | 9 ++++----- ceilometer/hardware/inspector/snmp.py | 14 +++++++------- ceilometer/hardware/pollsters/net.py | 14 -------------- ceilometer/tests/hardware/inspector/base.py | 6 +++--- ceilometer/tests/hardware/inspector/test_snmp.py | 14 +++++++------- ceilometer/tests/hardware/pollsters/base.py | 6 +++--- ceilometer/tests/hardware/pollsters/test_net.py | 14 ++++++-------- setup.cfg | 1 - 8 files changed, 30 insertions(+), 48 deletions(-) diff --git a/ceilometer/hardware/inspector/base.py b/ceilometer/hardware/inspector/base.py index 6803793ae..0fae9efd3 100644 --- a/ceilometer/hardware/inspector/base.py +++ b/ceilometer/hardware/inspector/base.py @@ -59,20 +59,19 @@ DiskStats = collections.namedtuple('DiskStats', ['size', 'used']) # name: the name of the interface # mac: the MAC of the interface # ip: the IP of the interface +# speed: the speed of the interface (bytes/s) # -Interface = collections.namedtuple('Interface', ['name', 'mac', 'ip']) +Interface = collections.namedtuple('Interface', ['name', 'mac', 'ip', 'speed']) # Named tuple representing network interface statistics. # -# bandwidth: current bandwidth (bytes/s) # rx_bytes: total number of octets received (bytes) # tx_bytes: total number of octets transmitted (bytes) # error: number of outbound packets not transmitted because of errors # -InterfaceStats = collections.namedtuple( - 'InterfaceStats', - ['bandwidth', 'rx_bytes', 'tx_bytes', 'error']) +InterfaceStats = collections.namedtuple('InterfaceStats', + ['rx_bytes', 'tx_bytes', 'error']) @six.add_metaclass(abc.ABCMeta) diff --git a/ceilometer/hardware/inspector/snmp.py b/ceilometer/hardware/inspector/snmp.py index a408695a2..51ca9c4c7 100644 --- a/ceilometer/hardware/inspector/snmp.py +++ b/ceilometer/hardware/inspector/snmp.py @@ -67,7 +67,7 @@ class SNMPInspector(base.Inspector): #Network Interface OIDs _interface_index_oid = "1.3.6.1.2.1.2.2.1.1" _interface_name_oid = "1.3.6.1.2.1.2.2.1.2" - _interface_bandwidth_oid = "1.3.6.1.2.1.2.2.1.5" + _interface_speed_oid = "1.3.6.1.2.1.2.2.1.5" _interface_mac_oid = "1.3.6.1.2.1.2.2.1.6" _interface_ip_oid = "1.3.6.1.2.1.4.20.1.2" _interface_received_oid = "1.3.6.1.2.1.2.2.1.10" @@ -162,10 +162,10 @@ class SNMPInspector(base.Inspector): mac_oid = "%s.%s" % (self._interface_mac_oid, str(value)) mac = self._get_value_from_oid(mac_oid, host) - bw_oid = "%s.%s" % (self._interface_bandwidth_oid, - str(value)) + speed_oid = "%s.%s" % (self._interface_speed_oid, + str(value)) # bits/s to byte/s - bandwidth = self._get_value_from_oid(bw_oid, host) / 8 + speed = self._get_value_from_oid(speed_oid, host) / 8 rx_oid = "%s.%s" % (self._interface_received_oid, str(value)) rx_bytes = self._get_value_from_oid(rx_oid, host) @@ -179,9 +179,9 @@ class SNMPInspector(base.Inspector): adapted_mac = mac.prettyPrint().replace('0x', '') interface = base.Interface(name=str(name), mac=adapted_mac, - ip=str(ip)) - stats = base.InterfaceStats(bandwidth=int(bandwidth), - rx_bytes=int(rx_bytes), + ip=str(ip), + speed=int(speed)) + stats = base.InterfaceStats(rx_bytes=int(rx_bytes), tx_bytes=int(tx_bytes), error=int(error)) yield (interface, stats) diff --git a/ceilometer/hardware/pollsters/net.py b/ceilometer/hardware/pollsters/net.py index e55c4b043..b23abec1f 100644 --- a/ceilometer/hardware/pollsters/net.py +++ b/ceilometer/hardware/pollsters/net.py @@ -29,20 +29,6 @@ class _Base(plugin.HardwarePollster): INSPECT_METHOD = 'inspect_network' -class BandwidthBytesPollster(_Base): - - @staticmethod - def generate_one_sample(host, c_data): - (nic, info) = c_data - return util.make_sample_from_host(host, - name='network.bandwidth.bytes', - type=sample.TYPE_GAUGE, - unit='B', - volume=info.bandwidth, - res_metadata=nic, - ) - - class IncomingBytesPollster(_Base): @staticmethod diff --git a/ceilometer/tests/hardware/inspector/base.py b/ceilometer/tests/hardware/inspector/base.py index 0c6c88ade..e61f04a7f 100644 --- a/ceilometer/tests/hardware/inspector/base.py +++ b/ceilometer/tests/hardware/inspector/base.py @@ -30,9 +30,9 @@ class InspectorBaseTest(object): network = [(base.Interface(name='eth0', mac='112233445566', - ip='10.0.0.1'), - base.InterfaceStats(bandwidth=1250000 / 8, - rx_bytes=1000, + ip='10.0.0.1', + speed=1250000 / 8), + base.InterfaceStats(rx_bytes=1000, tx_bytes=2000, error=1)), ] diff --git a/ceilometer/tests/hardware/inspector/test_snmp.py b/ceilometer/tests/hardware/inspector/test_snmp.py index 393b16f70..95be7ca5a 100644 --- a/ceilometer/tests/hardware/inspector/test_snmp.py +++ b/ceilometer/tests/hardware/inspector/test_snmp.py @@ -140,13 +140,13 @@ GETCMD_MAP = { FakeMac(), )], ), - ins._interface_bandwidth_oid + '.1': (None, - None, - 0, - [('', - Base.network[0][1].bandwidth * 8, - )], - ), + ins._interface_speed_oid + '.1': (None, + None, + 0, + [('', + Base.network[0][0].speed * 8, + )], + ), ins._interface_received_oid + '.1': (None, None, 0, diff --git a/ceilometer/tests/hardware/pollsters/base.py b/ceilometer/tests/hardware/pollsters/base.py index 966aa7f28..db98eab9e 100644 --- a/ceilometer/tests/hardware/pollsters/base.py +++ b/ceilometer/tests/hardware/pollsters/base.py @@ -32,9 +32,9 @@ class FakeInspector(inspector_base.Inspector): MEMORY = inspector_base.MemoryStats(total=1000, used=90) NET = (inspector_base.Interface(name='test.teest', mac='001122334455', - ip='10.0.0.2'), - inspector_base.InterfaceStats(bandwidth=1000, - rx_bytes=90, + ip='10.0.0.2', + speed=1000), + inspector_base.InterfaceStats(rx_bytes=90, tx_bytes=80, error=1)) diff --git a/ceilometer/tests/hardware/pollsters/test_net.py b/ceilometer/tests/hardware/pollsters/test_net.py index a7ed931c7..e229bd491 100644 --- a/ceilometer/tests/hardware/pollsters/test_net.py +++ b/ceilometer/tests/hardware/pollsters/test_net.py @@ -21,22 +21,20 @@ from ceilometer.tests.hardware.pollsters import base class TestNetPollsters(base.TestPollsterBase): - def test_bandwidth(self): - self._check_get_samples(net.BandwidthBytesPollster, - 'hardware.network.bandwidth.bytes', - 1000, sample.TYPE_GAUGE) - def test_incoming(self): self._check_get_samples(net.IncomingBytesPollster, 'hardware.network.incoming.bytes', - 90, sample.TYPE_CUMULATIVE) + 90, sample.TYPE_CUMULATIVE, + expected_unit='B') def test_outgoing(self): self._check_get_samples(net.OutgoingBytesPollster, 'hardware.network.outgoing.bytes', - 80, sample.TYPE_CUMULATIVE) + 80, sample.TYPE_CUMULATIVE, + expected_unit='B') def test_error(self): self._check_get_samples(net.OutgoingErrorsPollster, 'hardware.network.outgoing.errors', - 1, sample.TYPE_CUMULATIVE) + 1, sample.TYPE_CUMULATIVE, + expected_unit='packet') diff --git a/setup.cfg b/setup.cfg index 2043c98b5..5ba15bbc9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -129,7 +129,6 @@ ceilometer.poll.central = hardware.cpu.load.15min = ceilometer.hardware.pollsters.cpu:CPULoad15MinPollster hardware.disk.size.total = ceilometer.hardware.pollsters.disk:DiskTotalPollster hardware.disk.size.used = ceilometer.hardware.pollsters.disk:DiskUsedPollster - hardware.network.bandwidth.bytes = ceilometer.hardware.pollsters.net:BandwidthBytesPollster hardware.network.incoming.bytes = ceilometer.hardware.pollsters.net:IncomingBytesPollster hardware.network.outgoing.bytes = ceilometer.hardware.pollsters.net:OutgoingBytesPollster hardware.network.outgoing.errors = ceilometer.hardware.pollsters.net:OutgoingErrorsPollster