GabrielBrascher commented on a change in pull request #4958:
URL: https://github.com/apache/cloudstack/pull/4958#discussion_r624142836



##########
File path: 
plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java
##########
@@ -78,11 +80,12 @@ public long getOverCommitMemory() {
     }
 
     protected static long getCpuSpeed(final NodeInfo nodeInfo) {
-        try (final Reader reader = new FileReader(
-                "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")) {
-            return Long.parseLong(IOUtils.toString(reader).trim()) / 1000;
+        try (Reader reader = new FileReader(cpuInfoMaxFreqFileName)) {
+            Long cpuInfoMaxFreq = 
Long.parseLong(IOUtils.toString(reader).trim());
+            LOGGER.info(String.format("Retrieved value [%s] from file [%s]. 
Using the value divided by 1000 [%s] as CPU speed value.", cpuInfoMaxFreq, 
cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));

Review comment:
       This log is an interesting one. Also making it info seems reasonable as 
it is a piece of information regarding the agent and it logs only when the 
service starts.
   
   Regarding @sureshanaparti comment's, I am also thinking of some options that 
might be better than the `divided by 1000`.
   
   As an example, let's say that a host has a CPU speed of `2000 MHz`. The 
`cpuinfo_max_freq` file should then hold the value of `2000000` (at least 
that's what I get when running KVM on Ubuntu)
   
   In that example, it would then log:
   `Retrieved value [2000000] from file 
[/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq]. Using the value 
divided by 1000 [2000] as CPU speed value.`
   
   What do you think of changing to something such as:
   `Retrieved value [2000000] from file 
[/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq]. This corresponds to a 
CPU speed of 2000 MHz.`




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to