Merge "Remove meter hardware.network.bandwidth.bytes"

This commit is contained in:
Jenkins 2014-06-30 17:34:10 +00:00 committed by Gerrit Code Review
commit dc1cd53ec0
8 changed files with 30 additions and 48 deletions

View File

@ -59,20 +59,19 @@ DiskStats = collections.namedtuple('DiskStats', ['size', 'used'])
# name: the name of the interface # name: the name of the interface
# mac: the MAC of the interface # mac: the MAC of the interface
# ip: the IP 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. # Named tuple representing network interface statistics.
# #
# bandwidth: current bandwidth (bytes/s)
# rx_bytes: total number of octets received (bytes) # rx_bytes: total number of octets received (bytes)
# tx_bytes: total number of octets transmitted (bytes) # tx_bytes: total number of octets transmitted (bytes)
# error: number of outbound packets not transmitted because of errors # error: number of outbound packets not transmitted because of errors
# #
InterfaceStats = collections.namedtuple( InterfaceStats = collections.namedtuple('InterfaceStats',
'InterfaceStats', ['rx_bytes', 'tx_bytes', 'error'])
['bandwidth', 'rx_bytes', 'tx_bytes', 'error'])
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)

View File

@ -67,7 +67,7 @@ class SNMPInspector(base.Inspector):
# Network Interface OIDs # Network Interface OIDs
_interface_index_oid = "1.3.6.1.2.1.2.2.1.1" _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_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_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_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" _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, mac_oid = "%s.%s" % (self._interface_mac_oid,
str(value)) str(value))
mac = self._get_value_from_oid(mac_oid, host) mac = self._get_value_from_oid(mac_oid, host)
bw_oid = "%s.%s" % (self._interface_bandwidth_oid, speed_oid = "%s.%s" % (self._interface_speed_oid,
str(value)) str(value))
# bits/s to byte/s # 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, rx_oid = "%s.%s" % (self._interface_received_oid,
str(value)) str(value))
rx_bytes = self._get_value_from_oid(rx_oid, host) rx_bytes = self._get_value_from_oid(rx_oid, host)
@ -179,9 +179,9 @@ class SNMPInspector(base.Inspector):
adapted_mac = mac.prettyPrint().replace('0x', '') adapted_mac = mac.prettyPrint().replace('0x', '')
interface = base.Interface(name=str(name), interface = base.Interface(name=str(name),
mac=adapted_mac, mac=adapted_mac,
ip=str(ip)) ip=str(ip),
stats = base.InterfaceStats(bandwidth=int(bandwidth), speed=int(speed))
rx_bytes=int(rx_bytes), stats = base.InterfaceStats(rx_bytes=int(rx_bytes),
tx_bytes=int(tx_bytes), tx_bytes=int(tx_bytes),
error=int(error)) error=int(error))
yield (interface, stats) yield (interface, stats)

View File

@ -29,20 +29,6 @@ class _Base(plugin.HardwarePollster):
INSPECT_METHOD = 'inspect_network' 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): class IncomingBytesPollster(_Base):
@staticmethod @staticmethod

View File

@ -30,9 +30,9 @@ class InspectorBaseTest(object):
network = [(base.Interface(name='eth0', network = [(base.Interface(name='eth0',
mac='112233445566', mac='112233445566',
ip='10.0.0.1'), ip='10.0.0.1',
base.InterfaceStats(bandwidth=1250000 / 8, speed=1250000 / 8),
rx_bytes=1000, base.InterfaceStats(rx_bytes=1000,
tx_bytes=2000, tx_bytes=2000,
error=1)), error=1)),
] ]

View File

@ -140,11 +140,11 @@ GETCMD_MAP = {
FakeMac(), FakeMac(),
)], )],
), ),
ins._interface_bandwidth_oid + '.1': (None, ins._interface_speed_oid + '.1': (None,
None, None,
0, 0,
[('', [('',
Base.network[0][1].bandwidth * 8, Base.network[0][0].speed * 8,
)], )],
), ),
ins._interface_received_oid + '.1': (None, ins._interface_received_oid + '.1': (None,

View File

@ -32,9 +32,9 @@ class FakeInspector(inspector_base.Inspector):
MEMORY = inspector_base.MemoryStats(total=1000, used=90) MEMORY = inspector_base.MemoryStats(total=1000, used=90)
NET = (inspector_base.Interface(name='test.teest', NET = (inspector_base.Interface(name='test.teest',
mac='001122334455', mac='001122334455',
ip='10.0.0.2'), ip='10.0.0.2',
inspector_base.InterfaceStats(bandwidth=1000, speed=1000),
rx_bytes=90, inspector_base.InterfaceStats(rx_bytes=90,
tx_bytes=80, tx_bytes=80,
error=1)) error=1))

View File

@ -21,22 +21,20 @@ from ceilometer.tests.hardware.pollsters import base
class TestNetPollsters(base.TestPollsterBase): 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): def test_incoming(self):
self._check_get_samples(net.IncomingBytesPollster, self._check_get_samples(net.IncomingBytesPollster,
'hardware.network.incoming.bytes', 'hardware.network.incoming.bytes',
90, sample.TYPE_CUMULATIVE) 90, sample.TYPE_CUMULATIVE,
expected_unit='B')
def test_outgoing(self): def test_outgoing(self):
self._check_get_samples(net.OutgoingBytesPollster, self._check_get_samples(net.OutgoingBytesPollster,
'hardware.network.outgoing.bytes', 'hardware.network.outgoing.bytes',
80, sample.TYPE_CUMULATIVE) 80, sample.TYPE_CUMULATIVE,
expected_unit='B')
def test_error(self): def test_error(self):
self._check_get_samples(net.OutgoingErrorsPollster, self._check_get_samples(net.OutgoingErrorsPollster,
'hardware.network.outgoing.errors', 'hardware.network.outgoing.errors',
1, sample.TYPE_CUMULATIVE) 1, sample.TYPE_CUMULATIVE,
expected_unit='packet')

View File

@ -129,7 +129,6 @@ ceilometer.poll.central =
hardware.cpu.load.15min = ceilometer.hardware.pollsters.cpu:CPULoad15MinPollster hardware.cpu.load.15min = ceilometer.hardware.pollsters.cpu:CPULoad15MinPollster
hardware.disk.size.total = ceilometer.hardware.pollsters.disk:DiskTotalPollster hardware.disk.size.total = ceilometer.hardware.pollsters.disk:DiskTotalPollster
hardware.disk.size.used = ceilometer.hardware.pollsters.disk:DiskUsedPollster 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.incoming.bytes = ceilometer.hardware.pollsters.net:IncomingBytesPollster
hardware.network.outgoing.bytes = ceilometer.hardware.pollsters.net:OutgoingBytesPollster hardware.network.outgoing.bytes = ceilometer.hardware.pollsters.net:OutgoingBytesPollster
hardware.network.outgoing.errors = ceilometer.hardware.pollsters.net:OutgoingErrorsPollster hardware.network.outgoing.errors = ceilometer.hardware.pollsters.net:OutgoingErrorsPollster