Linux Shell Script View numa information _linux Shell

Source: Internet
Author: User

The

Nova provides NUMA-related advanced features under the NFV scenario, which provides a script to view the NUMA-related information for compute nodes.

#!/bin/bash function Get_nr_processor () {grep ' ^processor '/proc/cpuinfo | wc-l} function get_nr_socket () {grep ' Physical ID '/proc/cpuinfo | Awk-f: ' {print $ | "Sort-un"} ' | Wc-l} function Get_nr_siblings () {grep ' siblings '/proc/cpuinfo | awk-f: ' {print $ | ' Sort-un '} '} function Get_nr_cores_of_socket () {grep ' CPU cores '/proc/cpuinfo | awk-f: ' {print $ | "Sort-un"} '} echo ' ===== CPU topology Table ===== ' echo echo ' +--------------+---------+-----------+ ' echo ' | Processor ID | Core ID | Socket ID | ' echo ' +--------------+---------+-----------+ ' while read line; do if [-Z "$line"]; Then printf ' | %-12s | %-7s | %-9s |\n ' $p _id $c _id $s _id echo ' +--------------+---------+-----------+ ' continue fi if echo "$line" | Grep-q "^processor"; Then p_id= ' echo ' $line | Awk-f: ' {print $} ' | Tr-d ' ' fi if echo "$line" | Grep-q "^core id"; Then c_id= ' echo ' $line | Awk-f: ' {print $} ' | Tr-d ' ' fi if echo "$line" | Grep-q "^physical id"; Then s_id= ' echo ' $line | Awk-f: ' {print $} ' |
    Tr-d ' fi done </proc/cpuinfo echo Awk-f: ' {if ($ ~/processor/) {gsub (//, "", $);
  p_id=$2;
    else if ($ ~/physical Id/) {gsub (//, "", $);
    s_id=$2; ARR[S_ID]=ARR[S_ID] "p_id}} end{for (i in arr) printf" Socket%s:%s\n ", I, Arr[i];} '/proc/cpuinfo echo E Cho ' ===== CPU Info Summary ===== ' echo nr_processor= ' get_nr_processor ' echo ' Logical processors: $nr _processor ' Nr_socket = ' Get_nr_socket ' echo physical socket: $nr _socket "nr_siblings= ' get_nr_siblings ' echo" siblings in one socket: $nr _sibli  NGS "nr_cores= ' Get_nr_cores_of_socket ' echo" cores in one socket: $nr _cores "Let Nr_cores*=nr_socket echo" cores at Total: $NR _cores "If [" $nr _cores "=" $nr _processor "]; Then echo "Hyper-threading:off" Else echo "Hyper-threading:on" fi echo Echo ' ===== end ===== '


Query Results Sample:

===== CPU topology Table ===== +--------------+---------+-----------+ | Processor ID | Core ID |
Socket ID | +--------------+---------+-----------+
| 0 | 0 |
1 | +--------------+---------+-----------+
| 1 | 1 |
1 | +--------------+---------+-----------+
| 2 | 9 |
1 | +--------------+---------+-----------+
| 3 | 10 |
1 | +--------------+---------+-----------+
| 4 | 0 |
0 | +--------------+---------+-----------+
| 5 | 1 |
0 | +--------------+---------+-----------+
| 6 | 9 |
0 | +--------------+---------+-----------+
| 7 | 10 |
0 | +--------------+---------+-----------+
| 8 | 0 |
1 | +--------------+---------+-----------+
| 9 | 1 |
1 | +--------------+---------+-----------+
| 10 | 9 |
1 | +--------------+---------+-----------+
| 11 | 10 |
1 | +--------------+---------+-----------+
| 12 | 0 |
0 | +--------------+---------+-----------+
| 13 | 1 |
0 | +--------------+---------+-----------+
| 14 | 9 |
0 | +--------------+---------+-----------+
| 15 | 10 |
0 | +--------------+---------+-----------+ Socket 0:4 5 6 7 Socket 1:0 1 2 3 8 9 ===== CPU Info Summary = = = = Logical Processors:16 physical socket:2 siblings in one socket:8 cores into one socket:4 cores in Total:8 hyper-thr  Eading:on ===== End =====


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.