OS 版本

# 发行版
cat /etc/issue
lsb_release -a
# 内核版本
uname -a
cat /proc/version

系统资源概览

top
# OR
htop

内存

free -h
cat /proc/meminfo
# 查看内存条信息
lshw -c memory

磁盘

  • 磁盘型号
sudo hdparm -i /dev/sda | grep "Model"

sudo smartctl --info /dev/sda
  • 随机读写 iops
fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=15G -numjobs=20 -runtime=60 -group_reporting -name=mytest
  • 读写吞吐量
hdparm -Tt --direct /dev/sda
  • 磁盘转速
$ sudo hdparm -I /dev/sda | grep Rotation 
    Nominal Media Rotation Rate: 5400
$ sudo sg_vpd -a  /dev/sda | grep rpm 
  Nominal rotation rate: 5400 rpm
  • 分区与容量
# 磁盘容量及分区状况(不能查看未挂载分区)
df -Th

# 磁盘容量及分区状况(可以查看未挂载分区)
sudo fdisk -l
sudo lsblk -f

# 查看磁盘 UUID(可以查看未挂载分区)
sudo blkid

# /lib 目录大小
du -sh /lib
 
# /lib 子目录大小
du -sh /lib/*
  • 快速检查磁盘是否健康
$ sudo smartctl -H /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-54-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
  • 查看磁盘读写次数
$ sudo smartctl -A /dev/nvme0n1 
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-94-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF SMART DATA SECTION ===
SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        54 Celsius
Available Spare:                    100%
Available Spare Threshold:          10%
Percentage Used:                    1%
Data Units Read:                    368,220,831 [188 TB]
Data Units Written:                 121,824,067 [62.3 TB]
Host Read Commands:                 1,461,320,151
Host Write Commands:                884,629,798
Controller Busy Time:               7,910
Power Cycles:                       50
Power On Hours:                     11,667
Unsafe Shutdowns:                   26
Media and Data Integrity Errors:    0
Error Information Log Entries:      1
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
  • 查看磁盘 io
iotop
# d 查看磁盘读写状况
# m 以 MB 为单位
# 2 每 2s 统计一次
# 3 一共统计 3 次
iostat -dm 2 3
# OR
iostat -dmx /dev/nvme0n1 1  10

CPU

# 查看CPU信息
lshw -c cpu # 推荐
lscpu
cat /proc/cpuinfo

# 查看CPU型号
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

# 总核数 = 物理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

主板

# 查看主板信息
# sudo dmidecode -t 2
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: Gigabyte Technology Co., Ltd.
    Product Name: B560M AORUS ELITE
    Version: Default string
    Serial Number: Default string
    Asset Tag: Default string
    Features:
        Board is a hosting board
        Board is replaceable
    Location In Chassis: Default string
    Chassis Handle: 0x0003
    Type: Motherboard
    Contained Object Handles: 0

$ sudo lshw -c bus
  *-core                    
       description: Motherboard
       product: B560M AORUS ELITE
       vendor: Gigabyte Technology Co., Ltd.
       physical id: 0
       version: Default string
       serial: Default string
       slot: Default string

lshw

  • 查看 class
lshw -short
lshw -businfo
本文出自 qbit snap

qbit
268 声望279 粉丝