#!/bin/bash
DATE: 2018--01-06
################################################ ##需要安装统计服务器硬件信息的软件## /usr/bin/yum install pciutils dmidecode -y >/tmp/yum.log
###需要安装统计服务器磁盘信息的软件## #/usr/bin/wget -P /tmp http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/Lib_Utils-1.00-08.noarch.rpm #/usr/bin/wget -P /tmp http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/MegaCli-8.00.46-1.i386.rpm #/bin/rpm -ivh Lib_Utils-1.00-08.noarch.rpm #/bin/rpm -ivh MegaCli-8.00.46-1.i386.rpm
Define files and variables here
################################################
systembit=getconf LONG_BIT
#系统位数(32或64)
meminfo=dmidecode | grep "^[[:space:]]*Size.*MB$" | uniq -c | sed 's/ \t*Size: /\*/g' | sed 's/^ *//g'|xargs -n 20
#内存信息
diskinfo=fdisk -l|grep Disk|awk '{count+=$3}END{print count$4}'|sed 's/,//g'
#已识别磁盘大小
product_SN_name=dmidecode|grep -A 4 "System Information"|sed '1d'|sed -n '2p;4p'|sed 's#^\t##g'|xargs -n 10
#设备名称和SN串码
system_name=cat /etc/issue|head -n +1
#系统版本
board_SN_name=dmidecode|grep -A 4 "Base Board Information"|sed '1d'|sed -n '2p;4p'|sed 's#^\t##g'|xargs -n 10
#主板信息和SN串码
cpu_model=cat /proc/cpuinfo | grep name | cut -d: -f2 | uniq -c | sed 's/^ *//'
#CPU型号
cpu_core_num=cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F ': ' '{print $2}'
#一个物理CPU的核心数
cpu_phy_num=cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
#物理CPU个数
cpu_logic_num=cat /proc/cpuinfo | grep "siblings" | uniq | awk -F ': ' '{print $2}'
#一个物理CPU的逻辑CPU个数
netcardinfo=lspci | grep -i eth | head -n +1 | awk -F : '{print $3}' | sed 's/^ //'
#网卡信息
Virtl_Drive_Info=/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL|grep -A7 "Virtual Drive Information"|sed '1d'
PD_info=/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL|egrep "Device Id|Inquiry Data|Device Speed|Drive Temperature|PD Type|Raw Size"
##磁盘类型厂家,磁盘大小,磁盘写入速度,磁盘温度
################################################
BEGINNING of MAIN
################################################ if [ $cpu_core_num -eq $cpu_logic_num ];then echo "+--------------------------------------------+" echo "| This Machine's Hyper-Threading is Disabled |" ##超线程已禁用或不支持超线程 echo "+--------------------------------------------+" else echo "+--------------------------------------------------------------+" echo "| This Machine's Hyper-Threading is Enabled(recommend disable) |" ##支持超线程并且已打开(推荐关闭) echo "+--------------------------------------------------------------+" fi echo "Systembit : $systembit" echo "MEM info : $meminfo" echo "Disk_totle : $diskinfo" echo "Pro_SN_name : $product_SN_name" echo "System name : $system_name" echo "Board_SN name: $board_SN_name" echo "CPU model : $cpu_model" echo "CPU_phy_num : $cpu_phy_num" echo "CPU_core_num : $cpu_core_num" echo "CPU_logic_num: $cpu_logic_num" echo "Netcard info : $netcardinfo" echo "+++++++++++++++++++++++++++++++++++" echo "<<raid informations>>" echo " $Virtl_Drive_Info" echo "+++++++++++++++++++++++++++++++++++" echo "<<Virtual Drive Information>>" echo "$PD_info"