Description of problem: Metrics for RHV 4 VMs get cpu_usagemhz_rate_average logged as 0. This causes NOR to show 0 for CPU: CPU Max 0 MHz High 0 MHz Average 0 MHz Low 0 MHz CPU Usage Max 36.00% High 2.86% Average 2.76% Low 2.67% vmdb_production=# select timestamp, cpu_usage_rate_average, cpu_usagemhz_rate_average from metrics where resource_name='cfme_58_vm_0' order by timestamp desc limit 5; timestamp | cpu_usage_rate_average | cpu_usagemhz_rate_average ---------------------+------------------------+--------------------------- 2017-09-01 18:35:20 | 3 | 0 2017-09-01 18:35:00 | 2 | 0 2017-09-01 18:34:40 | 3 | 0 2017-09-01 18:34:20 | 3 | 0 2017-09-01 18:34:00 | 2 | 0 (5 rows) Version-Release number of selected component (if applicable): 5.8.2.0 How reproducible: 100% Steps to Reproduce: 1.) Add RHV 4 Provider with running VMs, and enable C&U. 2.) Monitor cpu_usagemhz_rate_average in metrics table, and CPU values in NOR. Actual results: RHV 4 VMs show 0 MHz for CPU. Expected results: RHV 4 VMs show correct MHz for CPU. Additional info:
It looks like the problem is in the ovirt_metrics gem. The cpu_usagemhz_rate_average value is calculated in VmSamplesHistory: **** /opt/rh/cfme-gemset/gems/ovirt_metrics-1.4.1/lib/ovirt_metrics/models/vm_samples_history.rb: module OvirtMetrics class VmSamplesHistory < OvirtHistory belongs_to :host_configuration, :foreign_key => :current_host_configuration_version belongs_to :vm_configuration, :foreign_key => :vm_configuration_version def cpu_usagemhz_rate_average speed_of_host = self.host_configuration.try(:speed_in_mhz).to_f [...] speed_of_host * (self.cpu_usage_percent.to_f / 100.0) end **** speed_in_mhz is defined in HostConfiguration: **** /opt/rh/cfme-gemset/gems/ovirt_metrics-1.4.1/lib/ovirt_metrics/models/host_configuration.rb: module OvirtMetrics class HostConfiguration < OvirtHistory [...] GHZ_REGEX = /.*\@\s*(\d+\.\d+)GHz/ MHZ_REGEX = /.*\@\s*(\d+\.\d+)MHz/ def speed_in_mhz if self.cpu_model.respond_to?(:match) match = self.cpu_model.match(GHZ_REGEX) return (match[1].to_f * 1024) if match match = self.cpu_model.match(MHZ_REGEX) return match[1].to_f if match end return nil end end end **** The RHV 4 host that is causing this issue does not have a CPU speed within the cpu_model string: ovirt_engine_history=# select history_id, host_name, number_of_cores, cpu_speed_mh, cpu_model from host_configuration where history_id=4717; history_id | host_name | number_of_cores | cpu_speed_mh | cpu_model ------------+--------------+-----------------+--------------+----------------------------------------------- 4717 | host_mixed_1 | 4 | 2095 | Intel Celeron_4x0 (Conroe/Merom Class Core 2) (1 row) whereas a working host does: ovirt_engine_history=# select history_id, host_name, number_of_cores, cpu_speed_mh, cpu_model from host_configuration where history_id=123728; history_id | host_name | number_of_cores | cpu_speed_mh | cpu_model ------------+--------------------------------------+-----------------+--------------+------------------------------------------------- 123728 | qeblade32.rhq.lab.eng.bos.redhat.com | 8 | 2128 | Intel(R) Xeon(R) CPU L5518 @ 2.13GHz (1 row) So I guess this isn't a RHV version-specific issue so much as caused by how certain host models display their CPU Version host in dmidecode or however RHV captures the info to store in cpu_model. It seems strange to me that CFME is grepping for a GHz or MHz value in the cpu_model column of the host_configuration table, when the numeric cpu_speed_mh column also exists and would be more reliable.
https://github.com/ManageIQ/ovirt_metrics/pull/23
New commit detected on ManageIQ/ovirt_metrics/master: https://github.com/ManageIQ/ovirt_metrics/commit/73cd2e182762d9e3020e2b7f8e4c2fe8f4829b01 commit 73cd2e182762d9e3020e2b7f8e4c2fe8f4829b01 Author: Boris Odnopozov <bodnopoz> AuthorDate: Wed Nov 8 14:36:57 2017 +0200 Commit: Boris Odnopozov <bodnopoz> CommitDate: Wed Nov 29 10:07:33 2017 +0200 Fix fetching cpu speed Fix fetching cpu speed. This is to resolve: https://bugzilla.redhat.com/show_bug.cgi?id=1487735 lib/ovirt_metrics/models/host_configuration.rb | 14 - lib/ovirt_metrics/models/host_samples_history.rb | 2 +- lib/ovirt_metrics/models/vm_samples_history.rb | 2 +- spec/models/host_configuration_spec.rb | 31 -- spec/models/host_samples_history_spec.rb | 20 +- spec/models/vm_disk_samples_history_spec.rb | 8 +- spec/models/vm_samples_history_spec.rb | 11 +- spec/schemas/schema_rhev30.rb | 655 ----------------------- spec/support/active_record.rb | 6 - 9 files changed, 19 insertions(+), 730 deletions(-) delete mode 100644 spec/models/host_configuration_spec.rb delete mode 100644 spec/schemas/schema_rhev30.rb
https://github.com/ManageIQ/manageiq/pull/16616
New commit detected on ManageIQ/manageiq/master: https://github.com/ManageIQ/manageiq/commit/34a1528e9536b81ad74b1645dce8186df4e6cafb commit 34a1528e9536b81ad74b1645dce8186df4e6cafb Author: Boris Odnopozov <bodnopoz> AuthorDate: Thu Dec 7 13:29:49 2017 +0200 Commit: Boris Odnopozov <bodnopoz> CommitDate: Thu Dec 7 13:29:49 2017 +0200 Bumping the ovirt_metrics gem version Several bug fixes are included in the new release, including: https://bugzilla.redhat.com/show_bug.cgi?id=1495133 https://bugzilla.redhat.com/show_bug.cgi?id=1487735 Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)