Re: command for finding out number of processors on a linux machine

Rich Wellner (wellner@fnal.gov)
Tue, 16 Nov 1999 18:28:35 -0600

Sergei Avvakumov <avva@miranda.fnal.gov> writes:

> > How do I tell if it's an SMP kernel?
>
> 'uname -a'
>
> for SMP you'll see something like:
>
> Linux miranda 2.2.12 #2 SMP Thu Sep 9 16:59:41 CDT 1999 i686 unknown
>
> for non SMP :
>
> Linux viola 2.2.13 #6 Mon Nov 8 14:53:28 EST 1999 i686 unknown

This is the right answer, but as a side note. Redhat, even in the
2.2.x series, defaults to a uniprocessor kernel in order to enable
e.g. power management. Therefore, you could, in the degenerate case,
have a multi-processor machine that 'uname -a' leads you to believe is
a uni-processor machine.

Something like:
----------------------------------------------------------
#! /bin/bash
smp=`uname -a|grep SMP|wc -l`
cpus=`grep -e 'processor.*: [0-9]' /proc/cpuinfo|wc -l`

if [ $smp -eq 0 ]; then
echo Uniprocessor kernel
echo You *may* have a rare, misconfigured machine with
echo several CPUs that we cannot know about
echo Open the box and do a nose count if you think that is true
else
echo You have an SMP kernel
echo It is running over $cpus CPUs
fi
----------------------------------------------------------

should be very blunder proof as it tells the user what their
configuration is believed to be and the situation in which the
information isn't known accurate.

rw2

-- 
Logically, life must be possible in the Universe. 
Else you would not be here. 
Assuming you are.