往往一到公司盘点或升级服务器硬件时候,需要记录服务器的具体硬件信息,对于Windows下来说,装个鲁大师既可以查看所有硬件信息,但Linux下要想查看这些硬件信息要麻烦的多,下面是我整理的一些命令,再查看Linux硬件信息就变的容易的多了。为了方便大家更容易的查看硬件信息,简单写了这个脚本,主要针对RedHat系列系统,执行结果如有出入,请稍作修改。
1、查看CPU信息
说明:CPU型号是至强3065,主频2.33Ghz,2个物理CPU
2、查看硬盘信息(需要安装hdparm软件,yum install –y hdparm)
说明:磁盘型号是西部数据WD1601ABYS-18C0A0,总磁盘容量160G,还用134G可用
3、查看内存信息(需要安装dmidecode软件,yum install –y dmidecode)
说明:Maximum Capacity最大支持容量8G,Number Of Devices插槽数4个,第一个插槽和第三个插槽使用内存型号是DDR2,内存容量是1G,频率是667Mhz。第二个插槽和第三个插槽均未使用。总体内存已使用750M,剩余110M;虚拟内存未使用。
4、查看主板信息
说明:服务器是DELL R200,主板是Dell TY019,序列号是CN717038670154
5、查看网卡信息(需要安装pci工具,yum install –y pciutils)
说明:网卡型号是博通BCM5721
6、查看系统信息
说明:操作系统是CentOS6.4_x64,内核版本是2.6.32
查看硬件信息脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[root@localhost ~]# vi showhardwareinfo.sh
#!/bin/bash
yum install hdparm dmidecode pciutils -y
echo
echo
"###### CPU #######"
echo
cat /proc/cpuinfo | grep
"model name"
| awk -F
":"
'{print $2}'
| uniq -f
1
cat /proc/cpuinfo | grep
"cpu cores"
| awk -F
":"
'{print " CPU ="$2}'
| uniq -f
1
echo
echo
"###### Hard Disk ######"
echo
hdparm -i /dev/sda | grep -i
"model"
| awk -F
"-"
'{print $1}'
| awk -F
"="
'{print $2}'
fdisk -l | grep
"/dev/sda"
| awk -F
","
'NR==1{print $1}'
echo
df -h
echo
echo
"###### Memory ######"
echo
dmidecode -t memory | grep -i
"maximum capacity"
dmidecode -t memory | grep -i
"number of devices"
echo
dmidecode -t memory | grep -i
"size"
| awk -F
":"
'NR==1{print " Capacity 1" $1":",$2}'
dmidecode -t memory | grep -i
"speed"
| awk
'NR==1'
dmidecode -t memory | grep -i
"type:"
| uniq -f
1
dmidecode -t memory | grep -i
"size"
| awk -F
":"
'NR==2{print " Capacity 2" $1":",$2}'
dmidecode -t memory | grep -i
"speed"
| awk
'NR==2'
dmidecode -t memory | grep -i
"type:"
| uniq -f
1
dmidecode -t memory | grep -i
"size"
| awk -F
":"
'NR==3{print " Capacity 3" $1":",$2}'
dmidecode -t memory | grep -i
"speed"
| awk
'NR==3'
dmidecode -t memory | grep -i
"type:"
| uniq -f
1
dmidecode -t memory | grep -i
"size"
| awk -F
":"
'NR==4{print " Capacity 4" $1":",$2}'
dmidecode -t memory | grep -i
"speed"
| awk
'NR==4'
dmidecode -t memory | grep -i
"type:"
| uniq -f
1
echo
free -m
echo
echo
"###### Mianboard ######"
echo
dmidecode -q | grep -i
"product name"
| awk -F
":"
'NR==1{print "Server Model" ":",$2}'
dmidecode -q | grep -i
"Manufacturer"
| awk -F
":"
'NR==1{print "Brand" ":",$2}'
dmidecode -q | grep -i
"product name"
| awk -F
":"
'NR==2{print "Mainboard Model" ":",$2}'
echo
echo
"###### Network Card ######"
echo
lspci | grep -i eth | awk
'NR==1'
| awk -F
":"
'{print $3}'
echo
echo
"###### Operating System ######"
echo
cat /etc/issue | awk
'NR==1'
uname -r | awk
'{print "kernel: "$1}'
echo
|
1
2
|
[root@localhost ~]
# chmod +x showhardwareinfo.sh
[root@localhost ~]
# ./showhardwareinfo.sh
|
运行结果如下:
以上介绍了查看服务器CPU、硬盘、内存等基本信息实例,希望对大家有所帮助。
本文转自 李振良OK 51CTO博客,原文链接:http://blog.51cto.com/lizhenliang/1345628,如需转载请自行联系原作者