[内容] Linux CPU 详细信息的显示

内容一:显示 Linux CPU 详细信息
1.1 显示 Linux CPU 详细信息

# cat /proc/cpuinfo

或者:

# lscpu

1.2 /proc/cpuinfo 文件里或者 lscpu 命令里重要参数

1) processor,逻辑核心 ID
2) physical id,物理封装 CPU ID 也就是 CPU socket ID
3) core ID,物理核心 ID
4) cpu cores 物理封装 CPU 也就是 CPU socket 里的物理核心数量
5) siblings 物理封装 CPU 也就是 CPU socket 里的逻辑核心数量

内容二:显示 Linux CPU 详细信息的案例
2.1 显示 Linux CPU 详细信息

# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 1
model name	: AMD Ryzen 7 1700 Eight-Core Processor
stepping	: 1
microcode	: 0x8001138
cpu MHz		: 1371.214
cache size	: 512 KB
physical id	: 0
siblings	: 16
core id		: 0
cpu cores	: 8
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
bugs		: sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 5987.93
TLB size	: 2560 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate eff_freq_ro [13] [14]

......
# cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1
processor	: 2
processor	: 3
processor	: 4
processor	: 5
processor	: 6
processor	: 7
processor	: 8
processor	: 9
processor	: 10
processor	: 11
processor	: 12
processor	: 13
processor	: 14
processor	: 15
# cat /proc/cpuinfo | grep 'physical id'
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
# cat /proc/cpuinfo | grep 'core id'
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7
# cat /proc/cpuinfo | grep 'cpu cores'
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
# cat /proc/cpuinfo | grep 'siblings'
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16

2.2 理解显示的 CPU 详细信息

1) processor 的数字从 0 到 15,代表有 16 个逻辑核心
2) physical id 的数字都是 0,代表只有 1 个物理封装 CPU ID 也就是 CPU socket ID
3) core id 的数字从 0 到 7,代表有 8 个物理核心
4) cpu cores 的数字都是 8,代表每 1 个物理封装 CPU 也就是 CPU socket 里有 8 个物理核心
5) siblings 的数字都是 8,代表每 1 个物理封装 CPU 也就是 CPU socket 里有 16 个逻辑核心
6) 简单的理解:1 个 CPU,8 个物理核心,16 个逻辑核心

[命令] Linux 命令 mtr (检测网络联通性)

案例一:一直测试某 1 个 IP 地址的联通性并边测试边显示状况

# mtr -n 8.8.8.8

或者:

# mtr --no-dns 8.8.8.8


补充:
1) 这里以测试 8.8.8.8 IP 地址为例
2) -n 和 –no-dns 参数代表不使用 DNS 解析主机名

案例二:测试某 1 个 IP 地址 100 次的联通性并边测试边显示状况

# mtr -nc 100 8.8.8.8

或者:

# mtr --no-dns --report-cycles 100 8.8.8.8


补充:
1) 这里以测试 8.8.8.8 IP 地址为例
2) -n 和 –no-dns 参数代表不使用 DNS 解析主机名
3) -c 和 –report-cycles 参数代表指定次数

案例三:测试某 1 个域名 100 次的联通性并显示最终报告

# mtr -nrc 100 eternalcenter.com

或者:

# mtr --no-dns --report --report-cycles 100 eternalcenter.com


补充:
1) 这里以测试 eternalcenter.com 域名为例
2) -n 和 –no-dns 参数代表不使用 DNS 解析主机名
3) -r 和 –report 参数代表生成最终报告
4) -c 和 –report-cycles 参数代表指定次数

案例四:测试某 1 个域名 TCP 443 端口 100 次的联通性并显示最终报告

# mtr -TP 443 -nrc 100 eternalcenter.com

或者:

# mtr --tcp --port 443 --no-dns --report --report-cycles 100 eternalcenter.com


补充:
1) 这里以测试 eternalcenter.com 域名的 443 端口为例
2) -n 和 –no-dns 参数代表不使用 DNS 解析主机名
3) -r 和 –report 参数代表生成最终报告
4) -c 和 –report-cycles 参数代表指定次数
5) -T 和 –tcp 参数代表指定 TCP
6) -P 和 –port 参数代表指定端口号

[命令] Linux 命令 nc (检查网络端口的联通性)

案例一:检查某 1 个域名某 1 个 TCP 端口的联通性

# nc -v -z eternalcenter.com 443

(补充:这里以检测 eternalcenter.com 域名的 TCP 443 端口为例)

案例二:检查某 1 个 IP 地址某 1 个 TCP 端口的联通性

# nc -v -z 8.8.8.8 443

(补充:这里以检测 8.8.8.8 IP 地址的 TCP 443 端口为例)

案例三:检查某 1 个域名某 1 个 UDP 端口的联通性

# nc -v -z -u eternalcenter.com 69

(补充:这里以检测 eternalcenter.com 域名的 UDP 69 端口为例)

案例四:检查某 1 个 IP 地址某 1 个 UDP 端口的联通性

# nc -v -z -u 8.8.8.8 69

(补充:这里以检测 8.8.8.8 IP 地址的 UDP 69 端口为例)