Linux系统信息相关
cpu
lscpu
可以查看cpu的架构,几级缓存等
lscpu
Architecture: x86_64 架构
CPU op-mode(s): 32-bit, 64-bit cpu运行模式
Byte Order: Little Endian 字节序
CPU(s): 24 多少核
On-line CPU(s) list: 0-23 在线cpu列表
Thread(s) per core: 1 每个核的线程数
Core(s) per socket: 12
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel 厂商
CPU family: 6 家族
Model: 62 型号
Stepping: 4
CPU MHz: 1200.000 cpu频率
BogoMIPS: 5399.26
Virtualization: VT-x
L1d cache: 32K 1级数据缓存
L1i cache: 32K 1级指令缓存
L2 cache: 256K 2级缓存
L3 cache: 30720K 3级缓存
NUMA node0 CPU(s): 0-11
NUMA node1 CPU(s): 12-23
/proc/cpuinfo
该文件保存了cpu的详细信息,每个核一块内容,有几个核,就会显示几个核的详细信息
cat /proc/cpuinfo
processor : 0 系统所有逻辑核id
vendor_id : GenuineIntel 厂家id
cpu family : 6
model : 62
model name : Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
stepping : 4
microcode : 1069
cpu MHz : 1200.000
cache size : 30720 KB
physical id : 0 物理cpu编号
siblings : 12 物理核个数
core id : 0 当前物理cpu逻辑核id
cpu cores : 12 逻辑核个数
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 dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips : 5399.82
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
...
#物理CPU个数
cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
#每个物理CPU物理核个数
cat /proc/cpuinfo | grep "cpu cores" | uniq
#每个物理CPU逻辑核个数
cat /proc/cpuinfo | grep "siblings" | uniq
#逻辑核个数
cat /proc/cpuinfo | grep "processor"| wc -l
网卡
/proc/meminfo
当前内存使用详情
cat /proc/meminfo
MemTotal: 16084640 kB
MemFree: 867408 kB
MemAvailable: 9729500 kB
Buffers: 458580 kB
Cached: 8717464 kB
SwapCached: 0 kB
Active: 3656372 kB
Inactive: 9565700 kB
Active(anon): 6240 kB
Inactive(anon): 4779520 kB
Active(file): 3650132 kB
Inactive(file): 4786180 kB
Unevictable: 697924 kB
Mlocked: 11200 kB
SwapTotal: 16777212 kB
SwapFree: 16777212 kB
Dirty: 896 kB
Writeback: 0 kB
AnonPages: 4742128 kB
Mapped: 1671604 kB
Shmem: 772268 kB
KReclaimable: 767396 kB
Slab: 957184 kB
SReclaimable: 767396 kB
SUnreclaim: 189788 kB
KernelStack: 34048 kB
PageTables: 65748 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 24819532 kB
Committed_AS: 18708556 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 71032 kB
VmallocChunk: 0 kB
Percpu: 6496 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 520700 kB
DirectMap2M: 13850624 kB
DirectMap1G: 2097152 kB
free -h
当前内存使用概况
free -h
total used free shared buff/cache available
Mem: 15Gi 5.0Gi 920Mi 737Mi 9.5Gi 9.4Gi
Swap: 15Gi 0B 15Gi
dmidecode -t memory
可以看到内存的详情,频率等信息
dmidecode -t memory
# dmidecode 2.12
SMBIOS 2.7 present.
Handle 0x002D, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Multi-bit ECC
Maximum Capacity: 96 GB
Error Information Handle: Not Provided
Number Of Devices: 8
Handle 0x002F, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x002D
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 16384 MB
Form Factor: DIMM
Set: None
Locator: P1_DIMMA1
Bank Locator: Node0_Bank0
Type: DDR3
Type Detail: Registered (Buffered)
Speed: 1866 MHz
Manufacturer: Samsung
Serial Number: 01A680F7
Asset Tag: Dimm0_AssetTag
Part Number: M393B2G70BH0-
Rank: 2
Configured Clock Speed: 1866 MHz
查看系统详细信息
lsb_release -a
查看网卡对应的pci(bus)地址
使用ethtool
ethtool -i eth0
直接查找
- 查看网卡信息
ip address
- 查看网卡的bus号
lspci |grep Eth
-
进入到/sys/bus/pci/devices
-
根据上面的bus号,挨个查看对应目录下的net/目录。net目录下的名字就是与ip address显示的名字对应
lspci
展示所有PCI设备信息[list all PCI devices]
lspci -t
展示层次结构
lspci -t
-+-[0000:bc]---00.0-[bd]--
+-[0000:bb]---00.0
+-[0000:ba]-+-00.0
| +-01.0
| \-02.0
+-[0000:b4]-+-01.0-[b5]----00.0
| +-02.0
| +-03.0
| \-04.0
+-[0000:80]-+-00.0-[81]--
| +-04.0-[82]--
| +-08.0-[83]--
| +-0c.0-[84]--
| \-10.0-[85]--
+-[0000:7c]---00.0-[7d]--+-00.0
| +-00.1
| +-00.2
| \-00.3
+-[0000:7b]---00.0
+-[0000:7a]-+-00.0
| +-01.0
| \-02.0
+-[0000:74]-+-01.0-[75]----00.0
| +-02.0
| +-03.0
| \-04.0
\-[0000:00]-+-00.0-[01-06]----00.0-[02-06]--+-00.0-[03]----00.0
| +-01.0-[04]----00.0
| +-02.0-[05]----00.0
| \-03.0-[06]----00.0
+-04.0-[07]--
+-08.0-[08]----00.0
+-0c.0-[09]--
+-10.0-[0a]----00.0
+-11.0-[0b]----00.0
\-12.0-[0c]--
lspci -k
展示加载的驱动模块
lspci -k
03:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
Subsystem: Huawei Technologies Co., Ltd. Device d136
Kernel driver in use: igb_uio
Kernel modules: hinic
04:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)
Subsystem: Huawei Technologies Co., Ltd. Device d136
Kernel driver in use: hinic
Kernel modules: hinic
上面可以看出一个是dpdk的igb_uio,一个是原生的hinic
lspci -nn
一个n是展示设备厂商id和设备id,两个n是增加文字内容描述
lspci -nn
03:00.0 Ethernet controller [0200]: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) [19e5:1822] (rev 45)
04:00.0 Ethernet controller [0200]: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) [19e5:1822] (rev 45)
确认硬件是否连接
有时候网卡没有加载,不确定是硬件没查好还是驱动有问题,可以使用如下命令查看,如果有信息,就表明硬件没问题,ip a没信息,表明驱动有问题
lspci | grep -i ethernet
/proc/net/dev
记录网络设备的统计信息
cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
enp125s0f3: 1472292 10003 0 1 0 0 0 628 3192 22 0 0 0 0 0 0
enp125s0f2: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
enp125s0f0: 1444445 11252 0 628 0 0 0 628 1317498 7523 0 0 0 0 0 0
lo: 14333963 94150 0 0 0 0 0 0 14333963 94150 0 0 0 0 0 0
enp6s0: 253080 740 0 0 0 0 0 0 383390 2319 0 0 0 0 0 0
enp125s0f1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
enp4s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
enp5s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
查询系统架构
uname -m
x86_64
查询系统版本
cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
测试磁盘读写速度
hdparm -Tt /dev/sda
/dev/sda:
Timing cached reads: 3140 MB in 1.99 seconds = 1574.39 MB/sec
Timing buffered disk reads: 386 MB in 3.01 seconds = 128.30 MB/sec
Timing cached reads是从缓存读取
Timing buffered disk是从物理盘读取
具体磁盘性能如何,可以与其他磁盘对比一下。上面的这个示例磁盘算是一般的磁盘。
好一些的磁盘性能如下
/dev/sda:
Timing cached reads: 15740 MB in 1.99 seconds = 7901.01 MB/sec
Timing buffered disk reads: 2014 MB in 3.00 seconds = 670.97 MB/sec
我电脑的ssd,比较新的电脑,2022年买的5000块,如下
hdparm -Tt /dev/loop0
/dev/loop0:
Timing cached reads: 32666 MB in 2.00 seconds = 16355.96 MB/sec
HDIO_DRIVE_CMD(identify) failed: Invalid argument
Timing buffered disk reads: 582 MB in 0.73 seconds = 795.30 MB/sec