Minor code structure improvements
This commit is contained in:
parent
ce7bb3fc9a
commit
db64028f2f
3 changed files with 32 additions and 54 deletions
28
functions.sh
28
functions.sh
|
|
@ -1,13 +1,13 @@
|
|||
# Define global functions
|
||||
# This function applies Dell's default dynamic fan control profile
|
||||
function apply_Dell_fan_control_profile () {
|
||||
function apply_Dell_fan_control_profile() {
|
||||
# Use ipmitool to send the raw command to set fan control to Dell default
|
||||
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x01 > /dev/null
|
||||
CURRENT_FAN_CONTROL_PROFILE="Dell default dynamic fan control profile"
|
||||
}
|
||||
|
||||
# This function applies a user-specified static fan control profile
|
||||
function apply_user_fan_control_profile () {
|
||||
function apply_user_fan_control_profile() {
|
||||
# Use ipmitool to send the raw command to set fan control to user-specified value
|
||||
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x01 0x00 > /dev/null
|
||||
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED > /dev/null
|
||||
|
|
@ -17,7 +17,7 @@ function apply_user_fan_control_profile () {
|
|||
# Convert first parameter given ($DECIMAL_NUMBER) to hexadecimal
|
||||
# Usage : convert_decimal_value_to_hexadecimal $DECIMAL_NUMBER
|
||||
# Returns : hexadecimal value of DECIMAL_NUMBER
|
||||
function convert_decimal_value_to_hexadecimal () {
|
||||
function convert_decimal_value_to_hexadecimal() {
|
||||
local DECIMAL_NUMBER=$1
|
||||
local HEXADECIMAL_NUMBER=$(printf '0x%02x' $DECIMAL_NUMBER)
|
||||
echo $HEXADECIMAL_NUMBER
|
||||
|
|
@ -25,9 +25,8 @@ function convert_decimal_value_to_hexadecimal () {
|
|||
|
||||
# Retrieve temperature sensors data using ipmitool
|
||||
# Usage : retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
|
||||
function retrieve_temperatures () {
|
||||
if (( $# != 2 ))
|
||||
then
|
||||
function retrieve_temperatures() {
|
||||
if (( $# != 2 )); then
|
||||
printf "Illegal number of parameters.\nUsage: retrieve_temperatures \$IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT \$IS_CPU2_TEMPERATURE_SENSOR_PRESENT" >&2
|
||||
return 1
|
||||
fi
|
||||
|
|
@ -39,8 +38,7 @@ function retrieve_temperatures () {
|
|||
# Parse CPU data
|
||||
local CPU_DATA=$(echo "$DATA" | grep "3\." | grep -Po '\d{2}')
|
||||
CPU1_TEMPERATURE=$(echo $CPU_DATA | awk "{print \$$CPU1_TEMPERATURE_INDEX;}")
|
||||
if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
|
||||
then
|
||||
if $IS_CPU2_TEMPERATURE_SENSOR_PRESENT; then
|
||||
CPU2_TEMPERATURE=$(echo $CPU_DATA | awk "{print \$$CPU2_TEMPERATURE_INDEX;}")
|
||||
else
|
||||
CPU2_TEMPERATURE="-"
|
||||
|
|
@ -50,8 +48,7 @@ function retrieve_temperatures () {
|
|||
INLET_TEMPERATURE=$(echo "$DATA" | grep Inlet | grep -Po '\d{2}' | tail -1)
|
||||
|
||||
# If exhaust temperature sensor is present, parse its temperature data
|
||||
if $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT
|
||||
then
|
||||
if $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT; then
|
||||
EXHAUST_TEMPERATURE=$(echo "$DATA" | grep Exhaust | grep -Po '\d{2}' | tail -1)
|
||||
else
|
||||
EXHAUST_TEMPERATURE="-"
|
||||
|
|
@ -59,13 +56,13 @@ function retrieve_temperatures () {
|
|||
}
|
||||
|
||||
# /!\ Use this function only for Gen 13 and older generation servers /!\
|
||||
function enable_third_party_PCIe_card_Dell_default_cooling_response () {
|
||||
function enable_third_party_PCIe_card_Dell_default_cooling_response() {
|
||||
# We could check the current cooling response before applying but it's not very useful so let's skip the test and apply directly
|
||||
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 > /dev/null
|
||||
}
|
||||
|
||||
# /!\ Use this function only for Gen 13 and older generation servers /!\
|
||||
function disable_third_party_PCIe_card_Dell_default_cooling_response () {
|
||||
function disable_third_party_PCIe_card_Dell_default_cooling_response() {
|
||||
# We could check the current cooling response before applying but it's not very useful so let's skip the test and apply directly
|
||||
ipmitool -I $IDRAC_LOGIN_STRING raw 0x30 0xce 0x00 0x16 0x05 0x00 0x00 0x00 0x05 0x00 0x01 0x00 0x00 > /dev/null
|
||||
}
|
||||
|
|
@ -88,12 +85,11 @@ function disable_third_party_PCIe_card_Dell_default_cooling_response () {
|
|||
# }
|
||||
|
||||
# Prepare traps in case of container exit
|
||||
function graceful_exit () {
|
||||
function graceful_exit() {
|
||||
apply_Dell_fan_control_profile
|
||||
|
||||
# Reset third-party PCIe card cooling response to Dell default depending on the user's choice at startup
|
||||
if ! $KEEP_THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE_STATE_ON_EXIT
|
||||
then
|
||||
if ! $KEEP_THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE_STATE_ON_EXIT; then
|
||||
enable_third_party_PCIe_card_Dell_default_cooling_response
|
||||
fi
|
||||
|
||||
|
|
@ -102,7 +98,7 @@ function graceful_exit () {
|
|||
}
|
||||
|
||||
# Helps debugging when people are posting their output
|
||||
function get_Dell_server_model () {
|
||||
function get_Dell_server_model() {
|
||||
IPMI_FRU_content=$(ipmitool -I $IDRAC_LOGIN_STRING fru 2>/dev/null) # FRU stands for "Field Replaceable Unit"
|
||||
|
||||
SERVER_MANUFACTURER=$(echo "$IPMI_FRU_content" | grep "Product Manufacturer" | awk -F ': ' '{print $2}')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue