标签:
expr参考:http://blog.chinaunix.net/uid-209416-id-2410742.html
stty参考:http://blog.csdn.net/ysdaniel/article/details/6965339
$?#&01参考:http://www.2cto.com/os/201305/210831.html
exit参考:http://blog.163.com/bobile45@126/blog/static/96061992201311712658570/
trap 参考:http://blog.csdn.net/cheungjustin/article/details/5678679
break & continue参考:http://www.2cto.com/os/201305/209361.html
for & while参考:http://www.cnblogs.com/kangyoung/p/3556186.html
if参考:http://www.2cto.com/os/201503/379433.html
echo参考:http://www.linuxidc.com/Linux/2014-10/107550.htm
read参考:http://man.linuxde.net/read
awk参考:http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html
去除空格参考:http://bbs.chinaunix.net/thread-2195137-1-1.html
tee参考:http://blog.csdn.net/yucan1001/article/details/8453527
tr参考:http://blog.sina.com.cn/s/blog_58c3f7960100uttl.html & http://man.linuxde.net/tr
sed参考:http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html
1 #!/bin/bash 2 # Author:Yingtao.Gu 3 # Copyright (c) 2016.1 4 # Script listed as below: 5 6 ##########Main Title################ 7 echo -e "Which item you want to choose[1-6] ? \nYou can type exit to exit this interactive window.\n1.CPU\n2.RAM\n3.Disk\n4.HCA\n5.NIC\n6.MotherBoard\nThe results will be saved in the opt directory." 8 read Choice 9 10 ##########Public variable############ 11 Begin=####################################################Begin#################################################### 12 End=#####################################################End##################################################### 13 echo1="----->" 14 save="/opt/ServerInformationCollection" 15 16 #########1.CPU###### 17 if [ $Choice -eq 1 ];then 18 PHNUM=`/usr/bin/lscpu | egrep Socket | gawk -F: ‘ { print$2 }‘` 19 CONUM=`/usr/bin/lscpu | egrep ^Core | awk ‘{ print$4 }‘` 20 echo "$Begin" 2>&1 | tee -a $save 21 echo -e "Cpu Mode is $echo1`/usr/bin/lscpu | egrep "Model name" | gawk -F: ‘{ print $2 }‘| tr -d " "`" 2>&1 | tee -a $save 22 echo "Phsical Cpu is $echo1 `/usr/bin/lscpu | egrep Socket | gawk -F: ‘ { print$2 }‘|tr -d " "`" 2>&1 | tee -a $save 23 echo "Phsical Core is $echo1`expr $PHNUM \* $CONUM`" 24 echo "Cpu Total Thread is $echo1 `/usr/bin/lscpu | egrep "^CPU\(s\)\:" | gawk -F: ‘ { print$2 }‘|tr -d " "`" 2>&1 | tee -a $save 25 echo "$End" 2>&1 | tee -a $save 26 27 #########2.Memory###### 28 elif [ $Choice -eq 2 ];then 29 echo "$Begin" 2>&1 | tee -a $save 30 echo "`/usr/sbin/dmidecode -t memory | egrep -A8 -i size | egrep "(Locator:|Size:|Speed:|Manufacturer:)" | egrep -vi "No Module Installed" | egrep -A4 -i Size | egrep -vi "Bank Locator:"`" 2>&1 | tee -a $save 31 echo "$End" 2>&1 | tee -a $save 32 33 ########3.LSI######## 34 elif [ $Choice -eq 3 ];then 35 echo -e "which item you want to choose[1-2] ? \n1.Megaraid Card\n2.SAS Hba Card" 36 read choice2 37 if [ $choice2 -eq 1 ] ; then 38 RAID=`/usr/sbin/lspci | egrep -i RAID | awk ‘{ print $12 }‘` 39 if [ "$RAID" == "2208" ] || [ "$RAID" == "2108" ];then 40 echo "$Begin" 2>&1 | tee -a $save 41 echo "`/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL | egrep "Product Name|FW Version|Serial No"`" 2>&1 | tee -a $save 42 echo "`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep -i "Raw Size|Enclosure Device ID:|Slot Number:|Firmware state|Inquiry Data|foreign" | sort`" 2>&1 | tee -a $save 43 echo "`/opt/MegaRAID/MegaCli/MegaCli64 -LDGetNum -aAll`" 2>&1 | tee -a $save 44 echo "`/opt/MegaRAID/MegaCli/MegaCli64 -CfgDsply -a0 | egrep "RAID Level"`" 2>&1 | tee -a $save 45 echo "$End" 2>&1 | tee -a $save 46 else 47 echo "$Begin" 2>&1 | tee -a $save 48 echo "Here are not any megaraid card can be detected" 2>&1 | tee -a $save 49 echo "$End" 2>&1 | tee -a $save 50 fi 51 elif [ $choice2 -eq 2 ];then 52 SERIAL=`/usr/sbin/lspci | egrep -i serial | awk ‘{ print$11 }‘` 53 if [ "$SERIAL" == SAS2308 ] || [ "$SERIAL" == SAS2008 ];then 54 SERNUM=`/usr/sbin/lspci | egrep -i Serial | wc -l` 55 echo "$Begin" 2>&1 | tee -a $save 56 for ((i=0;i<$SERNUM;i++));do 57 echo -e "`/opt/smartmgr/scripts/sas2ircu $i display | egrep "Controller type|Firmware version|Volume ID|Status of volume|Enclosure #|Slot #|State|Size|Model Number|Firmware Revision|Serial No" | sort`" 2>&1 | tee -a $save 58 done 59 echo "$End" 2>&1 | tee -a $save 60 else 61 echo "$Begin" 2>&1 | tee -a $save 62 echo "Here are not any sas hba card can be detected " 2>&1 | tee -a $save 63 echo "$End" 2>&1 | tee -a $save 64 fi 65 else 66 echo "$Begin" 2>&1 | tee -a $save 67 echo "Here are not any Lsi SAS and Raid card can be detected." 2>&1 | tee -a $save 68 echo "$End" 2>&1 | tee -a $save 69 fi 70 71 ########4.IB######## 72 elif [ $Choice -eq 4 ];then 73 MT=`/usr/sbin/lspci | egrep -i mt` 74 if [ -n "$MT" ];then 75 echo "$Begin" 2>&1 | tee -a $save 76 echo "`/usr/sbin/lspci | egrep -i mellanox`" 2>&1 | tee -a $save 77 ME=`/usr/sbin/lspci | egrep -i mt | awk -F: ‘{ print$1 }‘` 78 for i1 in $ME;do 79 echo "`/usr/sbin/lspci -vv -s 0000:$i1:00.0 |grep SN |awk -F ‘: ‘ ‘{print$2}‘`" 2>&1 | tee -a $save 80 done 81 echo "$End" 2>&1 | tee -a $save 82 else 83 echo "$Begin" 2>&1 | tee -a $save 84 echo "Here are not any Mellanox ib card can be detected" 2>&1 | tee -a $save 85 echo "$End" 2>&1 | tee -a $save 86 fi 87 88 ######5.NIC####### 89 elif [ $Choice -eq 5 ];then 90 echo "$Begin" 2>&1 | tee -a $save 91 echo "`/usr/sbin/lspci | egrep -i network | egrep -v MT`" 2>&1 | tee -a $save 92 echo "$End" 2>&1 | tee -a $save 93 94 ######6.MotherBoard###### 95 elif [ $Choice -eq 6 ];then 96 echo "$Begin" 2>&1 | tee -a $save 97 echo -e "`/usr/sbin/dmidecode -s bios-vendor`\n`/usr/sbin/dmidecode -s bios-version`\n`/usr/sbin/dmidecode -s bios-release-date`\n`/usr/sbin/dmidecode -s system-product-name`\n`/usr/sbin/dmidecode -s baseboard-serial-number`" 2>&1 | tee -a $save 98 echo "$End" 2>&1 | tee -a $save 99 else 100 echo "Please do it carefully!!!" 2>&1 | tee -a $save 101 fi
标签:
原文地址:http://www.cnblogs.com/appresearch/p/5426197.html