Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5218604
  • 博文数量: 553
  • 博客积分: 13864
  • 博客等级: 上将
  • 技术积分: 11041
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-28 21:25
个人简介

个人Blog: hhktony.com

文章分类

全部博文(553)

文章存档

2015年(1)

2014年(2)

2013年(12)

2012年(384)

2011年(154)

分类: LINUX

2011-12-02 10:27:36

呵呵,没事的时候把之前作的硬件信息统计的一些命令写成了个小的脚本,还有很多问题需要解决,先放上来大家分享一下,看看有没有好的建议~
根据提示执行这个脚本,等待5秒之后,
首先,会弹出一个hardinfo.html的网页,页面上面有当前的硬件信息,可以通过打印该页面,将其粘贴在机器上面。

其次,在生成的目录下面有一个info.xls文件,该文件是将硬件信息保存成了表格的形式。


############################### Hardware information Tool #####################
#Version: 1.0
#Auther:kll
#Mail:k_liang@126.com
###########################################################
#/bin/sh
echo -ne "\t注意:"
echo -e " 请以root权限来执行该脚本。"
echo -e "\t (Please use root to execute this shell)"
echo -ne "\t 请输入您当前的机器名称,不能包含空格符号。例如:Piaget1.0-PV-SKU3(Dis) " :
read dirname
if [ -e $dirname ] ; then
rm $dirname -rf
fi
cd .
mkdir $dirname
cat /etc/sysconfig/hwconf >$dirname/hwconf.txt
cat /proc/cpuinfo >$dirname/cpuinfo.txt
dmidecode -t memory >$dirname/meminfo.txt
dmidecode -s bios-version >$dirname/bios.txt
dmidecode -s bios-release-date >$dirname/biosd.txt
lspci >$dirname/lspci.txt
lspci -n >$dirname/lspcin.txt
cd $dirname
touch hardinfo.html
echo >hardinfo.html
echo ">hardinfo.html
echo "" >>hardinfo.html
echo "" >>hardinfo.html
echo "
" >>hardinfo.html

echo "" >>hardinfo.html

echo "" >> hardinfo.html
echo "
">> hardinfo.html
echo "">>hardinfo.html
echo "机 型:$dirname">>hardinfo.html
echo "">>hardinfo.html

echo "
" >> hardinfo.html


echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html

###############CPU information###########
echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### Memory information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### Host Bridge information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### South Bridge information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### Video Card information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
lspci |grep "VGA" >> /dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html

############### Audio Card information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
lspci |grep "Audio" >> /dev/null
#lspci -n|grep "0403">>/dev/null

if [ $? == 0 ]
then
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html

############### NIC Card information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
lspci |grep "Ethernet" >> /dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html
############### HDD information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### ODD information###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
hdparm -I /dev/cdrom |grep "Model Number">> /dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html


############### Wireless card information##############

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
lspci |grep "Network" >> /dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html

echo "" >>hardinfo.html
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html


############### BIOS information ###########

echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

############### Modem information #####################
echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
grep -l "Modem Function Group:" /proc/asound/card*/codec#* >> /dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html


############### Blue information #####################
echo "
" >> hardinfo.html
echo "
" >>hardinfo.html
hciconfig |grep "Address" >>/dev/null
if [ $? == 0 ]
then
echo "
" >>hardinfo.html
else
echo "
" >>hardinfo.html
fi
echo "
" >> hardinfo.html

###############Other devices information################
echo "
" >> hardinfo.html
echo "
" >>hardinfo.html

echo "
" >>hardinfo.html
echo "
" >> hardinfo.html

echo "
" >>hardinfo.html
echo "">>hardinfo.html
echo "硬件类别">>hardinfo.html
echo "">>hardinfo.html
echo "
" >>hardinfo.html
echo "">>hardinfo.html
echo "硬件信息">>hardinfo.html
echo "">>hardinfo.html
echo "
" >>hardinfo.html
echo "">>hardinfo.html
echo "ID">>hardinfo.html
echo "">>hardinfo.html
echo "
" >>hardinfo.html
echo "CPU信息">>hardinfo.html
echo "
" >>hardinfo.html
echo `cat /proc/cpuinfo |grep -w 'model name'|awk -F: '{print $2}'|uniq`>>hardinfo.html
echo "
" >>hardinfo.html
echo "内存">>hardinfo.html
echo "
" >>hardinfo.html
echo `dmidecode -t memory |grep -5 "Memory Device"|grep -i "MB"|grep -i "size"|awk '{print $2,$3}'` >>hardinfo.html
echo "
" >>hardinfo.html
echo "北桥">>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci |grep "00:00.0"|awk -F: '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci -n|grep \`lspci |grep "00:00.0"|awk '{print $1}'\`|awk '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "南桥">>hardinfo.html
echo "
" >>hardinfo.html
echo " ">>hardinfo.html
echo "
" >>hardinfo.html
echo "">>hardinfo.html
echo "
" >>hardinfo.html
echo "显卡">>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci |grep "VGA"|awk -F: '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci -n|grep \`lspci |grep "VGA"|awk '{print $1}'\`|awk '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no Video card">>hardinfo.html
echo "
" >>hardinfo.html
echo "声卡">>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci |grep "Audio"|awk -F: '{print $3}'`>>hardinfo.html
# echo `lspci |grep \`lspci -n |awk 'match($2,"0403"){print $1,$3}'|awk '{print $1}'\`|awk -F: '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci -n|grep "\`lspci |grep "Audio"|awk '{print $1}'\`"|awk '{print $3}'`>>hardinfo.html
# echo `lspci -n |awk 'match($2,"0403"){print $1,$3}'|awk '{print $2}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no Audio card">>hardinfo.html
echo "
" >>hardinfo.html
echo "网卡">>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci |grep "Ethernet"|awk -F: '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci -n|grep \`lspci |grep "Ethernet"|awk '{print $1}'\`|awk '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no NIC card">>hardinfo.html
echo "
" >>hardinfo.html
echo "硬盘">>hardinfo.html
echo "
" >>hardinfo.html
echo -n `hdparm -I /dev/sda |grep "Model Number"|awk -F: '{printf $2}'`>>hardinfo.html
echo `hdparm -I /dev/sda |grep "size"|grep GB|awk '{print $9,$10}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "光驱">>hardinfo.html
echo "
" >>hardinfo.html
echo -n `hdparm -I /dev/cdrom |grep "Model Number"`|awk -F: '{print $2}'>>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no CD-ROM">>hardinfo.html
echo "
" >>hardinfo.html
echo "无线网卡">>hardinfo.html
echo "
" >>hardinfo.html
echo `lspci |grep "Network"|awk -F: '{print $3}'` >> hardinfo.html
echo "
" >>hardinfo.html
echo `lspci -n|grep \`lspci |grep "Network"|awk '{print $1}'\`|awk '{print $3}'`>>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no wireless card">>hardinfo.html
echo "
" >>hardinfo.html
echo "BIOS信息">>hardinfo.html
echo "
" >>hardinfo.html
echo -e "`dmidecode -s bios-version`\t" "`dmidecode -s bios-release-date`">> hardinfo.html
echo "
" >>hardinfo.html
echo "Modem ">>hardinfo.html
echo "
" >>hardinfo.html
echo `cat \`grep -l "Modem Function Group:" /proc/asound/card*/codec#* \`|grep "Vendor Id:"` >>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no Modem">>hardinfo.html
echo "
" >>hardinfo.html
echo "Bluetooth">>hardinfo.html
echo "
" >>hardinfo.html
echo "Support" >>hardinfo.html
echo "
" >>hardinfo.html
echo "There is no Bluetooth">>hardinfo.html
echo "
" >>hardinfo.html
echo "其它硬件">>hardinfo.html
echo "
" >>hardinfo.html
echo -e "Cellular: \t">>hardinfo.html
echo "
">>hardinfo.html
echo -e "Camera: \t">>hardinfo.html
echo "
">>hardinfo.html
echo -e "Cardreader: \t">> hardinfo.html
echo "
" >>hardinfo.html
echo "" >>hardinfo.html
echo "">>hardinfo.html
###################### make info.xls file #################################

echo -ne "\tModel">>info.xls
echo -ne "\tCode">>info.xls
echo -ne "\t Bios">>info.xls
echo -ne "\t NorthBridge">>info.xls
echo -ne "\t CPU">>info.xls
echo -ne "\t Video">>info.xls
echo -ne "\t Audio">>info.xls
echo -ne "\t LAN">>info.xls
echo -ne "\t Wireless">>info.xls
echo -ne "\t Modem">>info.xls
echo -ne "\t BlueTooth">>info.xls
echo -ne "\t HDD">>info.xls
echo -ne "\t ODD">>info.xls
echo -ne "\t Memory">>info.xls
echo -ne "\tCellular">>info.xls
echo -ne "\tCard Reader">>info.xls
echo -ne "\tPCMCIA">>info.xls
echo -e "\t1394">>info.xls

echo -ne "\t$dirname">>info.xls
echo -ne "\t ">>info.xls
echo -ne "\t`dmidecode -s bios-version`" "`dmidecode -s bios-release-date`">>info.xls

echo -ne "\t`lspci |grep "00:00.0"|awk -F: '{print $3}'`" " `lspci -n|grep \`lspci |grep "00:00.0"|awk '{print $1}'\`|awk '{print $3}'`">>info.xls

echo -ne "\t`cat /proc/cpuinfo |grep -w 'model name'|awk -F: '{print $2}'|uniq`">>info.xls

lspci |grep "VGA" >> /dev/null
if [ $? == 0 ]
then
echo -ne "\t`lspci |grep "VGA"|awk -F: '{print $3}'`" " `lspci -n|grep \`lspci |grep "VGA"|awk '{print $1}'\`|awk '{print $3}'`">>info.xls
else
echo -ne "\tThere is no Video card">>info.xls
fi

lspci |grep "Audio" >> /dev/null
#if [ $? == 0 ]
#then
# echo -ne "\t`lspci |grep "Audio"|awk -F: '{print $3}'`" " `lspci -n|grep "\`lspci |grep "Audio"|awk '{print $1}'\`"|awk '{print $3}'`">>info.xls
#else
# echo -ne "\tThere is no Audio card">>info.xls
#fi
if [ $? == 0 ]
then
lspci |grep "Audio"|awk -F: '{print $3}'>>info.txt
lspci -n|grep "`lspci |grep "Audio"|awk '{print $1}'`"|awk '{print $3}'>>info.txt
num=`wc info.txt|awk '{print $1}'`
N=1
if [ $num -gt $N ]
then
a=`echo \`cat info.txt |sed -n 1p\` \`cat info.txt |sed -n 3p\``
b=`echo \`cat info.txt |sed -n 2p\` \`cat info.txt |sed -n 4p\``
echo -ne "\t $a $b">>info.xls
else
echo -ne "`cat info.txt |sed -n 1p`" "`cat info.txt |sed -n 2p`">>info.xls
fi
else
echo "There is no Audio card">> info.xls
fi
#echo>info.txt

lspci |grep "Ethernet" >> /dev/null
if [ $? == 0 ]
then
echo -ne "\t`lspci |grep "Ethernet"|awk -F: '{print $3}'`" " `lspci -n|grep \`lspci |grep "Ethernet"|awk '{print $1}'\`|awk '{print $3}'`">>info.xls
else
echo -ne "\tThere is no NIC card">>info.xls
fi

lspci |grep "Network" >> /dev/null
if [ $? == 0 ]
then
echo -ne "\t`lspci |grep "Network"|awk -F: '{print $3}'`" " `lspci -n|grep \`lspci |grep "Network"|awk '{print $1}'\`|awk '{print $3}'`">>info.xls
else
echo -ne "\tThere is no wireless card">>info.xls
fi


grep -l "Modem Function Group:" /proc/asound/card*/codec#* >> /dev/null
if [ $? == 0 ]
then
echo -ne "\t`cat \`grep -l "Modem Function Group:" /proc/asound/card*/codec#* \`|grep "Vendor Id:"`" >>info.xls
else
echo -ne "\tThere is no Modem">>info.xls
fi

hciconfig |grep "Address" >>/dev/null
if [ $? == 0 ]
then
echo -ne "\tSupport" >>info.xls
else
echo -ne "\tThere is no Bluetooth">>info.xls
fi

echo -ne "\t`hdparm -I /dev/sda |grep "Model Number"|awk -F: '{printf $2}'`" "`hdparm -I /dev/sda |grep "size"|grep GB|awk '{print $9,$10}'`">>info.xls

hdparm -I /dev/cdrom |grep "Model Number">> /dev/null
if [ $? == 0 ]
then
echo -ne "\t`hdparm -I /dev/cdrom |grep "Model Number"|awk -F: '{print $2}'`">>info.xls
else
echo -ne "\tThere is no CD-ROM">>info.xls
fi

#echo -e "\t `dmidecode -t memory |grep -5 "Memory Device"|grep -i "MB"|grep -i "size"|awk '{print $2,$3}'`" >>info.xls
dmidecode -t memory |grep -5 "Memory Device"|grep -i "MB"|grep -i "size"|awk '{print $2,$3}' >info.txt
num=`wc info.txt|awk '{print $1}'`
N=1
if [ $num -gt $N ]
then
echo -ne "\t `cat info.txt |sed -n 1p`" "`cat info.txt |sed -n 2p`">>info.xls
else
echo -ne "\t `cat info.txt |sed -n 1p`">>info.xls
fi
rm -rf info.txt
##########################################################

echo -e "\t 恭喜你!已经成功的建立了硬件信息目录`pwd`,请查看相关的硬件信息"
echo -e "\t (Conguration!The hardware information has been send to the dir `pwd`,please get details from this dir) "
echo -e "\t 请稍候..."
sleep 5

firefox `pwd`/hardinfo.html &


SLA:http://hi.baidu.com/kangliang2008/blog/item/f13c1583927761ae0cf4d2b2.html

阅读(2289) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~