eMarcel.com

Oracle Database, Fusion Middleware, Linux

Show number of CPUs

#!/bin/bash
#This script will show you amount and name of CPUs including vmware cpu's if they exist.

name="$(
cat /proc/cpuinfo | awk -F: '
/vendor_id/ { vendor=$2 }
/model name/ { model=$2 }
/cpu MHz/ {
if ( model ~ "Hz" ) {speed=""} else { speed=$2 "MHz" };
print vendor, model, speed; }
' | tail -1
)"

num=$(
if [ -r /proc/vmware/cpuinfo ]
then
awk '/pcpu/ { print NF-1 }' /proc/vmware/cpuinfo
else
cat /proc/cpuinfo | grep processor| wc -l
fi
)

# ESX: mas info sobre logical/cores/packages
if [ -r /proc/vmware/sched/ncpus ]; then
cores=$( echo $( cat /proc/vmware/sched/ncpus ) )
fi

#clear

echo "
*************************************************************
*
* `echo $num CPUs $( echo "$name ($cores)" )`
*
*************************************************************
"
##EOF##

 

 

 

(Visited 27 times, 1 visits today)

Tweet
Share
+1
Share

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close