CentOS7通過指令獲取系統信息

獲取服務器硬件信息

  • 獲取服務器型號、序列號
$ dmidecode | grep "System Information" -A9 | egrep "Manufacturer|Product|Serial"
	Manufacturer: RDO
	Product Name: OpenStack Compute
	Serial Number: fc4b41c4-fba2-40b5-8bbe-470fa9a498a2
  • 獲取主板信息
$ dmidecode | grep -A16 "System Information$"
System Information
	Manufacturer: RDO
	Product Name: OpenStack Compute
	Version: 17.0.10-1.el7
	Serial Number: fc4b41c4-fba2-40b5-8bbe-470fa9a498a2
	UUID: f270d386-d9e9-4eff-a144-598b036ad105
	Wake-up Type: Power Switch
	SKU Number: Not Specified
	Family: Virtual Machine

Handle 0x0300, DMI type 3, 21 bytes
Chassis Information
	Manufacturer: Red Hat
	Type: Other
	Lock: Not Present
	Version: RHEL 7.6.0 PC (i440FX + PIIX, 1996)
	Serial Number: Not Specified
  • 獲取BIOS信息
$ dmidecode -t bios
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
	Vendor: SeaBIOS
	Version: 1.11.0-2.el7
	Release Date: 04/01/2014
	Address: 0xE8000
	Runtime Size: 96 kB
	ROM Size: 64 kB
	Characteristics:
		BIOS characteristics not supported
		Targeted content distribution is supported
	BIOS Revision: 0.0
  • 獲取內存信息
$ dmidecode -t memory

在這裏插入圖片描述

獲取CPU信息

  • 獲取cpu型號
$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
    16  Intel Xeon Processor (Skylake, IBRS)
  • 獲取物理cpu個數
$ grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
16
  • 獲取物理cpu核數
$ cat /proc/cpuinfo | grep "processor" | wc -l
16
  • 獲取單個物理cpu核數
$ cat /proc/cpuinfo | grep "cores" | uniq
cpu cores	: 1
  • 獲取單個物理cpu核數
$ cat /proc/cpuinfo | grep "cores" | uniq
cpu cores	: 1
  • 獲取cpu主頻
$ cat /proc/cpuinfo | grep MHz | uniq
cpu MHz		: 2095.076
  • 獲取cpu詳細信息
$ lscpu 
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             16
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel Xeon Processor (Skylake, IBRS)
Stepping:              4
CPU MHz:               2095.076
BogoMIPS:              4190.15
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K
L3 cache:              16384K
NUMA node0 CPU(s):     0-15
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke md_clear spec_ctrl intel_stibp
  • 獲取cpu運行模式
$ getconf LONG_BIT
64
  • 查詢cpu是否支持64位
$ cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
16

獲取內存信息

  • 獲取系統最大支持內存
$ dmidecode|grep -P 'Maximum\s+Capacity'
	Maximum Capacity: 64 GB
  • 獲取服務器內存槽使用情況
$ dmidecode | grep -A5 "Memory Device" | grep Size | grep -v Range
	Size: 16384 MB
	Size: 16384 MB
	Size: 16384 MB
	Size: 16384 MB
  • 獲取內存條頻率
$ dmidecode | grep -A16 "Memory Device" | grep "Speed"
	Speed: Unknown
	Speed: Unknown
	Speed: Unknown
	Speed: Unknown
  • 獲取內存詳細信息
$  cat /proc/meminfo
MemTotal:       65806668 kB
MemFree:         2815512 kB
MemAvailable:   38976856 kB
Buffers:            2092 kB
Cached:         37698400 kB
SwapCached:            0 kB
Active:         37577212 kB
Inactive:       23485288 kB
Active(anon):   24788676 kB
Inactive(anon):   517712 kB
Active(file):   12788536 kB
Inactive(file): 22967576 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      20971516 kB
SwapFree:       20971516 kB
Dirty:               580 kB
Writeback:             0 kB
AnonPages:      23362172 kB
Mapped:           960988 kB
Shmem:           1944336 kB
Slab:            1185788 kB
SReclaimable:     937100 kB
SUnreclaim:       248688 kB
KernelStack:       67264 kB
PageTables:       110604 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    53874848 kB
Committed_AS:   29323048 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      124404 kB
VmallocChunk:   34359598844 kB
HardwareCorrupted:     0 kB
AnonHugePages:  17391616 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      184160 kB
DirectMap2M:     5058560 kB
DirectMap1G:    63963136 kB
  • 獲取內存使用情況
$ free -h
              total        used        free      shared  buff/cache   available
Mem:            62G         22G        2.7G        1.9G         37G         37G
Swap:           19G          0B         19G

獲取硬盤信息

  • 獲取磁盤分區狀態
$ fdisk -l | grep Disk
Disk /dev/vda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Disk label type: dos
Disk identifier: 0x000ae09f
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/vdc: 107.4 GB, 107374182400 bytes, 209715200 sectors
Disk label type: dos
Disk identifier: 0xa7343e4f
  • 獲取磁盤和分區分佈
$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0   30G  0 disk 
└─vda1 253:1    0   30G  0 part /
vdb    253:16   0   20G  0 disk [SWAP]
vdc    253:32   0  100G  0 disk 
└─vdc1 253:33   0  100G  0 part /data
  • 獲取磁盤詳細信息
$ fdisk -l

Disk /dev/vda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ae09f

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    62914526    31456239+  83  Linux

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vdc: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xa7343e4f

   Device Boot      Start         End      Blocks   Id  System
/dev/vdc1            2048   209715199   104856576   83  Linux
  • 獲取磁盤掛載詳情
$  mount | column -t
  • 獲取掛載使用詳情
$ swapon -s
Filename				Type		Size	Used	Priority
/dev/vdb                               	partition	20971516	0	-2
  • 獲取磁盤使用詳情
$ df -hl
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        30G   11G   20G  37% /
devtmpfs         32G     0   32G   0% /dev
tmpfs            32G     0   32G   0% /dev/shm
tmpfs            32G  362M   32G   2% /run
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/vdc1       100G   71G   30G  71% /data

獲取網卡信息

  • 查看所有網絡接口信息
$ ifconfig -a
$ ip link show
  • 獲取具體某個網絡接口信息
$ ethtool eth0
Settings for eth0:
	Link detected: yes
  • 獲取具體某個網絡接口信息
$ ethtool eth0
Settings for eth0:
	Link detected: yes
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章