mirror of
https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker.git
synced 2025-10-23 04:51:57 +00:00
Beautify code and log messages
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -4,26 +4,27 @@ RUN apt-get update
|
|||||||
|
|
||||||
RUN apt-get install ipmitool cron -y
|
RUN apt-get install ipmitool cron -y
|
||||||
|
|
||||||
COPY crontab /etc/cron.d/fan-control
|
COPY crontab /etc/cron.d/dell_idrac_fan_control
|
||||||
|
|
||||||
RUN chmod 0777 /etc/cron.d/fan-control
|
RUN chmod 0777 /etc/cron.d/dell_idrac_fan_control
|
||||||
|
|
||||||
RUN touch /var/log/cron.log
|
RUN touch /var/log/cron.log
|
||||||
|
|
||||||
ADD check-temp.sh /opt/check-temp.sh
|
ADD check_temp.sh /opt/check_temp.sh
|
||||||
|
|
||||||
ADD startup.sh /startup.sh
|
ADD startup.sh /startup.sh
|
||||||
|
|
||||||
RUN chmod 0777 /opt/check-temp.sh
|
RUN chmod 0777 /opt/check_temp.sh
|
||||||
|
|
||||||
RUN chmod 0777 /startup.sh
|
RUN chmod 0777 /startup.sh
|
||||||
|
|
||||||
RUN /usr/bin/crontab /etc/cron.d/fan-control
|
RUN /usr/bin/crontab /etc/cron.d/dell_idrac_fan_control
|
||||||
|
|
||||||
# you should override these when running. See README.md
|
# you should override these default values when running. See README.md
|
||||||
#ENV IDRAC_HOST 192.168.1.100
|
#ENV IDRAC_HOST 192.168.1.100
|
||||||
ENV IDRAC_HOST local
|
ENV IDRAC_HOST local
|
||||||
#ENV IDRAC_USER root
|
#ENV IDRAC_USER root
|
||||||
#ENV IDRAC_PW calvin
|
#ENV IDRAC_PASSWORD calvin
|
||||||
ENV FAN_SPEED 5
|
ENV FAN_SPEED 5
|
||||||
CMD /startup.sh && cron && tail -f /var/log/cron.log
|
|
||||||
|
CMD /startup.sh && /opt/check_temp.sh && cron && tail -f /var/log/cron.log
|
||||||
|
38
README.md
38
README.md
@@ -1,10 +1,34 @@
|
|||||||
# IDRAC Fan Controller Docker Image
|
# IDRAC Fan Controller Docker Image
|
||||||
|
|
||||||
To use,
|
- `IDRAC_HOST` parameter can be set to "local" or to your distant iDRAC's IP address. Default value is "local".
|
||||||
|
- `IDRAC_USERNAME` parameter is only necessary if you're adressing a distant iDRAC. Default value is "root".
|
||||||
|
- `IDRAC_PASSWORD` parameter is only necessary if you're adressing a distant iDRAC. Default value is "calvin".
|
||||||
|
- `FAN_SPEED` parameter can be set as a decimal or hexadecimal value (0x00 to 0x64). Default value is 5 (%).
|
||||||
|
|
||||||
`docker run -e IDRAC_HOST=<host ip> -e IDRAC_USER=<username> -e IDRAC_PW=<password> -e FAN_SPEED=<dec or hex fan speed> alombardo4/idrac-fan-control:latest`
|
To use:
|
||||||
|
|
||||||
`FAN_SPEED` can be set as a decimal or hexadecimal value (0x00 to 0x64). Default value is 5 (%).
|
1. with local iDRAC:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name Dell_iDRAC_fan_controller \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-e FAN_SPEED=<dec or hex fan speed> \
|
||||||
|
alombardo4/idrac-fan-control:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
2. with LAN iDRAC:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name Dell_iDRAC_fan_controller \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-e IDRAC_HOST=<iDRAC host IP> \
|
||||||
|
-e IDRAC_USERNAME=<iDRAC username> \
|
||||||
|
-e IDRAC_PASSWORD=<iDRAC password> \
|
||||||
|
-e FAN_SPEED=<dec or hex fan speed> \
|
||||||
|
alombardo4/idrac-fan-control:latest
|
||||||
|
```
|
||||||
|
|
||||||
`docker-compose.yml` examples:
|
`docker-compose.yml` examples:
|
||||||
|
|
||||||
@@ -16,6 +40,7 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
Dell_iDRAC_fan_controller:
|
Dell_iDRAC_fan_controller:
|
||||||
image: alombardo4/idrac-fan-control
|
image: alombardo4/idrac-fan-control
|
||||||
|
container_name: Dell_iDRAC_fan_controller
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- IDRAC_HOST=local # can be omitted as it is the default value
|
- IDRAC_HOST=local # can be omitted as it is the default value
|
||||||
@@ -32,10 +57,11 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
Dell_iDRAC_fan_controller:
|
Dell_iDRAC_fan_controller:
|
||||||
image: alombardo4/idrac-fan-control
|
image: alombardo4/idrac-fan-control
|
||||||
|
container_name: Dell_iDRAC_fan_controller
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- IDRAC_HOST=192.168.1.100 # override to the IP of your IDRAC
|
- IDRAC_HOST=192.168.1.100 # override to the IP address of your IDRAC
|
||||||
- IDRAC_USER=root # set to your IPMI username
|
- IDRAC_USERNAME=root # set to your IPMI username
|
||||||
- IDRAC_PW=calvin # set to your IPMI password
|
- IDRAC_PASSWORD=calvin # set to your IPMI password
|
||||||
- FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%)
|
- FAN_SPEED=0x05 # set to the decimal or hexadecimal value you want to set the fans to (from 0 to 100%)
|
||||||
```
|
```
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
IPMIHOST=`cat /host.txt`
|
|
||||||
IPMIUSER=`cat /user.txt`
|
|
||||||
IPMIPW=`cat /pw.txt`
|
|
||||||
DECIMAL_FAN_SPEED=`cat /decimal_fan_speed.txt`
|
|
||||||
HEXADECIMAL_FAN_SPEED=`cat /hexadecimal_fan_speed.txt`
|
|
||||||
|
|
||||||
MAXTEMP=32
|
|
||||||
|
|
||||||
if [[ $IPMIHOST == "local" ]]
|
|
||||||
then
|
|
||||||
LOGIN_STRING='open'
|
|
||||||
else
|
|
||||||
LOGIN_STRING="lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP=$(ipmitool -I $LOGIN_STRING sdr type temperature |grep Inlet |grep degrees |grep -Po '\d{2}' | tail -1)
|
|
||||||
|
|
||||||
echo "Current Temp is $TEMP C"
|
|
||||||
if [ $TEMP -gt $MAXTEMP ];
|
|
||||||
then
|
|
||||||
echo "Temp is too high. Activating dynamic fan control"
|
|
||||||
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x01
|
|
||||||
else
|
|
||||||
echo "Temp is OK. Using manual fan control"
|
|
||||||
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x00
|
|
||||||
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED
|
|
||||||
fi
|
|
34
check_temp.sh
Executable file
34
check_temp.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
IPMI_HOST=`cat /idrac_host.txt`
|
||||||
|
IPMI_USERNAME=`cat /idrac_username.txt`
|
||||||
|
IPMI_PASSWORD=`cat /idrac_password.txt`
|
||||||
|
DECIMAL_FAN_SPEED=`cat /decimal_fan_speed.txt`
|
||||||
|
HEXADECIMAL_FAN_SPEED=`cat /hexadecimal_fan_speed.txt`
|
||||||
|
|
||||||
|
MAX_INLET_TEMPERATURE=32
|
||||||
|
|
||||||
|
if [[ $IPMI_HOST == "local" ]]
|
||||||
|
then
|
||||||
|
LOGIN_STRING='open'
|
||||||
|
else
|
||||||
|
LOGIN_STRING="lanplus -H $IPMI_HOST -U $IPMI_USERNAME -P $IPMI_PASSWORD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
INLET_TEMPERATURE=$(ipmitool -I $LOGIN_STRING sdr type temperature |grep Inlet |grep degrees |grep -Po '\d{2}' | tail -1)
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo "------------------------------------"
|
||||||
|
echo "Current inlet temperature is $INLET_TEMPERATURE °C."
|
||||||
|
if [ $INLET_TEMPERATURE -gt $MAX_INLET_TEMPERATURE ]
|
||||||
|
then
|
||||||
|
printf "Inlet temperature is ${RED}too high${NC}. Activating default dynamic fan control."
|
||||||
|
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x01
|
||||||
|
else
|
||||||
|
printf "Inlet temperature is ${GREEN}OK${NC}. Using manual fan control with ${DECIMAL_FAN_SPEED}%% fan speed."
|
||||||
|
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x01 0x00
|
||||||
|
ipmitool -I $LOGIN_STRING raw 0x30 0x30 0x02 0xff $HEXADECIMAL_FAN_SPEED
|
||||||
|
fi
|
2
crontab
2
crontab
@@ -1 +1 @@
|
|||||||
* * * * * /bin/bash -c "/opt/check-temp.sh &> /var/log/cron.log"
|
* * * * * /bin/bash -c "/opt/check_temp.sh &> /var/log/cron.log"
|
||||||
|
12
startup.sh
12
startup.sh
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo $IDRAC_HOST >> /host.txt
|
echo $IDRAC_HOST >> /idrac_host.txt
|
||||||
echo $IDRAC_USER >> /user.txt
|
echo $IDRAC_USERNAME >> /idrac_username.txt
|
||||||
echo $IDRAC_PW >> /pw.txt
|
echo $IDRAC_PASSWORD >> /idrac_password.txt
|
||||||
|
|
||||||
if [[ $FAN_SPEED == 0x* ]]
|
if [[ $FAN_SPEED == 0x* ]]
|
||||||
then
|
then
|
||||||
@@ -16,10 +16,10 @@ fi
|
|||||||
echo $DECIMAL_FAN_SPEED >> /decimal_fan_speed.txt
|
echo $DECIMAL_FAN_SPEED >> /decimal_fan_speed.txt
|
||||||
echo $HEXADECIMAL_FAN_SPEED >> /hexadecimal_fan_speed.txt
|
echo $HEXADECIMAL_FAN_SPEED >> /hexadecimal_fan_speed.txt
|
||||||
|
|
||||||
echo "Host: `cat /host.txt`"
|
echo "Idrac/IPMI host: `cat /idrac_host.txt`"
|
||||||
if [[ $IDRAC_HOST != "local" ]]
|
if [[ $IDRAC_HOST != "local" ]]
|
||||||
then
|
then
|
||||||
echo "User: `cat /user.txt`"
|
echo "Idrac/IPMI user: `cat /idrac_username.txt`"
|
||||||
echo "PW: `cat /pw.txt`"
|
echo "Idrac/IPMI password: `cat /idrac_password.txt`"
|
||||||
fi
|
fi
|
||||||
echo "Fan speed objective: `cat /decimal_fan_speed.txt`%"
|
echo "Fan speed objective: `cat /decimal_fan_speed.txt`%"
|
||||||
|
Reference in New Issue
Block a user