Find the answer to your Linux question:
Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By prabinseth
We are working on our subscription renewal and now since Red Hat has changed their subscription model we need to give them the number of physical CPU sockets on each ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    1

    How do I get the physical CPU socket count in RHEL?


    We are working on our subscription renewal and now since Red Hat has changed their subscription model we need to give them the number of physical CPU sockets on each system.

    I have tried looking thru /proc/cpuinfo as well as tried to parse data out from dmidecode but both of those solutions count each individual core as a CPU.

    Is there a clean and easy way to determine the number of sockets on each system? We also use RHN Satellite to manage our systems but I believe that is pulling the same data from dmidecode.

    Help!

  2. #2
    Just Joined!
    Join Date
    Jul 2011
    Location
    Kolkata, India
    Posts
    1

    Wink how to get number of physical CPUs / socketed CPUs / number of cores

    Hi all,

    As i have seen in so many complicated processes / apps to get number of physically socketed CPUs. But guys, i think its really simple to get the stats.Here are my 2 cents..

    1. number of physical processors :

    # cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l

    2. number of cores :

    # cat / proc/cpuinfo | grep "cpu cores" | uniq

    3. find if ht enabled

    # cat /proc/cpuinfo | grep "ht" | uniq

    if u see "ht" in flags then ht is enabled

    suppose cpuinfo gives u the numbers

    CPUs = 24 (0 to 23 )
    siblings in each CPU = 12
    CPU cores in each CPU = 6

    that means each CPU is hyper threading enabled.

    siblings (12 ) = cores (6) x hyper-threading (2)

    number of physical CPUs = 24 / 12 = 2 !


    chaos!
    prabin
    junix88 likes this.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,454
    Quote Originally Posted by prabinseth View Post
    Hi all,

    As i have seen in so many complicated processes / apps to get number of physically socketed CPUs. But guys, i think its really simple to get the stats.Here are my 2 cents..

    1. number of physical processors :

    # cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l

    2. number of cores :

    # cat / proc/cpuinfo | grep "cpu cores" | uniq

    3. find if ht enabled

    # cat /proc/cpuinfo | grep "ht" | uniq

    if u see "ht" in flags then ht is enabled

    suppose cpuinfo gives u the numbers

    CPUs = 24 (0 to 23 )
    siblings in each CPU = 12
    CPU cores in each CPU = 6

    that means each CPU is hyper threading enabled.

    siblings (12 ) = cores (6) x hyper-threading (2)

    number of physical CPUs = 24 / 12 = 2 !


    chaos!
    prabin
    Prabin, for your first posting here, this is awesome! Congratulations, and welcome to the forums!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    Jul 2011
    Posts
    1
    A little expansion on what was provided makes it scriptable


    Code:
    #!/bin/bash
    
    numCPU=`cat /proc/cpuinfo | grep -c processor`
    numPhys=`cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l`
    numCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
    cat /proc/cpuinfo | grep -q "ht"
    isHT=$?
    numThrd=1
    if [ $isHT -eq 0 ]
    then
    numThrd=2
    fi
    
    sibs=$(($numCores * $numThrd))
    socks=$(($numCPU / $sibs))
    
    echo "Physical sockets are $socks"

  5. #5
    Just Joined!
    Join Date
    Mar 2012
    Posts
    1
    Code:
    #!/bin/bash
    
    numCPU=`cat /proc/cpuinfo | grep -c processor`
    numPhys=`cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l`
    numCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
    cat /proc/cpuinfo | grep -q "ht"
    isHT=$?
    numThrd=1
    if [ $isHT -eq 0 ]
    then
    numThrd=2
    fi
    
    sibs=$(($numCores * $numThrd))
    socks=$(($numCPU / $sibs))
    
    ARR[1]="Physical sockets are $socks"
    
    case $numThrd in
    1)
    ARR[2]="Hyperthreading is NOT enabled"
    ;;
    2)
    ARR[2]="Hyperthreading is enabled"
    ;;
    esac
    
    ARR[3]="Number of cores not counting hyperthreads is $numCores"
    
    ARR[0]=""
    for i in $(seq 0 ${#ARR[*]}); do
    echo ${ARR[$i]}
    done

  6. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Micro tweak so it doesn't barf if there are no physical cores (VM)

    Code:
    #!/bin/bash
    
    numCPU=`cat /proc/cpuinfo | grep -c processor`
    numPhys=`cat /proc/cpuinfo | grep "physical id" | sort -n | uniq | wc -l`
    numCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
    if [ -Z $numCores ]; then
    numCores=0
    fi
    cat /proc/cpuinfo | grep -q "ht"
    isHT=$?
    numThrd=1
    if [ $isHT -eq 0 ]
    then
    numThrd=2
    fi
    
    sibs=$(($numCores * $numThrd))
    if [ $sibs -ne "0" ]; then
      socks=$(($numCPU / $sibs))
    else
      socks="0, Virtual Machine?"
    fi
    
    echo "Physical sockets are $socks"
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •