I am running the following command to get the number of processors/cores in Linux:
cat /proc/cpuinfo | grep processor | wc -l
nproc is what you are looking for.
nproc
More here : http://www.cyberciti.biz/faq/linux-get-number-of-cpus-core-command/