File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
server/src/main/java/com/cloud/server Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -974,8 +974,16 @@ private double[] getCpuLoads() {
974974 private double getSystemCpuCyclesTotal () {
975975 String cpucaps = Script .runSimpleBashScript ("cat /proc/cpuinfo | grep \" cpu MHz\" | grep \" cpu MHz\" | cut -f 2 -d : | tr -d ' '| tr '\\ n' \" \" " );
976976 double totalcpucap = 0 ;
977- for (String cpucap : cpucaps .split (" " )) {
978- totalcpucap += Double .parseDouble (cpucap );
977+ if (StringUtils .isEmpty (cpucaps )) {
978+ String totalCpus = Script .runSimpleBashScript ("nproc --all| tr '\\ n' \" \" " );
979+ String maxCpuSpeed = Script .runSimpleBashScript ("lscpu | egrep 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\ n' \" \" " );
980+ if (StringUtils .isNotEmpty (totalCpus ) && StringUtils .isNotEmpty (maxCpuSpeed )) {
981+ totalcpucap = Double .parseDouble (totalCpus ) * Double .parseDouble (maxCpuSpeed );
982+ }
983+ } else {
984+ for (String cpucap : cpucaps .split (" " )) {
985+ totalcpucap += Double .parseDouble (cpucap );
986+ }
979987 }
980988 return totalcpucap ;
981989 }
You can’t perform that action at this time.
0 commit comments