以戴尔服务器为例:
#!/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}’