How-To Geek
Get the Processor Type on Solaris
It’s easy to get the type of processor that a Solaris box is running on. While this might seem like a silly thing to need to know, if you are connected into a Solaris server at a remote location, you may need to know what type of processor is being used in order to install the correct packages.
uname -p
The uname command gives information about the current system.
Example on an Intel box:
# uname -p
i.386
Example on an Sun Sparc box:
# uname -p
sparc
Got Feedback? Join the discussion at discuss.howtogeek.com
Comments (11)
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 12/1/06




As part of script I’ve made to automatically get HW details of our servers (HP9000, Solaris, Fujitsu, AIX,…) this function give you information about processor number, type and speed:
function sunos_hw_CPU {
typeset num=$( psrinfo | wc -l )
typeset tipo=$(
prtconf -pvPD | egrep -e “device_type.*cpu|name” |
sed -n “/device_type/{n;p;}” | awk -F\’ ‘{ print $2 }’ |
sed -e “s/SUNW,//” | head -1
)
if [ "$tipo" == "cpu" ]
then
tipo=$(
prtconf -pvPD | egrep -e “device_type.*cpu|compatible” |
sed -n “/device_type/{n;p;}” | awk -F\’ ‘{ print $2 }’ |
sed -e “s/SUNW,//” | head -1
)
fi
typeset freq=$(
/usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//” |
head -1
)
echo $num \”$tipo $freq\”
}
# sunos_hw_CPU
16 “UltraSPARC-IV 1350 MHz”
Enjoy it ;-) !
Alex, thanks!
That’s a great script… I might convert it into linux…
As part of the same script, I’ve done this function for Linux (including VMware ESX servers):
function linux_hw_CPU {
typeset num=0
typeset name=”"
typeset cores=”"
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
echo $num $( echo “$name ($cores)” | enclose )
}
For example, in one of our ESX box, I get:
32 “GenuineIntel Intel(R) Xeon(TM) CPU 3.00GHz (32 logical 16 cores 8 packages)”
(ESX is nice, it gives me information about chip, cores and also logical (that is because hyperthreading is activates on that box).
A normal linux server (not ESX) would give something more simple like:
2 “GenuineIntel Pentium III (Coppermine) 696.417 MHz ()”
Hope it helps
Alex : ¿ Its posible to get the complete set of scripts to identify the hw?..thanks in advance
What if you have a 64 bit dual core CPU and you are running a non SMP kernel , the script will show only 1 CPU.
Is there a way to get the details from hardware ?
On linux , dmidecode -s processor-version will give you the CPU count , however how to find out if its a single or multicore processor
@Keith: I believe that if you use a non-SMP kernel, your OS won’t be able to see more than 1 CPU, so you won’t be able to get more information about CPU, unless maybe you use vendor specific drivers.
If you use a SMP kernel, you may be able to get information about the number of chips and the number of cores of each cpu chip using /proc/cpuinfo. Look at how I actually decode it in my script:
function enclose {
tr -s ” ” | sed -e “s/^/\”/; s/$/\”/; s/\”\ /\”/; s/\ \”/\”/”
}
function linux_hw_CPU {
typeset num=0
typeset name=”"
typeset cores=”"
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
)
if grep -q “physical id” /proc/cpuinfo || grep “siblings” /proc/cpuinfo
then
chip_count=$( grep “physical id” /proc/cpuinfo | sort -u | wc -l )
chip_core=$( grep “siblings” /proc/cpuinfo | tail -1 | cut -d: -f2 )
cores=”($chip_count chips x $chip_core cores)”
fi
# Blades HP con
if [ -x /sbin/hpasmcli ]
then
chip_name=$( /sbin/hpasmcli -s “SHOW SERVER” | grep “Name” | head -1 | cut -d: -f2 )
chip_speed=$( /sbin/hpasmcli -s “SHOW SERVER” | grep “Speed” | head -1 | cut -d: -f2 )
chip_core=$( /sbin/hpasmcli -s “SHOW SERVER” | grep “Core” | head -1 | cut -d: -f2 )
fi
# ESX: mas info sobre logical/cores/packages
if [ -r /proc/vmware/sched/ncpus ]
then
cores=”($( echo $( cat /proc/vmware/sched/ncpus ) ))”
fi
# Linux Itanium IA64
if grep -q -i itanium /proc/cpuinfo
then
name=”$(
grep “vendor” /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
grep “arch ” /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
grep “family” /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
grep “cpu MHz” /proc/cpuinfo | cut -d: -f2- | cut -d. -f1 | tail -1 ) Mhz”
chip_count=$( grep “physical id” /proc/cpuinfo | sort -u | wc -l )
chip_core=$( grep “siblings” /proc/cpuinfo | tail -1 | cut -d: -f2 )
cores=”($chip_count chips x $chip_core cores)”
fi
echo $num $( echo “$name $cores” | enclose )
}
linux_hw_CPU
For example:
# linux_hw_CPU
8 “GenuineIntel Intel(R) Xeon(R) CPU E5345 @ 2.33GHz (2 chips x 4 cores)”
Hello guys,
Thanks alot for your great work! Anyone managed to differentiate the number of socket/core/threads on Sun CMT processors?
Hi,
Physical disks on sun solaris : psrinfo -p
@Alex,
Great script. But if you have CPUs with different frequencies, then it will NOT work. For getting the Frequency, you’ve used the below command:
/usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//” | head -1
This will result in:
$ /usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//” | head -1
1200 MHz
However, when I check, I’ve got 8 CPUs – 4 with 1200 MHz and 4 others with 900 MHz
$ /usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//”
1200 MHz
1200 MHz
1200 MHz
1200 MHz
900 MHz
900 MHz
900 MHz
900 MHz
You can perhaps use something like:
/usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//” | uniq
or
/usr/sbin/psrinfo -v| grep operate | sed -e “s/.*at //;s/,//” | sort -u
using the above commands for frequency, I get the below output:
$ ./sunos_cpu_info
8 “UltraSPARC-III+ 1200 MHz 900 MHz”
Anyway, thanks a lot for your wonderful script (for both Linux & Solaris!)
@ Alex, I’m referring to your first post!
Really usefull scripts for Linux and Solaris.
I have been trying to determine the number of cores in a system with Sparc T2 cpus.
These cpus hav 4,6 or 8 cores per cpu
psrinfo -pv | wc -l will return 32, this is the number of threads, if I divide 32 by 2 I get 16 !
Does this mean I have 4 4 core cpus or do I have 2 8 core cpus?
Am I missing something?
/Hogmaster