Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can use 'prtdiag' to get number of CPU by prtdiag command.

$ prtdiag
System Configuration:  Sun Microsystems  sun4u Sun Fire 6800
System clock frequency: 150 MHz
Memory size: 4096 Megabytes

========================= CPUs 
===============================================

             CPU      Run    E$   CPU      CPU
FRU Name    ID       MHz    MB   Impl.    Mask
----------  -------  ----  ----  -------  ----
/N0/SB1/P2    6      1200   8.0  US-III+  11.0
/N0/SB1/P3    7      1200   8.0  US-III+  11.0
/N0/SB3/P2   14      1200   8.0  US-III+  11.0
/N0/SB3/P3   15      1200   8.0  US-III+  11.0

But, I don't know is there any command could get the number (4 in this example)to let my script use it?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

With modern CPUs and their multi-core, multi-thread technologies, you need to define more precisely what you want to count but in your case, psrinfo better suits the job:

psrinfo -p

Note that prtdiag wasn't designed to be parseable and might return a very different output depending on the hardware.

share|improve this answer
    
For numbers of cores/threads, I often do psrinfo -v | grep -c on-line which isn't the cleanest solution, but it's always worked for me. –  alanc Mar 14 '13 at 6:06
add comment

How about

prtdiag | grep -c "^/"

To use the resulting value in a script, use $(prtdiag | grep -c "^/").

share|improve this answer
add comment

Here is a good script to find all the CPU, cores, virtual CPU (threads)

https://blogs.oracle.com/mandalika/entry/solaris_show_me_the_cpu

share|improve this answer
    
Adding the script from the link would improve the answer. Links do break and then your answer is of no use. –  Dave M Dec 18 '13 at 14:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.