How can I get numbers of CPU of Sun Solaris by command?
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.
Here is a simple set of pipes using psrinfo
:
psrinfo -v | grep ^Status | tail -1 | awk '{x = $5 + 1; print "CPUs: " x;}'
Example output:
CPUs: 6