From 64929802f24dedfc96780f61e0792c38ee08c144 Mon Sep 17 00:00:00 2001 From: Tigerblue77 <37409593+tigerblue77@users.noreply.github.com> Date: Sun, 28 Jan 2024 22:09:05 +0000 Subject: [PATCH 1/2] Added server model printing at container startup --- Dell_iDRAC_fan_controller.sh | 20 ++++++++++++++++++++ README.md | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/Dell_iDRAC_fan_controller.sh b/Dell_iDRAC_fan_controller.sh index bb6c536..46dac84 100644 --- a/Dell_iDRAC_fan_controller.sh +++ b/Dell_iDRAC_fan_controller.sh @@ -90,6 +90,23 @@ function gracefull_exit () { exit 0 } +# Help debugging when people are posting their output +# /!\ This function only works when started in local mode /!\ +function get_Dell_server_model () { + # Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container + if [ ! -e "/dev/mem" ]; then + echo "/!\ Could not open device at /dev/mem, check that you added the device to your Docker container or stop using local mode. Exiting." >&2 + exit 1 + fi + apt-get install dmidecode -qq > /dev/null 2>&1 + + SERVER_MANUFACTURER=$(dmidecode -s system-manufacturer) + SERVER_MODEL=$(dmidecode -s system-product-name) + + apt-get remove --purge dmidecode -qq > /dev/null + apt-get clean -qq +} + # Trap the signals for container exit and run gracefull_exit function trap 'gracefull_exit' SIGQUIT SIGKILL SIGTERM @@ -113,6 +130,9 @@ echo "iDRAC/IPMI host: $IDRAC_HOST" # Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly if [[ $IDRAC_HOST == "local" ]] then + get_Dell_server_model + echo "Server model: $SERVER_MANUFACTURER $SERVER_MODEL" + # Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then echo "/!\ Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0, check that you added the device to your Docker container or stop using local mode. Exiting." >&2 diff --git a/README.md b/README.md index 044465f..e261f7e 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,9 @@ docker run -d \ -e CPU_TEMPERATURE_THRESHOLD= \ -e CHECK_INTERVAL= \ -e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE= \ + --cap-add SYS_RAWIO \ --device=/dev/ipmi0:/dev/ipmi0:rw \ + --device=/dev/mem:/dev/mem:ro \ tigerblue77/dell_idrac_fan_controller:latest ``` @@ -112,6 +114,8 @@ services: Dell_iDRAC_fan_controller: image: tigerblue77/dell_idrac_fan_controller:latest container_name: Dell_iDRAC_fan_controller + cap_add: + - SYS_RAWIO # Required for dmidecode to work restart: unless-stopped environment: - IDRAC_HOST=local @@ -121,6 +125,7 @@ services: - DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE= devices: - /dev/ipmi0:/dev/ipmi0:rw + - /dev/mem:/dev/mem:rw # Required for dmidecode to work ``` 2. to use with LAN iDRAC: From b8372a76e680df26444852b3bb04d88a5bc7fe6d Mon Sep 17 00:00:00 2001 From: Tigerblue77 <37409593+tigerblue77@users.noreply.github.com> Date: Sun, 28 Jan 2024 22:09:18 +0000 Subject: [PATCH 2/2] Improved code by enabling it to run in LAN mode and removing capability which was required by dmidecode --- Dell_iDRAC_fan_controller.sh | 17 ++++------------- README.md | 5 ----- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Dell_iDRAC_fan_controller.sh b/Dell_iDRAC_fan_controller.sh index 46dac84..9486ac2 100644 --- a/Dell_iDRAC_fan_controller.sh +++ b/Dell_iDRAC_fan_controller.sh @@ -90,21 +90,12 @@ function gracefull_exit () { exit 0 } -# Help debugging when people are posting their output -# /!\ This function only works when started in local mode /!\ +# Helps debugging when people are posting their output function get_Dell_server_model () { - # Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container - if [ ! -e "/dev/mem" ]; then - echo "/!\ Could not open device at /dev/mem, check that you added the device to your Docker container or stop using local mode. Exiting." >&2 - exit 1 - fi - apt-get install dmidecode -qq > /dev/null 2>&1 + IPMI_FRU_content=$(ipmitool fru 2>/dev/null) # FRU stands for "Field Replaceable Unit" - SERVER_MANUFACTURER=$(dmidecode -s system-manufacturer) - SERVER_MODEL=$(dmidecode -s system-product-name) - - apt-get remove --purge dmidecode -qq > /dev/null - apt-get clean -qq + SERVER_MANUFACTURER=$(echo "$IPMI_FRU_content" | grep "Product Manufacturer" | awk -F ': ' '{print $2}') + SERVER_MODEL=$(echo "$IPMI_FRU_content" | grep "Product Name" | awk -F ': ' '{print $2}') } # Trap the signals for container exit and run gracefull_exit function diff --git a/README.md b/README.md index e261f7e..044465f 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,7 @@ docker run -d \ -e CPU_TEMPERATURE_THRESHOLD= \ -e CHECK_INTERVAL= \ -e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE= \ - --cap-add SYS_RAWIO \ --device=/dev/ipmi0:/dev/ipmi0:rw \ - --device=/dev/mem:/dev/mem:ro \ tigerblue77/dell_idrac_fan_controller:latest ``` @@ -114,8 +112,6 @@ services: Dell_iDRAC_fan_controller: image: tigerblue77/dell_idrac_fan_controller:latest container_name: Dell_iDRAC_fan_controller - cap_add: - - SYS_RAWIO # Required for dmidecode to work restart: unless-stopped environment: - IDRAC_HOST=local @@ -125,7 +121,6 @@ services: - DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE= devices: - /dev/ipmi0:/dev/ipmi0:rw - - /dev/mem:/dev/mem:rw # Required for dmidecode to work ``` 2. to use with LAN iDRAC: