File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -395,10 +395,13 @@ getNumberOfPhysicalCPUCores() {
395395 fi
396396 else
397397 # Do something under GNU/Linux platform
398- CORESPERSOCKET=` lscpu | grep " Core(s) per socket" | awk ' {print $4}' `
399- SOCKETS=` lscpu | grep " Socket(s)" | awk ' {print $2}' `
398+ #
399+ # Gets the cores per socket by counting unique cores on socket 0.
400+ # Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments.
401+ CORESPERSOCKET=$( lscpu -p=cpu,socket | grep " ^[0-9]\+,0" | sort | uniq | wc -l)
402+ SOCKETS=$( lscpu -p=socket | grep -e " ^[0-9]" | sort | uniq | wc -l)
400403 fi
401- N=` bc <<< " $ {CORESPERSOCKET}*${SOCKETS}" `
404+ N=$(( $ {CORESPERSOCKET}* ${SOCKETS} ))
402405 echo " ${N} "
403406}
404407
You can’t perform that action at this time.
0 commit comments