正是因为看了代码,才觉得奇怪的。
轮寻获取代码如下,LibvirtInspector 默认确实是没实现 inspect_cpu_util 接口啊。
LibvirtInspector 只实现了 inspect_cpus 接口,那个是 cpu 个数。
我上封邮件,agent compute 日志里一直提示没有实现的。
另 master 分支也没实现的。
https://github.com/openstack/ceilometer/blob/master/ceilometer/compute/virt/libvirt/inspector.py
class CPUUtilPollster(plugin.ComputePollster):
def get_samples(self, manager, cache, resources):
self._inspection_duration = self._record_poll_time()
for instance in resources:
LOG.debug(_('Checking CPU util for instance %s'),
instance.id)
try:
cpu_info = manager.inspector.inspect_cpu_util(
instance, self._inspection_duration)
LOG.debug(_("CPU UTIL: %(instance)s %(util)d"),
({'instance': instance.__dict__,
'util': cpu_info.util}))
yield util.make_sample_from_instance(
instance,
name='cpu_util',
type=sample.TYPE_GAUGE,
unit='%',
volume=cpu_info.util,
)
except virt_inspector.InstanceNotFoundException as err:
# Instance was deleted while getting samples. Ignore it.
LOG.debug(_('Exception while getting samples %s'), err)
except NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug(_('Obtaining CPU Util is not implemented for %s'
), manager.inspector.__class__.__name__)
except Exception as err:
LOG.error(_('Could not get CPU Util for %(id)s: %(e)s'), (
{'id':
instance.id, 'e': err}))