#!/bin/sh#################################################################################author:cprime#date:2012/08/20#filename:get_deviceinfo.sh#get device infomations#################################################################################install tools for getting device infomations #yum install -y dmidecode lshwBOARD_FIRM_NAME=`dmidecode -t 2 | awk -F':' '/Manu/{print $2}'`BOARD_TYPE=`dmidecode -t 2 | awk -F':' '/Product/{print $2}'`BOARD_SERIAL=`dmidecode -t 2 | awk -F':' '/Serial/{print $2}'`CPU_MODEL=`cat /proc/cpuinfo | awk -F':' '/model name/{print $2}' | sed -n '1p'`CPU_KENAL_NUM=`cat /proc/cpuinfo | awk -F':' '/model name/{print $2}' | wc -l`MEM_PRODUCKT=`dmidecode -t 17 | sed -e '/./{H;$!d}' -e 'x;/Rank: 2/!d' | awk -F':' '/Manufacturer/{print $2}' | sed -n '1p'`MEM_SIZE=`dmidecode -t 17 | sed -e '/./{H;$!d}' -e 'x;/Rank: 2/!d' | awk -F':' '/Size/{print $2}' | sed -n '1p'`MEM_NUM=`dmidecode -t 17 | sed -e '/./{H;$!d}' -e 'x;/Rank: 2/!d' | awk -F':' '/Size/{print $2}' | wc -l`touch /tmp/TMPFILElshw > /tmp/TMPFILEFILE=/tmp/TMPFILEDISK_PRODUCKT=`cat $FILE| grep -A12 'disk' | awk -F':' '/vendor/{print $2}' | sed -n '1p'`DISK_SIZE=`cat $FILE | grep -A12 'disk' | awk -F':' '/size/{print $2}' | sed -n '1p'`DISK_NUM=`cat $FILE | grep -A12 'disk' | awk -F':' '/size/{print $2}' | wc -l`NETWORK_PRODUCKT=`cat $FILE | grep -A12 'network' | awk -F':' '/vendor/{print $2}'`NETWORK_MODEL=`cat $FILE | grep -A12 'network' | awk -F':' '/product/{print $2}'`NETWORK_SPEED=`cat $FILE | grep -A12 'network' | awk -F':' '/size/{print $2}'`echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^主板厂商:$BOARD_FIRM_NAME主板型号:$BOARD_TYPE主板序列号:$BOARD_SERIAL--------------------------------------------------------------------------------CPU型号:$CPU_MODELCPU核数:$CPU_KENAL_NUM--------------------------------------------------------------------------------内存厂商:$MEM_PRODUCKT内存大小:$MEM_SIZE内存块数:$MEM_NUM--------------------------------------------------------------------------------磁盘厂商:$DISK_PRODUCKT磁盘大小:$DISK_SIZE磁盘块数:$DISK_NUM--------------------------------------------------------------------------------网卡厂商:$NETWORK_PRODUCKT网卡型号:$NETWORK_MODEL网卡速率:$NETWORK_SPEED ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"最小化安装的系统,默认dmidecode命令和lshw命令是没有的,如果这样的话,把yum那条注释去掉就会安装上了。 我的设备输出情况如下: [root ~]# sh get_dviceinfo.sh ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 主板厂商: BIOSTAR Group 主板型号: TH67A+ 主板序列号: None -------------------------------------- CPU型号: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz CPU核数:2 -------------------------------------- 内存厂商: Kingston 内存大小: 4096 MB 内存块数:2 ------------------------------------- 磁盘厂商: Western Digital 磁盘大小: 931GiB (1TB) 磁盘块数:2 -------------------------------------- 网卡厂商: Realtek Semiconductor Co., Ltd. 网卡型号: RTL8111/8168B PCI Express Gigabit Ethernet controller 网卡速率: 1GB/s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
别人写的,觉得写得不错, 以后工作中可能会用得到,就先转载过来。