Linux Shell script View numa information

Source: Internet
Author: User
Tags printf socket sort

This article mainly introduced the Linux Shell script view numa information, this article directly gives the script implementation code, needs the friend may refer to under

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

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 #!/bin/bash function Get_nr_processor () {grep ' ^processor '/proc/cpuinfo | wc-l} fun Ction 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 </proc/cpuinfo echo awk-f: ' {if ($ ~/processor/) {gsub (//, "", $); p_id=$2;} else if ($ ~ P Hysical Id/) {gsub (//, "", $); S_id=$2 arr[s_id]=arr[s_id] "" p_id}} end{for (i in arr) printf "Socket%s:%sn", I, AR R[i]; } '/proc/cpuinfo echo Echo ' ===== 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 _siblings "nr_cores= ' Get_nr_cores_of_socket ' echo" cores in one socket: $nr _cores "Let Nr_cores *=nr_socket echo "Cores in 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:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.