技术
成就梦想!

BIOS、超线程、NUMA、CPU高性能、睿频服务器批量检查

      不同的业务系统对BIOS配置要求不同,为了快速检查,就必须通过脚本进行核查。本次就简单写了一个核查脚本用来检车BIOS的超线程、NUMA、CPU高性能、睿频等配置。
        核查脚本分为两块一个是信息文件.csv,还有一个就是shell检查脚本。

csv文件如下图所示:

shell核查脚本:

#!/bin/bash

modprobe ipmi_watchdog
modprobe ipmi_poweroff
modprobe ipmi_devintf
modprobe ipmi_si
modprobe ipmi_msghandler
echo "ipmi_watchdog" > /etc/modules-load.d/ipmi_watchdog.conf
echo "ipmi_poweroff" > /etc/modules-load.d/ipmi_poweroff.conf
echo "ipmi_devintf" > /etc/modules-load.d/ipmi_devintf.conf
echo "ipmi_si" > /etc/modules-load.d/ipmi_si.conf
echo "ipmi_msghandler" > /etc/modules-load.d/ipmi_msghandler.conf

vendor=$(dmidecode -t 1 | grep -Ei "Manufacturer")

if [[ $vendor == *H3C* ]];then
    BMC_IP=$(ipmitool lan print 8 | grep -E "IP\s+Address\s+:" | awk '{print $4}')
else
    BMC_IP=$(ipmitool lan print | grep -E "IP\s+Address\s+:" | awk '{print $4}')
fi

#厂商与型号获取
Vendor_out=$(dmidecode -t 1 | grep -Ei "Manufacturer" |cut -d " " -f 2)
Product=$(dmidecode -t 1 |grep "Product Name" |cut -d ":" -f 2)

#管理地址获取
bond0_net_01=`ls /etc/sysconfig/network-scripts/ifcfg-bond0.* | awk '{print $0}' |sed -n "1p"`
[ -e "$bond0_net_01" ] && bond0_ip=`cat $bond0_net_01  |grep IPADDR |tr -d '\r'|cut -d "=" -f 2`

#超线程信息获取
CPU_Core=`dmidecode -t processor |grep "Core Enabled" |sed -n "1p" |cut -d " " -f 3`
CPU_Thread=`dmidecode -t processor |grep "Thread Count" |sed -n "1p" |cut -d " " -f 3`
[ "$CPU_Core" -eq "$CPU_Thread" ] && Thread_Chack_status=OFF || Thread_Chack_status=ON

#NUMA信息获取
lscpu  |grep "NUMA node1" > /dev/null 2>&1
[ $? -eq 0 ] && NUMA_Chack_status=ON || NUMA_Chack_status=OFF

#CPU高性能信息获取
[ -e "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" ] && CPU_Power_Mode=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`  
[ "$CPU_Power_Mode" == performance ] && CPU_Power_Mode_Chack_status=ON || CPU_Power_Mode_Chack_status=OFF

#CPU睿频信息获取
[ -e "/sys/devices/system/cpu/intel_pstate/no_turbo" ] && CPU_Turbo=`cat /sys/devices/system/cpu/intel_pstate/no_turbo`  
[ "$CPU_Turbo" == 0 ] && CPU_Turbo_Chack_status=ON || CPU_Turbo_Chack_status=OFF



echo "------------------------------------------------------------------"
echo "管理地址:$bond0_ip"
echo "厂商:$Vendor_out"
echo "型号:$Product"
echo "IPMI地址:$BMC_IP"


i=0
while read host || [ -n "$host" ];
do

        array=(${host//,/ })
        bmc_ip=${array[0]}
        manufacture=${array[2]}
		

        if [[ $BMC_IP = $bmc_ip ]]; then
                if [[ $manufacture = 'BIOS-01' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-02' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-03' ]]; then
#超线程关闭
[ "$Thread_Chack_status" == OFF ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求关闭  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-04' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA关闭
[ "$NUMA_Chack_status" == OFF ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求关闭    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 
#CPU performance开启
[ "$CPU_Power_Mode_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "CPU高性能:要求开启   实际配置:$CPU_Power_Mode_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-05' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 
#睿频开启
[ "$CPU_Turbo_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "睿频配置:要求开启    实际配置:$CPU_Turbo_Chack_status   检查结果:$Chack_out" 
#CPU performance开启
[ "$CPU_Power_Mode_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "CPU高性能:要求开启   实际配置:$CPU_Power_Mode_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-06' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 
#睿频开启
[ "$CPU_Turbo_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "睿频配置:要求开启    实际配置:$CPU_Turbo_Chack_status   检查结果:$Chack_out" 
#CPU performance开启
[ "$CPU_Power_Mode_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "CPU高性能:要求开启   实际配置:$CPU_Power_Mode_Chack_status   检查结果:$Chack_out" 

				elif [[ $manufacture = 'BIOS-07' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA关闭
[ "$NUMA_Chack_status" == OFF ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求关闭    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 
#CPU performance开启
[ "$CPU_Power_Mode_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "CPU高性能:要求开启   实际配置:$CPU_Power_Mode_Chack_status   检查结果:$Chack_out" 

                elif [[ $manufacture = 'BIOS-08' ]]; then
#超线程开启
[ "$Thread_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "超线程配置:要求开启  实际配置:$Thread_Chack_status   检查结果:$Chack_out" 
#NUMA开启
[ "$NUMA_Chack_status" == ON ] && Chack_out="\033[32m Pass \033[0m" || Chack_out="\033[31m Fail \033[0m"
echo -e "NUMA配置:要求开启    实际配置:$NUMA_Chack_status   检查结果:$Chack_out" 

                fi


        fi
        let i+=1

done < '/tmp/bios_fq_info.csv'
echo "------------------------------------------------------------------"

执行示例,输出检查结果:

赞(4)
未经允许不得转载:未来往事的博客 » BIOS、超线程、NUMA、CPU高性能、睿频服务器批量检查

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址