Skip to content

Instantly share code, notes, and snippets.

@perfecto25
Created May 23, 2023 21:42
Show Gist options
  • Save perfecto25/63c943031a54bcf6e520154da7a6c235 to your computer and use it in GitHub Desktop.
Save perfecto25/63c943031a54bcf6e520154da7a6c235 to your computer and use it in GitHub Desktop.
Dell BIOS automation
#!/bin/bash
# reset firmware to optimized settings
# usage:
# ./dellbios.sh - prints current settings
# ./dellbios.sh configure - configures optimized BIOS settings (will require reboot to pick up changes)
export PATH=$PATH:/opt/dell/srvadmin/sbin/
red="\e[0;91m"
blue="\e[0;94m"
expand_bg="\e[K"
blue_bg="\e[0;104m${expand_bg}"
red_bg="\e[0;101m${expand_bg}"
green_bg="\e[0;102m${expand_bg}"
green="\e[0;92m"
white="\e[0;97m"
bold="\e[1m"
uline="\e[4m"
reset="\e[0m"
create_job=0
function check_state() {
expected=$1
actual=$2
name=$3
racsection=$4
err=0
[[ -z "${actual}" ]] && return;
if [[ "${expected}" == "${actual}" ]]
then
echo -e "${green}> $name is ${actual}${reset}"
else
echo -e "${red}>> $name is ${actual} - should be ${expected}${reset}"
err=1
create_job=1
fi
if [[ "${action}" == "configure" ]]
then
if [ $err -eq 1 ]
then
echo -e "${blue}updating $name to ${expected}....${reset}"
racadm set "${racsection}" "${expected}"
if [ $? -eq 0 ]
then
echo -e "${blue}> optimization complete.${reset}\n"
else
echo -e "${red}> Error setting optimization.${reset}\n"
fi
fi
fi
}
#set -x
if [[ -n "${1}" ]]
then
[[ "${1}" != "configure" ]] && { echo -e "${red}not valid command, run with $0 configure${reset}"; exit 1; }
action="${1}"
fi
echo -e "\n${white}checking BIOS CPU settings\n${reset}"
section="BIOS.ProcSettings"
proc=$(racadm get $section)
val=$(echo $proc | awk -F 'LogicalProc=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Hyperthreading" "${section}.LogicalProc"
val=$(echo $proc | awk -F 'DcuIpPrefetcher=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "DCU Ip Prefetcher" "${section}.DcuIpPrefetcher"
val=$(echo $proc | awk -F 'DcuStreamerPrefetcher=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "DCU Streamer Prefetcher" "${section}.DcuStreamerPrefetcher"
val=$(echo $proc | awk -F 'ProcAdjCacheLine=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Adjacent Cache Line Prefetcher" "${section}.ProcAdjCacheLine"
val=$(echo $proc | awk -F 'ProcHwPrefetcher=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Hardware Prefetcher" "${section}.ProcHwPrefetcher"
val=$(echo $proc | awk -F 'ProcVirtualization=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Virtualization" "${section}.ProcVirtualization"
val=$(echo $proc | awk -F 'CpuInterconnectBusSpeed=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "MaxDataRate" ${val} "CPU Interconnect Bus Link Speed" "${section}.CpuInterconnectBusSpeed"
val=$(echo $proc | awk -F 'QpiSpeed=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "MaxDataRate" ${val} "CPU Interconnect Speed" "${section}.QpiSpeed"
val=$(echo $proc | awk -F 'ProcCores=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "All" ${val} "Number of Cores per Processor" "${section}.ProcCores"
val=$(echo $proc | awk -F 'ControlledTurbo=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Enabled" ${val} "Dell Controlled Turbo" "${section}.ControlledTurbo"
# Dynamic Core Allocation
# Enables or disables the operating system capability to set the logical processors in idle state which helps to reduce power consumption.
val=$(echo $proc | awk -F 'DynamicCoreAllocation=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Dynamic Core Allocation" "${section}.DynamicCoreAllocation"
echo -e "\n${white}checking BIOS System Profile settings\n${reset}"
section="BIOS.SysProfileSettings"
proc=$(racadm get $section)
val=$(echo $proc | awk -F 'SysProfile=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "PerfOptimized" ${val} "System Profile" "${section}.SysProfile"
val=$(echo $proc | awk -F 'MemFrequency=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "MaxPerf" ${val} "Memory Frequency" "${section}.MemFrequency"
val=$(echo $proc | awk -F 'ProcPwrPerf=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "MaxPerf" ${val} "Power Performance" "${section}.ProcPwrPerf"
echo -e "\n${white}checking BIOS Memory settings\n${reset}"
section="BIOS.MemSettings"
proc=$(racadm get $section)
val=$(echo $proc | awk -F 'NodeInterleave=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Node Interleaving" "${section}.NodeInterleave"
val=$(echo $proc | awk -F 'MemTest=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Enabled" ${val} "System Memory Testing" "${section}.MemTest"
val=$(echo $proc | awk -F 'MemOpMode=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "OptimizerMode" ${val} "Optimizer Mode" "${section}.MemOpMode"
echo -e "\n${white}checking IDRAC settings\n${reset}"
section="IDRAC.Telnet"
proc=$(racadm get $section)
val=$(echo $proc | awk -F 'Enable=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "Telnet" "${section}.Enable"
section="IDRAC.IPV6"
proc=$(racadm get $section)
val=$(echo $proc | awk -F 'Enable=' '{print $2}' | awk '{print $1}')
[[ -n $val ]] && check_state "Disabled" ${val} "IPv6" "${section}.Enable"
# create IDRAC job
if [[ "${action}" == "configure" ]]
then
if [ $create_job -eq 1 ]
then
racadm jobqueue create BIOS.Setup.1-1
[ ! $? -eq 0 ] && { echo -e "${red}Unable to schedule BIOS update job, you will need to manually change these settings after reboot${reset}"; exit 1; }
echo -e "${bold}${white}Racadm job scheduled to update BIOS settings, you will need to reboot to pick up changes${reset}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment