ubuntu查看硬件信息
1.查询Cpu详情
1.查看CPU信息
#查看cpu详情信息
lscpu
`lscpu | grep "Model name"|awk '{print $6}'`
2.查询Mem详情
`dmidecode |grep -A16 "Memory Device$"`
3.查询DISK详情
1.查看磁盘型号
#以文件形式查看磁盘信息
`cat /sys/block/nvme0n1/device/model`
INTEL SSDPE2MW012T4
或
apt install smartmontools
smartctl --all /dev/sda
4.查询GPU详情
`lshw -C display | grep "product:"|awk -F ":" '{print $2}'`
5.查看主板详情:
`dmidecode |grep -A16 "System Information$"|grep "Product Name:"|head -n 1|awk -F ":" '{print $2}'`
6.查看硬件脚本
#!/bin/bash
host=`getIlip` (getIlip自己可以写脚本获取IP编译为命令)
cpu=`lscpu | grep "Model name"|awk '{print $6}'`
mem1=`dmidecode |grep -A16 "Memory Device$"|grep "Part Number: VMA"|wc -l`
mem2=`dmidecode |grep -A16 "Memory Device$"|grep "Part Number: CM4"|wc -l`
disk=`cat /sys/block/nvme0n1/device/model`
disknumber=`lsblk | grep disk|wc -l`
zhuban=`dmidecode |grep -A16 "System Information$"|grep "Product Name:"|head -n 1|awk -F ":" '{print $2}'`
gpu=`lshw -C display | grep "product:"|awk -F ":" '{print $2}'`
echo "host:$host,CPU:$cpu,主板:$zhuban,阿斯嘉特:$mem1,海盗船:$mem2,Disk:$disk,磁盘数量:$disknumber,GPU:$gpu"