mirror of https://github.com/apache/cloudstack.git
kvm: Improve logs on agent start (#4958)
This PR intends to improve logging on agent start to facilitate troubleshooting. Co-authored-by: Daniel Augusto Veronezi Salvador <daniel@scclouds.com.br> Co-authored-by: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com>
This commit is contained in:
parent
85e4abf522
commit
2ececbf994
|
|
@ -42,6 +42,8 @@ public class KVMHostInfo {
|
|||
private long overCommitMemory;
|
||||
private List<String> capabilities = new ArrayList<>();
|
||||
|
||||
private static String cpuInfoMaxFreqFileName = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
|
||||
|
||||
public KVMHostInfo(long reservedMemory, long overCommitMemory) {
|
||||
this.reservedMemory = reservedMemory;
|
||||
this.overCommitMemory = overCommitMemory;
|
||||
|
|
@ -78,11 +80,12 @@ public class KVMHostInfo {
|
|||
}
|
||||
|
||||
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]. This corresponds to a CPU speed of [%s] MHz.", cpuInfoMaxFreq, cpuInfoMaxFreqFileName, cpuInfoMaxFreq / 1000));
|
||||
return cpuInfoMaxFreq / 1000;
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
LOGGER.info("Could not read cpuinfo_max_freq, falling back on libvirt");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue