CPU Count | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

CPU Count

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-02-2012
Duffs22 Duffs22 is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 31 January 2014, 5:16 AM EST
Posts: 112
Thanks: 18
Thanked 1 Time in 1 Post
CPU Count

Hi,

I am observing high load average on RHEL5 server and need to check the number of core processors available on the box to give me a bigger picture on whether or not I should be worried.

I have always checked the physical count quite simply.....

# grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l
1

....however can anyone confirm that the below output truely represents the actual number of core processors available on my server?

# cat /proc/cpuinfo | grep processor | awk '{a++} END {print a}'
8

R,
D.
Sponsored Links
    #2  
Old 02-02-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 July 2014, 6:27 PM EDT
Location: Saskatchewan
Posts: 18,988
Thanks: 750
Thanked 3,146 Times in 2,951 Posts
You get a useless use of cat award. And if you're using awk, why bother using grep?

I'd grep for something a little less generic than 'processor'. That might turn up in a CPU name or something potentially. And pin it to the beginning of the line where it should always be found.


Code:
 awk '/^cpu MHz/ { a++ } END { print a }' /proc/cpuinfo

Sponsored Links
    #3  
Old 02-02-2012
Duffs22 Duffs22 is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 31 January 2014, 5:16 AM EST
Posts: 112
Thanks: 18
Thanked 1 Time in 1 Post
I am aware of that so (without printing the entire cpuinfo) "processor : 7" equates to 8 core CPU's? - Just looking for a consensus/confirmation.
    #4  
Old 02-02-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 July 2014, 6:27 PM EDT
Location: Saskatchewan
Posts: 18,988
Thanks: 750
Thanked 3,146 Times in 2,951 Posts
It could mean one 8-core CPU, a pair of 4-core CPU's, four 2-core CPU's, or 8 1-core CPU's. Cores are counted individually. If you care which belongs in what chip, that's the physical ID.

If you just care about the number of cores, counting the line match like that will work fine.

In fact, you don't need to even match anything. Just count the number of records, splitting on blank lines, by setting RS to "". Then when awk runs out of input, print NR, the number of records. On my dual-core system:


Code:
$ awk -v RS="" 'END { print NR }' /proc/cpuinfo
2
$

Sponsored Links
    #5  
Old 02-02-2012
Duffs22 Duffs22 is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 31 January 2014, 5:16 AM EST
Posts: 112
Thanks: 18
Thanked 1 Time in 1 Post
Yip, simply looking for the number of cores which according to this is 8. Thing is though it does not correspond to what the hardware mgmt interface sayes?

# hpasmcli
HP management CLI for Linux (v2.0)
Copyright 2008 Hewlett-Packard Development Group, L.P.
hpasmcli> show server
System : ProLiant BL460c G6
Serial No. : GB8033X7FV
ROM version : I24 03/30/2010
iLo present : Yes
Embedded NICs : 2
NIC1 MAC: 78:e7:d1:65:3a:60
NIC2 MAC: 78:e7:d1:65:3a:64
Processor: 0
Name : Intel Xeon
Stepping : 5
Speed : 2933 MHz
Bus : 133 MHz
Core : 4
Thread : 8
Socket : 1
Level2 Cache : 1024 KBytes
Status : Ok
Processor total : 1

R,
D
Sponsored Links
    #6  
Old 02-02-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 28 July 2014, 6:27 PM EDT
Location: Saskatchewan
Posts: 18,988
Thanks: 750
Thanked 3,146 Times in 2,951 Posts
If you'd bothered posting your /proc/cpuinfo, I might be able to explain, but at present I can only guess.

Do your CPU's have hyperthreading? That will show up as double the number of cores in Linux.
Sponsored Links
    #7  
Old 02-02-2012
Duffs22 Duffs22 is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 31 January 2014, 5:16 AM EST
Posts: 112
Thanks: 18
Thanked 1 Time in 1 Post
Ok, cpuinfo attached...
Attached Files
File Type: txt cpuinfo.txt (6.4 KB, 14 views)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Count the delimeter from a file and delete the row if delimeter count doesnt match. Akumar1 Shell Programming and Scripting 5 08-31-2010 11:41 PM
count identical strings print last row and count dcfargo Shell Programming and Scripting 2 07-07-2010 10:36 AM
Getting Sum, Count and Distinct Count of a file singhabhijit Shell Programming and Scripting 4 03-01-2009 11:30 PM
Sorting using count, grep and count sukhpal_78 UNIX for Dummies Questions & Answers 2 06-27-2008 12:13 AM
How to count the record count in an EBCDIC file. oracle8 UNIX for Dummies Questions & Answers 1 07-26-2006 07:22 PM



All times are GMT -4. The time now is 04:41 AM.