You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/28 06:52:13 UTC

[GitHub] [cloudstack] davidjumani commented on a change in pull request #5506: kvm: Use lscpu to get cpu max speed

davidjumani commented on a change in pull request #5506:
URL: https://github.com/apache/cloudstack/pull/5506#discussion_r717274823



##########
File path: plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -85,8 +87,18 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
             LOGGER.info(String.format("Retrieved value [%s] from file [%s]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
             return cpuInfoMaxFreq / 1000;
         } catch (IOException | NumberFormatException e) {
-            LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), e);
-            return nodeInfo.mhz;
+            try {
+                LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s]. Trying to fetch it from lscpu",
+                    cpuInfoMaxFreqFileName), e);
+                String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";

Review comment:
       @weizhouapache I'll rearrange the CPU speed fetching stages




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org