Support for per disk volume measurements
This enables us to track per disk read/write requests and bytes. The existing samples accumulated by the incoming data are used to yield needed per disk samples. Also includes the names for the assocaited disks as part of the metadata. For per device pollsters, the resource id is a combination of instance id and device name. Unit tests included to cover the above use cases. Change-Id: I69ab6a99c61e051cfb367c1276b8886f25ae6be7 Implements: blueprint instance-per-disk-measurement
This commit is contained in:
parent
c638d043b1
commit
4f77c710ef
@ -1,9 +1,11 @@
|
||||
#
|
||||
# Copyright 2012 eNovance <licensing@enovance.com>
|
||||
# Copyright 2012 Red Hat, Inc
|
||||
# Copyright 2014 Cisco Systems, Inc
|
||||
#
|
||||
# Author: Julien Danjou <julien@danjou.info>
|
||||
# Author: Eoghan Glynn <eglynn@redhat.com>
|
||||
# Author: Pradeep Kilambi <pkilambi@cisco.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@ -16,7 +18,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import collections
|
||||
|
||||
@ -34,9 +35,16 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
DiskIOData = collections.namedtuple(
|
||||
'DiskIOData',
|
||||
'r_bytes r_requests w_bytes w_requests',
|
||||
'r_bytes r_requests w_bytes w_requests per_disk_requests',
|
||||
)
|
||||
|
||||
DiskRateData = collections.namedtuple('DiskRateData',
|
||||
['read_bytes_rate',
|
||||
'read_requests_rate',
|
||||
'write_bytes_rate',
|
||||
'write_requests_rate',
|
||||
'per_disk_rate'])
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class _Base(plugin.ComputePollster):
|
||||
@ -59,6 +67,10 @@ class _Base(plugin.ComputePollster):
|
||||
r_requests = 0
|
||||
w_bytes = 0
|
||||
w_requests = 0
|
||||
per_device_read_bytes = {}
|
||||
per_device_read_requests = {}
|
||||
per_device_write_bytes = {}
|
||||
per_device_write_requests = {}
|
||||
for disk, info in inspector.inspect_disks(instance_name):
|
||||
LOG.info(self.DISKIO_USAGE_MESSAGE,
|
||||
instance, disk.device, info.read_requests,
|
||||
@ -68,17 +80,29 @@ class _Base(plugin.ComputePollster):
|
||||
r_requests += info.read_requests
|
||||
w_bytes += info.write_bytes
|
||||
w_requests += info.write_requests
|
||||
# per disk data
|
||||
per_device_read_bytes[disk.device] = info.read_bytes
|
||||
per_device_read_requests[disk.device] = info.read_requests
|
||||
per_device_write_bytes[disk.device] = info.write_bytes
|
||||
per_device_write_requests[disk.device] = info.write_requests
|
||||
per_device_requests = {
|
||||
'read_bytes': per_device_read_bytes,
|
||||
'read_requests': per_device_read_requests,
|
||||
'write_bytes': per_device_write_bytes,
|
||||
'write_requests': per_device_write_requests,
|
||||
}
|
||||
i_cache[instance_name] = DiskIOData(
|
||||
r_bytes=r_bytes,
|
||||
r_requests=r_requests,
|
||||
w_bytes=w_bytes,
|
||||
w_requests=w_requests,
|
||||
per_disk_requests=per_device_requests,
|
||||
)
|
||||
return i_cache[instance_name]
|
||||
|
||||
@abc.abstractmethod
|
||||
def _get_sample(instance, c_data):
|
||||
"""Return one Sample."""
|
||||
def _get_samples(instance, c_data):
|
||||
"""Return one or more Sample."""
|
||||
|
||||
def get_samples(self, manager, cache, resources):
|
||||
for instance in resources:
|
||||
@ -90,7 +114,8 @@ class _Base(plugin.ComputePollster):
|
||||
instance,
|
||||
instance_name,
|
||||
)
|
||||
yield self._get_sample(instance, c_data)
|
||||
for s in self._get_samples(instance, c_data):
|
||||
yield s
|
||||
except virt_inspector.InstanceNotFoundException as err:
|
||||
# Instance was deleted while getting samples. Ignore it.
|
||||
LOG.debug(_('Exception while getting samples %s'), err)
|
||||
@ -108,53 +133,133 @@ class _Base(plugin.ComputePollster):
|
||||
class ReadRequestsPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_sample(instance, c_data):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(instance, c_data):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.read.requests',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='request',
|
||||
volume=c_data.r_requests,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': c_data.per_disk_requests['read_requests'].keys()}
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceReadRequestsPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_samples(instance, c_data):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(c_data.per_disk_requests[
|
||||
'read_requests']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.read.requests',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='request',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class ReadBytesPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_sample(instance, c_data):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(instance, c_data):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.read.bytes',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='B',
|
||||
volume=c_data.r_bytes,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': c_data.per_disk_requests['read_bytes'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceReadBytesPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_samples(instance, c_data):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(c_data.per_disk_requests[
|
||||
'read_bytes']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.read.bytes',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='B',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class WriteRequestsPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_sample(instance, c_data):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(instance, c_data):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.write.requests',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='request',
|
||||
volume=c_data.w_requests,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': c_data.per_disk_requests['write_requests'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceWriteRequestsPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_samples(instance, c_data):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(c_data.per_disk_requests[
|
||||
'write_requests']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.write.requests',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='request',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class WriteBytesPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_sample(instance, c_data):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(instance, c_data):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.write.bytes',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='B',
|
||||
volume=c_data.w_bytes,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': c_data.per_disk_requests['write_bytes'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceWriteBytesPollster(_Base):
|
||||
|
||||
@staticmethod
|
||||
def _get_samples(instance, c_data):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(c_data.per_disk_requests[
|
||||
'write_bytes']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.write.bytes',
|
||||
type=sample.TYPE_CUMULATIVE,
|
||||
unit='B',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
@ -169,6 +274,10 @@ class _DiskRatesPollsterBase(plugin.ComputePollster):
|
||||
r_requests_rate = 0
|
||||
w_bytes_rate = 0
|
||||
w_requests_rate = 0
|
||||
per_disk_r_bytes_rate = {}
|
||||
per_disk_r_requests_rate = {}
|
||||
per_disk_w_bytes_rate = {}
|
||||
per_disk_w_requests_rate = {}
|
||||
disk_rates = inspector.inspect_disk_rates(
|
||||
instance, self._inspection_duration)
|
||||
for disk, info in disk_rates:
|
||||
@ -176,17 +285,30 @@ class _DiskRatesPollsterBase(plugin.ComputePollster):
|
||||
r_requests_rate += info.read_requests_rate
|
||||
w_bytes_rate += info.write_bytes_rate
|
||||
w_requests_rate += info.write_requests_rate
|
||||
i_cache[instance.id] = virt_inspector.DiskRateStats(
|
||||
|
||||
per_disk_r_bytes_rate[disk.device] = info.read_bytes_rate
|
||||
per_disk_r_requests_rate[disk.device] = info.read_requests_rate
|
||||
per_disk_w_bytes_rate[disk.device] = info.write_bytes_rate
|
||||
per_disk_w_requests_rate[disk.device] = (
|
||||
info.write_requests_rate)
|
||||
per_disk_rate = {
|
||||
'read_bytes_rate': per_disk_r_bytes_rate,
|
||||
'read_requests_rate': per_disk_r_requests_rate,
|
||||
'write_bytes_rate': per_disk_w_bytes_rate,
|
||||
'write_requests_rate': per_disk_w_requests_rate,
|
||||
}
|
||||
i_cache[instance.id] = DiskRateData(
|
||||
r_bytes_rate,
|
||||
r_requests_rate,
|
||||
w_bytes_rate,
|
||||
w_requests_rate
|
||||
w_requests_rate,
|
||||
per_disk_rate
|
||||
)
|
||||
return i_cache[instance.id]
|
||||
|
||||
@abc.abstractmethod
|
||||
def _get_sample(self, instance, disk_rates_info):
|
||||
"""Return one Sample."""
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
"""Return one or more Sample."""
|
||||
|
||||
def get_samples(self, manager, cache, resources):
|
||||
self._inspection_duration = self._record_poll_time()
|
||||
@ -197,7 +319,8 @@ class _DiskRatesPollsterBase(plugin.ComputePollster):
|
||||
cache,
|
||||
instance,
|
||||
)
|
||||
yield self._get_sample(instance, disk_rates_info)
|
||||
for disk_rate in self._get_samples(instance, disk_rates_info):
|
||||
yield disk_rate
|
||||
except virt_inspector.InstanceNotFoundException as err:
|
||||
# Instance was deleted while getting samples. Ignore it.
|
||||
LOG.debug(_('Exception while getting samples %s'), err)
|
||||
@ -215,47 +338,127 @@ class _DiskRatesPollsterBase(plugin.ComputePollster):
|
||||
|
||||
class ReadBytesRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_sample(self, instance, disk_rates_info):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.read.bytes.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='B/s',
|
||||
volume=disk_rates_info.read_bytes_rate,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': disk_rates_info.per_disk_rate[
|
||||
'read_bytes_rate'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceReadBytesRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(disk_rates_info.per_disk_rate[
|
||||
'read_bytes_rate']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.read.bytes.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='B/s',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class ReadRequestsRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_sample(self, instance, disk_rates_info):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.read.requests.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='requests/s',
|
||||
volume=disk_rates_info.read_requests_rate,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': disk_rates_info.per_disk_rate[
|
||||
'read_requests_rate'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceReadRequestsRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(disk_rates_info.per_disk_rate[
|
||||
'read_requests_rate']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.read.requests.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='requests/s',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class WriteBytesRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_sample(self, instance, disk_rates_info):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.write.bytes.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='B/s',
|
||||
volume=disk_rates_info.write_bytes_rate,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': disk_rates_info.per_disk_rate[
|
||||
'write_bytes_rate'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceWriteBytesRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(disk_rates_info.per_disk_rate[
|
||||
'write_bytes_rate']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.write.bytes.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='B/s',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
||||
|
||||
class WriteRequestsRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_sample(self, instance, disk_rates_info):
|
||||
return util.make_sample_from_instance(
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
return [util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.write.requests.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='requests/s',
|
||||
volume=disk_rates_info.write_requests_rate,
|
||||
)
|
||||
additional_metadata={
|
||||
'device': disk_rates_info.per_disk_rate[
|
||||
'write_requests_rate'].keys()},
|
||||
)]
|
||||
|
||||
|
||||
class PerDeviceWriteRequestsRatePollster(_DiskRatesPollsterBase):
|
||||
|
||||
def _get_samples(self, instance, disk_rates_info):
|
||||
samples = []
|
||||
for disk, value in six.iteritems(disk_rates_info.per_disk_rate[
|
||||
'write_requests_rate']):
|
||||
samples.append(util.make_sample_from_instance(
|
||||
instance,
|
||||
name='disk.device.write.requests.rate',
|
||||
type=sample.TYPE_GAUGE,
|
||||
unit='requests/s',
|
||||
volume=value,
|
||||
resource_id="%s-%s" % (instance.id, disk),
|
||||
))
|
||||
return samples
|
||||
|
@ -75,7 +75,7 @@ def _get_metadata_from_object(instance):
|
||||
|
||||
|
||||
def make_sample_from_instance(instance, name, type, unit, volume,
|
||||
additional_metadata=None):
|
||||
resource_id=None, additional_metadata=None):
|
||||
additional_metadata = additional_metadata or {}
|
||||
resource_metadata = _get_metadata_from_object(instance)
|
||||
resource_metadata.update(additional_metadata)
|
||||
@ -86,7 +86,7 @@ def make_sample_from_instance(instance, name, type, unit, volume,
|
||||
volume=volume,
|
||||
user_id=instance.user_id,
|
||||
project_id=instance.tenant_id,
|
||||
resource_id=instance.id,
|
||||
resource_id=resource_id or instance.id,
|
||||
timestamp=timeutils.isotime(),
|
||||
resource_metadata=resource_metadata,
|
||||
)
|
||||
|
@ -1,9 +1,11 @@
|
||||
#
|
||||
# Copyright 2012 eNovance <licensing@enovance.com>
|
||||
# Copyright 2012 Red Hat, Inc
|
||||
#
|
||||
# Copyright 2014 Cisco Systems, Inc
|
||||
|
||||
# Author: Julien Danjou <julien@danjou.info>
|
||||
# Author: Eoghan Glynn <eglynn@redhat.com>
|
||||
# Author: Pradeep Kilambi <pkilambi@cisco.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@ -25,13 +27,50 @@ from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.tests.compute.pollsters import base
|
||||
|
||||
|
||||
class TestDiskPollsters(base.TestPollsterBase):
|
||||
class TestBaseDistIO(base.TestPollsterBase):
|
||||
|
||||
TYPE = 'cumulative'
|
||||
|
||||
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
||||
def _check_get_samples(self, factory, name):
|
||||
pass
|
||||
|
||||
def _check_aggregate_samples(self, factory, name,
|
||||
expected_volume,
|
||||
expected_device=None):
|
||||
match = self._check_get_samples(factory, name)
|
||||
self.assertEqual(expected_volume, match[0].volume)
|
||||
self.assertEqual(self.TYPE, match[0].type)
|
||||
self.assertEqual(expected_device,
|
||||
match[0].resource_metadata.get('device'))
|
||||
self.assertEqual(self.instance.id, match[0].resource_id)
|
||||
|
||||
def _check_per_device_samples(self, factory, name,
|
||||
expected_volume,
|
||||
expected_device=None):
|
||||
match = self._check_get_samples(factory, name, expected_count=2)
|
||||
match_dict = {}
|
||||
for m in match:
|
||||
match_dict[m.resource_id] = m
|
||||
key = "%s-%s" % (self.instance.id, expected_device)
|
||||
self.assertEqual(expected_volume,
|
||||
match_dict[key].volume)
|
||||
self.assertEqual(self.TYPE, match_dict[key].type)
|
||||
|
||||
self.assertEqual(key, match_dict[key].resource_id)
|
||||
|
||||
|
||||
class TestDiskPollsters(TestBaseDistIO):
|
||||
|
||||
DISKS = [
|
||||
(virt_inspector.Disk(device='vda'),
|
||||
(virt_inspector.Disk(device='vda1'),
|
||||
virt_inspector.DiskStats(read_bytes=1L, read_requests=2L,
|
||||
write_bytes=3L, write_requests=4L,
|
||||
errors=-1L))
|
||||
errors=-1L)),
|
||||
(virt_inspector.Disk(device='vda2'),
|
||||
virt_inspector.DiskStats(read_bytes=2L, read_requests=3L,
|
||||
write_bytes=5L, write_requests=7L,
|
||||
errors=-1L)),
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@ -39,7 +78,7 @@ class TestDiskPollsters(base.TestPollsterBase):
|
||||
self.inspector.inspect_disks = mock.Mock(return_value=self.DISKS)
|
||||
|
||||
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
||||
def _check_get_samples(self, factory, name, expected_volume):
|
||||
def _check_get_samples(self, factory, name, expected_count=1):
|
||||
pollster = factory()
|
||||
|
||||
mgr = manager.AgentManager()
|
||||
@ -48,32 +87,67 @@ class TestDiskPollsters(base.TestPollsterBase):
|
||||
self.assertIsNotEmpty(samples)
|
||||
self.assertIn(pollster.CACHE_KEY_DISK, cache)
|
||||
self.assertIn(self.instance.name, cache[pollster.CACHE_KEY_DISK])
|
||||
|
||||
self.assertEqual(set([name]), set([s.name for s in samples]))
|
||||
|
||||
match = [s for s in samples if s.name == name]
|
||||
self.assertEqual(len(match), 1, 'missing counter %s' % name)
|
||||
self.assertEqual(expected_volume, match[0].volume)
|
||||
self.assertEqual('cumulative', match[0].type)
|
||||
self.assertEqual(len(match), expected_count,
|
||||
'missing counter %s' % name)
|
||||
return match
|
||||
|
||||
def test_disk_read_requests(self):
|
||||
self._check_get_samples(disk.ReadRequestsPollster,
|
||||
'disk.read.requests', 2L)
|
||||
self._check_aggregate_samples(disk.ReadRequestsPollster,
|
||||
'disk.read.requests', 5L,
|
||||
expected_device=['vda1', 'vda2'])
|
||||
|
||||
def test_disk_read_bytes(self):
|
||||
self._check_get_samples(disk.ReadBytesPollster,
|
||||
'disk.read.bytes', 1L)
|
||||
self._check_aggregate_samples(disk.ReadBytesPollster,
|
||||
'disk.read.bytes', 3L,
|
||||
expected_device=['vda1', 'vda2'])
|
||||
|
||||
def test_disk_write_requests(self):
|
||||
self._check_get_samples(disk.WriteRequestsPollster,
|
||||
'disk.write.requests', 4L)
|
||||
self._check_aggregate_samples(disk.WriteRequestsPollster,
|
||||
'disk.write.requests', 11L,
|
||||
expected_device=['vda1', 'vda2'])
|
||||
|
||||
def test_disk_write_bytes(self):
|
||||
self._check_get_samples(disk.WriteBytesPollster,
|
||||
'disk.write.bytes', 3L)
|
||||
self._check_aggregate_samples(disk.WriteBytesPollster,
|
||||
'disk.write.bytes', 8L,
|
||||
expected_device=['vda1', 'vda2'])
|
||||
|
||||
def test_per_disk_read_requests(self):
|
||||
self._check_per_device_samples(disk.PerDeviceReadRequestsPollster,
|
||||
'disk.device.read.requests', 2L,
|
||||
'vda1')
|
||||
self._check_per_device_samples(disk.PerDeviceReadRequestsPollster,
|
||||
'disk.device.read.requests', 3L,
|
||||
'vda2')
|
||||
|
||||
def test_per_disk_write_requests(self):
|
||||
self._check_per_device_samples(disk.PerDeviceWriteRequestsPollster,
|
||||
'disk.device.write.requests', 4L,
|
||||
'vda1')
|
||||
self._check_per_device_samples(disk.PerDeviceWriteRequestsPollster,
|
||||
'disk.device.write.requests', 7L,
|
||||
'vda2')
|
||||
|
||||
def test_per_disk_read_bytes(self):
|
||||
self._check_per_device_samples(disk.PerDeviceReadBytesPollster,
|
||||
'disk.device.read.bytes', 1L,
|
||||
'vda1')
|
||||
self._check_per_device_samples(disk.PerDeviceReadBytesPollster,
|
||||
'disk.device.read.bytes', 2L,
|
||||
'vda2')
|
||||
|
||||
def test_per_disk_write_bytes(self):
|
||||
self._check_per_device_samples(disk.PerDeviceWriteBytesPollster,
|
||||
'disk.device.write.bytes', 3L,
|
||||
'vda1')
|
||||
self._check_per_device_samples(disk.PerDeviceWriteBytesPollster,
|
||||
'disk.device.write.bytes', 5L,
|
||||
'vda2')
|
||||
|
||||
|
||||
class TestDiskRatePollsters(base.TestPollsterBase):
|
||||
class TestDiskRatePollsters(TestBaseDistIO):
|
||||
|
||||
DISKS = [
|
||||
(virt_inspector.Disk(device='disk1'),
|
||||
@ -82,13 +156,15 @@ class TestDiskRatePollsters(base.TestPollsterBase):
|
||||
(virt_inspector.Disk(device='disk2'),
|
||||
virt_inspector.DiskRateStats(2048, 400, 6144, 800))
|
||||
]
|
||||
TYPE = 'gauge'
|
||||
|
||||
def setUp(self):
|
||||
super(TestDiskRatePollsters, self).setUp()
|
||||
self.inspector.inspect_disk_rates = mock.Mock(return_value=self.DISKS)
|
||||
|
||||
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
||||
def _check_get_samples(self, factory, sample_name, expected_volume):
|
||||
def _check_get_samples(self, factory, sample_name,
|
||||
expected_count=1):
|
||||
pollster = factory()
|
||||
|
||||
mgr = manager.AgentManager()
|
||||
@ -102,22 +178,58 @@ class TestDiskRatePollsters(base.TestPollsterBase):
|
||||
self.assertEqual(set([sample_name]), set([s.name for s in samples]))
|
||||
|
||||
match = [s for s in samples if s.name == sample_name]
|
||||
self.assertEqual(1, len(match), 'missing counter %s' % sample_name)
|
||||
self.assertEqual(expected_volume, match[0].volume)
|
||||
self.assertEqual('gauge', match[0].type)
|
||||
self.assertEqual(expected_count, len(match),
|
||||
'missing counter %s' % sample_name)
|
||||
return match
|
||||
|
||||
def test_disk_read_bytes_rate(self):
|
||||
self._check_get_samples(disk.ReadBytesRatePollster,
|
||||
'disk.read.bytes.rate', 3072L)
|
||||
self._check_aggregate_samples(disk.ReadBytesRatePollster,
|
||||
'disk.read.bytes.rate', 3072L,
|
||||
expected_device=['disk1', 'disk2'])
|
||||
|
||||
def test_disk_read_requests_rate(self):
|
||||
self._check_get_samples(disk.ReadRequestsRatePollster,
|
||||
'disk.read.requests.rate', 700L)
|
||||
self._check_aggregate_samples(disk.ReadRequestsRatePollster,
|
||||
'disk.read.requests.rate', 700L,
|
||||
expected_device=['disk1', 'disk2'])
|
||||
|
||||
def test_disk_write_bytes_rate(self):
|
||||
self._check_get_samples(disk.WriteBytesRatePollster,
|
||||
'disk.write.bytes.rate', 11264L)
|
||||
self._check_aggregate_samples(disk.WriteBytesRatePollster,
|
||||
'disk.write.bytes.rate', 11264L,
|
||||
expected_device=['disk1', 'disk2'])
|
||||
|
||||
def test_disk_write_requests_rate(self):
|
||||
self._check_get_samples(disk.WriteRequestsRatePollster,
|
||||
'disk.write.requests.rate', 1500L)
|
||||
self._check_aggregate_samples(disk.WriteRequestsRatePollster,
|
||||
'disk.write.requests.rate', 1500L,
|
||||
expected_device=['disk1', 'disk2'])
|
||||
|
||||
def test_per_disk_read_bytes_rate(self):
|
||||
self._check_per_device_samples(disk.PerDeviceReadBytesRatePollster,
|
||||
'disk.device.read.bytes.rate',
|
||||
1024L, 'disk1')
|
||||
self._check_per_device_samples(disk.PerDeviceReadBytesRatePollster,
|
||||
'disk.device.read.bytes.rate',
|
||||
2048L, 'disk2')
|
||||
|
||||
def test_per_disk_read_requests_rate(self):
|
||||
self._check_per_device_samples(disk.PerDeviceReadRequestsRatePollster,
|
||||
'disk.device.read.requests.rate',
|
||||
300L, 'disk1')
|
||||
self._check_per_device_samples(disk.PerDeviceReadRequestsRatePollster,
|
||||
'disk.device.read.requests.rate',
|
||||
400L, 'disk2')
|
||||
|
||||
def test_per_disk_write_bytes_rate(self):
|
||||
self._check_per_device_samples(disk.PerDeviceWriteBytesRatePollster,
|
||||
'disk.device.write.bytes.rate',
|
||||
5120L, 'disk1')
|
||||
self._check_per_device_samples(disk.PerDeviceWriteBytesRatePollster,
|
||||
'disk.device.write.bytes.rate', 6144L,
|
||||
'disk2')
|
||||
|
||||
def test_per_disk_write_requests_rate(self):
|
||||
self._check_per_device_samples(disk.PerDeviceWriteRequestsRatePollster,
|
||||
'disk.device.write.requests.rate', 700L,
|
||||
'disk1')
|
||||
self._check_per_device_samples(disk.PerDeviceWriteRequestsRatePollster,
|
||||
'disk.device.write.requests.rate', 800L,
|
||||
'disk2')
|
||||
|
@ -65,35 +65,43 @@ Compute (Nova)
|
||||
|
||||
All meters are related to the guest machine, not the host.
|
||||
|
||||
============================= ===== ========= ======== ======== ========== ==================================================================
|
||||
Name Type* Unit Resource Origin** Support*** Note
|
||||
============================= ===== ========= ======== ======== ========== ==================================================================
|
||||
instance g instance inst ID both 1, 2, 3 Existence of instance
|
||||
instance:<type> g instance inst ID both 1, 2, 3 Existence of instance <type> (openstack types)
|
||||
memory g MB inst ID n 1, 2 Volume of RAM allocated in MB
|
||||
memory.usage g MB inst ID p 3 Volume of RAM used in MB
|
||||
cpu c ns inst ID p 1, 2 CPU time used
|
||||
cpu_util g % inst ID p 1, 2, 3 Average CPU utilisation
|
||||
vcpus g vcpu inst ID n 1, 2 Number of VCPUs
|
||||
disk.read.requests c request inst ID p 1, 2 Number of read requests
|
||||
disk.read.requests.rate g request/s inst ID p 1, 2, 3 Average rate of read requests per second
|
||||
disk.write.requests c request inst ID p 1, 2 Number of write requests
|
||||
disk.write.requests.rate g request/s inst ID p 1, 2, 3 Average rate of write requests per second
|
||||
disk.read.bytes c B inst ID p 1, 2 Volume of reads in B
|
||||
disk.read.bytes.rate g B/s inst ID p 1, 2, 3 Average rate of reads in B per second
|
||||
disk.write.bytes c B inst ID p 1, 2 Volume of writes in B
|
||||
disk.write.bytes.rate g B/s inst ID p 1, 2, 3 Average volume of writes in B per second
|
||||
disk.root.size g GB inst ID n 1, 2 Size of root disk in GB
|
||||
disk.ephemeral.size g GB inst ID n 1, 2 Size of ephemeral disk in GB
|
||||
network.incoming.bytes c B iface ID p 1, 2 Number of incoming bytes on a VM network interface
|
||||
network.incoming.bytes.rate g B/s iface ID p 1, 2, 3 Average rate per sec of incoming bytes on a VM network interface
|
||||
network.outgoing.bytes c B iface ID p 1, 2 Number of outgoing bytes on a VM network interface
|
||||
network.outgoing.bytes.rate g B/s iface ID p 1, 2, 3 Average rate per sec of outgoing bytes on a VM network interface
|
||||
network.incoming.packets c packet iface ID p 1, 2 Number of incoming packets on a VM network interface
|
||||
network.incoming.packets.rate g packet/s iface ID p 1, 2, 3 Average rate per sec of incoming packets on a VM network interface
|
||||
network.outgoing.packets c packet iface ID p 1, 2 Number of outgoing packets on a VM network interface
|
||||
network.outgoing.packets.rate g packet/s iface ID p 1, 2, 3 Average rate per sec of outgoing packets on a VM network interface
|
||||
============================= ===== ========= ======== ======== ========== ==================================================================
|
||||
=============================== ===== ========= ======== ======== ========== ==================================================================
|
||||
Name Type* Unit Resource Origin** Support*** Note
|
||||
=============================== ===== ========= ======== ======== ========== ==================================================================
|
||||
instance g instance inst ID both 1, 2, 3 Existence of instance
|
||||
instance:<type> g instance inst ID both 1, 2, 3 Existence of instance <type> (openstack types)
|
||||
memory g MB inst ID n 1, 2 Volume of RAM allocated in MB
|
||||
memory.usage g MB inst ID p 3 Volume of RAM used in MB
|
||||
cpu c ns inst ID p 1, 2 CPU time used
|
||||
cpu_util g % inst ID p 1, 2, 3 Average CPU utilisation
|
||||
vcpus g vcpu inst ID n 1, 2 Number of VCPUs
|
||||
disk.read.requests c request inst ID p 1, 2 Number of read requests
|
||||
disk.read.requests.rate g request/s inst ID p 1, 2, 3 Average rate of read requests per second
|
||||
disk.write.requests c request inst ID p 1, 2 Number of write requests
|
||||
disk.write.requests.rate g request/s inst ID p 1, 2, 3 Average rate of write requests per second
|
||||
disk.read.bytes c B inst ID p 1, 2 Volume of reads in B
|
||||
disk.read.bytes.rate g B/s inst ID p 1, 2, 3 Average rate of reads in B per second
|
||||
disk.write.bytes c B inst ID p 1, 2 Volume of writes in B
|
||||
disk.write.bytes.rate g B/s inst ID p 1, 2, 3 Average volume of writes in B per second
|
||||
disk.device.read.requests c request disk ID p 1, 2 Number of read requests per device
|
||||
disk.device.read.requests.rate g request/s disk ID p 1, 2, 3 Average rate of read requests per second per device
|
||||
disk.device.write.requests c request disk ID p 1, 2 Number of write requests per device
|
||||
disk.device.write.requests.rate g request/s disk ID p 1, 2, 3 Average rate of write requests per second per device
|
||||
disk.device.read.bytes c B disk ID p 1, 2 Volume of reads in B per device
|
||||
disk.device.read.bytes.rate g B/s disk ID p 1, 2, 3 Average rate of reads in B per second per device
|
||||
disk.device.write.bytes c B disk ID p 1, 2 Volume of writes in B per device
|
||||
disk.device.write.bytes.rate g B/s disk ID p 1, 2, 3 Average volume of writes in B per second per device
|
||||
disk.root.size g GB inst ID n 1, 2 Size of root disk in GB
|
||||
disk.ephemeral.size g GB inst ID n 1, 2 Size of ephemeral disk in GB
|
||||
network.incoming.bytes c B iface ID p 1, 2 Number of incoming bytes on a VM network interface
|
||||
network.incoming.bytes.rate g B/s iface ID p 1, 2, 3 Average rate per sec of incoming bytes on a VM network interface
|
||||
network.outgoing.bytes c B iface ID p 1, 2 Number of outgoing bytes on a VM network interface
|
||||
network.outgoing.bytes.rate g B/s iface ID p 1, 2, 3 Average rate per sec of outgoing bytes on a VM network interface
|
||||
network.incoming.packets c packet iface ID p 1, 2 Number of incoming packets on a VM network interface
|
||||
network.incoming.packets.rate g packet/s iface ID p 1, 2, 3 Average rate per sec of incoming packets on a VM network interface
|
||||
network.outgoing.packets c packet iface ID p 1, 2 Number of outgoing packets on a VM network interface
|
||||
network.outgoing.packets.rate g packet/s iface ID p 1, 2, 3 Average rate per sec of outgoing packets on a VM network interface
|
||||
=============================== ===== ========= ======== ======== ========== ==================================================================
|
||||
|
||||
::
|
||||
|
||||
|
@ -92,6 +92,14 @@ ceilometer.poll.compute =
|
||||
disk.write.requests.rate = ceilometer.compute.pollsters.disk:WriteRequestsRatePollster
|
||||
disk.read.bytes.rate = ceilometer.compute.pollsters.disk:ReadBytesRatePollster
|
||||
disk.write.bytes.rate = ceilometer.compute.pollsters.disk:WriteBytesRatePollster
|
||||
disk.device.read.requests = ceilometer.compute.pollsters.disk:PerDeviceReadRequestsPollster
|
||||
disk.device.write.requests = ceilometer.compute.pollsters.disk:PerDeviceWriteRequestsPollster
|
||||
disk.device.read.bytes = ceilometer.compute.pollsters.disk:PerDeviceReadBytesPollster
|
||||
disk.device.write.bytes = ceilometer.compute.pollsters.disk:PerDeviceWriteBytesPollster
|
||||
disk.device.read.requests.rate = ceilometer.compute.pollsters.disk:PerDeviceReadRequestsRatePollster
|
||||
disk.device.write.requests.rate = ceilometer.compute.pollsters.disk:PerDeviceWriteRequestsRatePollster
|
||||
disk.device.read.bytes.rate = ceilometer.compute.pollsters.disk:PerDeviceReadBytesRatePollster
|
||||
disk.device.write.bytes.rate = ceilometer.compute.pollsters.disk:PerDeviceWriteBytesRatePollster
|
||||
cpu = ceilometer.compute.pollsters.cpu:CPUPollster
|
||||
cpu_util = ceilometer.compute.pollsters.cpu:CPUUtilPollster
|
||||
network.incoming.bytes = ceilometer.compute.pollsters.net:IncomingBytesPollster
|
||||
|
Loading…
x
Reference in New Issue
Block a user