查看本服务器硬件信息(CPU、内存、硬盘等)

以戴尔服务器为例:

 

#!/bin/bash
#查看 服务器ip:
ifconfig |grep -A7 "eth0" |grep "inet addr" | awk '{print $2}'| sed 's/addr://g'
#查看服务器型号:
dmidecode |grep -A8 "System Information" |grep "Product Name"|sed 's/^[ \t]*//'
#查看硬件编号:
dmidecode |grep -A8 "System Information" |grep "Serial Number" |sed 's/^[ \t]*//'
#现有内容数量和容量:
dmidecode |grep -A16 "Memory Device" |grep "Size" |sed 's/^[ \t]*//'
#最大支持 内存容量:
dmidecode |grep "Maximum Capacity"  |sed 's/^[ \t]*//'
#查看 CPU类型和主频:
cat /proc/cpuinfo |grep " model name"
#硬盘容量:
fdisk -l |grep "Disk" |awk '{print $2$3$4}'




获取到的内容为:

 

192.168.1.1
Product Name: PowerEdge R510
Serial Number: XXXXXXX
Size: 4096 MB
Size: 4096 MB
Size: 4096 MB
Size: 4096 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Maximum Capacity: 128 GB
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
/dev/sda:292.3GB,
/dev/sdb:859.0GB,

你可能感兴趣的:(shell,职场,休闲)