att-comdev / prometheus-openstack-exporter

Apache License 2.0
29 stars 18 forks source link

Error when get metrics Hypervisor #8

Open datnt53 opened 6 years ago

datnt53 commented 6 years ago

2018-10-25 08:56:22,440:ERROR:'HypervisorStats' object has no attribute 'extra_config' 2018-10-25 08:56:22,441:ERROR:failed to get data for cache key hypervisor_stats

                free = ((int(self.extra_config['cpu_ratio'] *
                             m_vcpus)) -
                        m_vcpus_used)

nova_aggregates[agg]['metrics']['free_vcpus'] += free

d819r197 commented 5 years ago

To fix this issue you will need to change the variable extra_config['cpu_ratio'] to self.cpu_overcommit_ratio We can see that a similar code is being called with correct variables; ree = (int(self.cpu_overcommit_ratio * m_vcpus)) - m_vcpus_used cache_stats.append({ 'stat_name': 'free_vcpus', 'stat_value': free, 'host': host, }) So if we match that, and produce: for agg in nova_aggregates.keys(): agg_hosts = nova_aggregates[agg]['hosts'] if host in agg_hosts: free = ((int(self.cpu_overcommit_ratio * m_vcpus)) - m_vcpus_used) nova_aggregates[agg]['metrics']['free_vcpus'] += free We find that the code is working properly. I will be submitting a patch for this to att-comdev, but until then this is the fix.

datnt53 commented 5 years ago

Thank a lot!