mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix NPE in management server logs due to /proc/cpuinfo output (#7765)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
6dd2ce86b5
commit
bde80f14aa
@ -974,8 +974,16 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
private double getSystemCpuCyclesTotal() {
|
||||
String cpucaps = Script.runSimpleBashScript("cat /proc/cpuinfo | grep \"cpu MHz\" | grep \"cpu MHz\" | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \"");
|
||||
double totalcpucap = 0;
|
||||
for (String cpucap : cpucaps.split(" ")) {
|
||||
totalcpucap += Double.parseDouble(cpucap);
|
||||
if (StringUtils.isEmpty(cpucaps)) {
|
||||
String totalCpus = Script.runSimpleBashScript("nproc --all| tr '\\n' \" \"");
|
||||
String maxCpuSpeed = Script.runSimpleBashScript("lscpu | egrep 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \"");
|
||||
if (StringUtils.isNotEmpty(totalCpus) && StringUtils.isNotEmpty(maxCpuSpeed)) {
|
||||
totalcpucap = Double.parseDouble(totalCpus) * Double.parseDouble(maxCpuSpeed);
|
||||
}
|
||||
} else {
|
||||
for (String cpucap : cpucaps.split(" ")) {
|
||||
totalcpucap += Double.parseDouble(cpucap);
|
||||
}
|
||||
}
|
||||
return totalcpucap;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user