LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2006, 06:34 PM   #16
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128

Fair enough.
 
Old 08-26-2006, 06:46 PM   #17
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
dmidecode ???
 
Old 08-26-2006, 06:51 PM   #18
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
uname might help.

man uname

uname -a

edit:
aix version of uname has option -M for processor model.

Last edited by schneidz; 12-16-2008 at 12:42 PM.
 
Old 01-09-2007, 08:08 PM   #19
cigarstub
Member
 
Registered: Sep 2005
Posts: 145

Rep: Reputation: 15
I tried the command cpuspeed but seemingly it's just
it will help you to get the speed and control priority of a daemon, you can set the max speed for a program


I am surprised (emotion just come when I realize some thing , "passing through my sense", I have my conception that deny death of itself ,it do not deny if death happen in other)
how to liberate ourself from these emotion to go faster in change , to feel the wind, to relax, to have fun? Please don't give any other emotion, I should deny emotion by be calm rather than contradict or escape it
 
Old 08-06-2007, 07:57 PM   #20
wmjosiah
LQ Newbie
 
Registered: Aug 2007
Location: Winchester, NH
Distribution: ubuntu
Posts: 3

Rep: Reputation: 0
Smile

I want an easy way to get the number of CPUs from a machine. The problem I have is that the info "cpu cores" is not there for every machine... in fact, it seems to only be there for multi-core processors. From an older dual Xeon (Woodcrest, I think):

processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 7
cpu MHz : 2400.210
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr
bogomips : 4802.15

processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 7
cpu MHz : 2400.210
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr
bogomips : 4798.01

If somebody has a clever little shell-scripting way to get the number of CPUs out of that, that would be great... or another command to do so. I mean, I know I can just look through it and find the last instance of "processor" and then add one to the number following the last instance of that... but perhaps there's an easier way... or I could just stop being lazy and learn how to do this right
 
Old 08-06-2007, 10:55 PM   #21
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You could do this:
Code:
cat /proc/cpuinfo | grep '^processor' | wc -l
 
Old 08-07-2007, 08:23 AM   #22
wmjosiah
LQ Newbie
 
Registered: Aug 2007
Location: Winchester, NH
Distribution: ubuntu
Posts: 3

Rep: Reputation: 0
Sweet!

That's exactly what I want. I didn't know the "wc" command. Thanks so much!

Quote:
Originally Posted by Matir
You could do this:
Code:
cat /proc/cpuinfo | grep '^processor' | wc -l
 
Old 08-07-2007, 05:45 PM   #23
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Wow the original post was almost 2 years ago......
Talk about a delayed response
 
Old 10-24-2008, 02:20 PM   #24
MeMooMeM
LQ Newbie
 
Registered: May 2005
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by exvor View Post
Wow the original post was almost 2 years ago......
Talk about a delayed response
Let's keep it alive then

Can /proc/cpuinfo show number of distinct processors? How does it separate from a dual core machine from a two processor machine?
 
Old 10-24-2008, 07:16 PM   #25
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by MeMooMeM View Post
Let's keep it alive then

Can /proc/cpuinfo show number of distinct processors? How does it separate from a dual core machine from a two processor machine?
What separates a dual core from two singles? Not the two cores. It's the on-chip resources that might be shared in the dual core. If you can't tell the difference from /proc/cpuinfo then the distinction is elsewhere, i.e. unrelated to the cores.
ta0kira
 
Old 10-24-2008, 07:48 PM   #26
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by MeMooMeM View Post
Let's keep it alive then

Can /proc/cpuinfo show number of distinct processors? How does it separate from a dual core machine from a two processor machine?
yes, look at "physical id". Unique values mark a physical processor.
 
Old 12-15-2008, 06:09 AM   #27
Uxinn
Member
 
Registered: May 2008
Location: Iceland
Distribution: Ubuntu Hardy
Posts: 47

Rep: Reputation: 16
Yes, let's keep this alive

Good idea to have a script at hand to fetch hardware info
started a small script to fetch some info.. work in progress

Code:
#!/bin/bash

CPU_COUNT=`grep physical\ id /proc/cpuinfo |sort -u|wc -l`
CORE_COUNT=`grep core\ id /proc/cpuinfo |sort -u|wc -l`
CPU_VENDOR=`grep vendor_id /proc/cpuinfo|awk '{print $3}'|sort -u`
MEMORY_KB=`grep MemTotal: /proc/meminfo|awk '{ print $2 }'`
MEMORY_GB=`echo $MEMORY_KB / 1000000|bc`"G"

if [ $CPU_VENDOR == 'GenuineIntel' ]; then
   CPU_VENDOR="Intel"
elif [ $CPU_VENDOR == 'AuthenticAMD' ]; then
   CPU_VENDOR="AMD"
fi

echo "CPU COUNT: " $CPU_COUNT
echo "CORE PER CPU: " $CORE_COUNT
echo "CPU VENDOR: " $CPU_VENDOR
echo "Total Memory: " $MEMORY_GB
 
Old 12-15-2008, 08:04 AM   #28
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
http://kobesearch.cpan.org/htdocs/Li...x/Cpuinfo.html
 
Old 12-15-2008, 04:07 PM   #29
MeMooMeM
LQ Newbie
 
Registered: May 2005
Posts: 8

Rep: Reputation: 0
Smile But... no physical ID in /proc/cpuinfo?

Quote:
Originally Posted by Uxinn View Post
Yes, let's keep this alive
Good idea to have a script at hand to fetch hardware info
started a small script to fetch some info.. work in progress
We are almost there... Well, I have access to two machines:

(A) A dual processor Opteron, single core on each.
(B) An Intel core-duo with dual core on a single processor.

I checked the cpuinfo on each. Machine A does not have a 'physical id' entry at all. Machine B has two such entries, both of which are zero, but not unique values as stated by BrianK.

The script only counts the rows, but doesn't check for unique IDs, so it can work correctly on Machine B. But it returns zero CPU COUNT and CORE PER CPU on Machine A.

I am assuming (just speculating) that machines that don't have dual(or multi) cores don't report physical ID in the cpuinfo. If this is the case, the script could check for the existence of this entry, and if none, it can report back only the number of rows with 'processor', and 1 as core per CPU.

Thank you BrianK for the physical ID idea and Uxinn for the script!
 
Old 12-16-2008, 06:05 AM   #30
Uxinn
Member
 
Registered: May 2008
Location: Iceland
Distribution: Ubuntu Hardy
Posts: 47

Rep: Reputation: 16
I tried the perl library, I think it is a bit outdated, but I prefer not needing to install any extras on the machines to make this work - So I stick to bash.

Here is an updated version with some more detail - a bit dirty, but that can be cleaned later.

Code:
#!/bin/bash

CPU_COUNT=`grep physical\ id /proc/cpuinfo |sort -u|wc -l`
CORE_COUNT=`grep core\ id /proc/cpuinfo |sort -u|wc -l`
CPU_MODEL=
CPU_VENDOR=`grep vendor_id /proc/cpuinfo|awk '{print $3}'|sort -u`
CPU_FREQ=`cat /proc/cpuinfo | grep "cpu MHz" | sort -u|sed 's/[^0-9\.]//g'`
OS_BIT=`uname -m`
KERNEL_VERSION=`uname -rsv`

#These are the distros I can test, don't have others installed
OS=`egrep -i 'red\ hat|suse|centos|ubuntu|debian' /etc/issue`

MEMORY_KB=`grep MemTotal: /proc/meminfo|awk '{ print $2 }'`
MEMORY_MB=`echo $MEMORY_KB / 1024|bc`"M"

if [ $OS_BIT == 'x86_64' ]; then
   OS_BIT="64bit"
else
   OS_BIT="32bit"
fi

if [ $CPU_COUNT == 0 ]; then
   CPU_COUNT=1
   CORE_COUNT=1
fi

if [ $CPU_VENDOR == 'GenuineIntel' ]; then
   CPU_VENDOR="Intel"
   CPU_TYPE=`grep model\ name /proc/cpuinfo|sort -u|awk '{print $5" "$7 $8 $9}'`
elif [ $CPU_VENDOR == 'AuthenticAMD' ]; then
   CPU_VENDOR="AMD"
   CPU_TYPE=`grep model\ name /proc/cpuinfo|sort -u|awk '{print $4 " " $5 " " $7}'`
fi


   echo "CPU COUNT: " $CPU_COUNT
   echo "CORE PER CPU: " $CORE_COUNT
   echo "CPU VENDOR: " $CPU_VENDOR
   echo "CPU Type: " $CPU_TYPE
   echo "Platform: " $OS_BIT
   echo "Operating System: " $OS
   echo "Kernel Version: " $KERNEL_VERSION
   echo "Total Memory: " $MEMORY_MB
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find how many CPU's are active in 8 CPU Linux machine sumit_sinha Linux - General 11 03-29-2011 10:53 AM
CPU information structure alltime Programming 2 10-31-2005 05:58 AM
Multithreaded System On 4 Cpu Linux Machine, process stuck on certain thread eyalzm Programming 1 05-10-2004 11:46 AM
Switching off a CPU of a multiple CPU machine kravisudhakar Linux - General 1 12-26-2003 10:13 AM
CPU#0:Machine Check Exception karamboul Linux - Software 1 03-29-2002 10:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration