[Linux] Linux check whether the machine is cpu or how many cores

Original: https://www.cnblogs.com/MC1225/p/8109354.html

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数
# 查看物理CPU个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l

View CPU information (model)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

 

View memory information
# cat /proc/meminfo

 

How many cores each cpu is (assuming the same cpu configuration)

more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l

cat /proc/cpuinfo | grep processor

1. View the number of physical CPUs
#cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l

2. View the number of logical CPUs
#cat /proc/cpuinfo |grep "processor"|wc- l

3. Check the CPU cores
#cat /proc/cpuinfo |grep "cores"|uniq

4. Check the CPU frequency
#cat /proc/cpuinfo |grep MHz|uniq

 

# uname -a

Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux

(View current operating system kernel information)

 


# cat /etc/issue | grep Linux

Red Hat Enterprise Linux AS release 4 (Nahant Update 5)

(View current operating system release information)

 


# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz

(Seeing that there are 8 logical CPUs, I also know the CPU model)

 


# cat /proc/cpuinfo | grep physical | uniq -c

4 physical id : 0

4 physical id : 1

(Description is actually two 4-core CPUs)

 


# getconf LONG_BIT

32

(It means that the current CPU is running in 32bit mode, but it does not mean that the CPU does not support 64bit)

 


# cat / proc / cpuinfo | grep flags | grep 'lm' | wc -l

8

(The result is greater than 0, indicating that 64bit calculation is supported. lm refers to long mode, and lm is 64bit if it supports lm)

 

The
output of the last line of sar -u 1 60 is the average of 60 times per minute
ATAE12:/home/collect/output # sar -u 1 10
Linux 2.6.16.54-0.2.12.2386.0.PTF.660233-smp ( ATAE12) 07/29/11

14:01:11 CPU %user %nice %system %iowait %idle
14:01:12 all 0.25 0.00 0.51 0.00 99.24
14:01:13 all 11.39 0.00 4.30 0.00 84.30
14:01:14 all 2.52 0.00 1.01 0.00 96.47
14:01:15 all 0.00 0.00 0.25 3.26 96.49
14:01:16 all 0.00 0.00 0.00 0.00 100.00
14:01:17 all 0.51 0.00 0.51 0.00 98.99
14:01:18          all      0.00      0.00      0.25      0.00     99.75
14:01:19          all      0.00      0.00      0.76      0.00     99.24
14:01:20          all      0.00      0.00      0.75      2.01     97.24
14:01:21          all      0.25      0.00      0.50      0.00     99.25
Average:          all      1.49      0.00      0.88      0.53     97.10

 

top is dynamic, vmstat is static

vmstat 1

uptime https://cloud.tencent.com/developer/article/1465399

Guess you like

Origin blog.csdn.net/bandaoyu/article/details/113520792