Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pdiddy973 committed Jun 30, 2024
1 parent 6dc3cc7 commit 057588e
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 pdiddy973

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 52 additions & 0 deletions adaptivefancontrol.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function get_temp {
local TEMP=$(ipmitool -I lanplus -H $IDRAC_HOST -U $IDRAC_USER -P $IDRAC_PW sdr type temperature | grep Exhaust | grep -o -e '[0-9][0-9] degrees' | grep -o -e '[0-9][0-9]')
echo $TEMP
}

function set_speed {
ipmitool -I lanplus -H $IDRAC_HOST -U $IDRAC_USER -P $IDRAC_PW raw 0x30 0x30 0x02 0xff $HEX > /dev/null
}

TEMP=$(get_temp)
if [ "$TEMP" -ge 0 ] && [ "$TEMP" -lt 35 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 20%"
HEX=0x14
set_speed
elif [ "$TEMP" -ge 35 ] && [ "$TEMP" -lt 40 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 30%"
HEX=0x1e
set_speed
elif [ "$TEMP" -ge 40 ] && [ "$TEMP" -lt 45 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 40%"
HEX=0x28
set_speed
elif [ "$TEMP" -ge 45 ] && [ "$TEMP" -lt 50 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 50%"
HEX=0x32
set_speed
elif [ "$TEMP" -ge 50 ] && [ "$TEMP" -lt 55 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 60%"
HEX=0x3c
set_speed
elif [ "$TEMP" -ge 55 ] && [ "$TEMP" -lt 60 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 70%"
HEX=0x46
set_speed
elif [ "$TEMP" -ge 60 ] && [ "$TEMP" -lt 70 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 80%"
HEX=0x50
set_speed
elif [ "$TEMP" -ge 70 ] && [ "$TEMP" -lt 80 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 90%"
HEX=0x5a
set_speed
elif [ "$TEMP" -ge 80 ] && [ "$TEMP" -le 100 ]; then
echo "Exhaust Temperature is $TEMP : Setting fan speed to 100%"
HEX=0x64
set_speed
else
echo "Temperature $TEMP: Was not able to get proper tempature"
fi

sleep "$CHECK_INTERVAL"s
exec "/opt/adaptivefancontrol.sh"
1 change: 1 addition & 0 deletions crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * /opt/adaptivefancontrol.sh
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'
services:
dell-idrac-fancontrol:
image: pdiddy973/dell-idrac-fancontrol:latest
container_name: dell-idrac-fancontrol
restart: unless-stopped
environment:
- IDRAC_HOST=
- IDRAC_USER=
- IDRAC_PW=
- CHECK_INTERVAL=
17 changes: 17 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:edge

RUN apk --no-cache add ipmitool apk-cron

COPY crontab /etc/cron.d/fan-control
COPY adaptivefancontrol.sh /opt/adaptivefancontrol.sh
RUN chmod 0777 /etc/cron.d/fan-control && \
chmod 0777 /opt/*.sh && \
/usr/bin/crontab /etc/cron.d/fan-control

# These can be overridden at runtime
ENV IDRAC_HOST=192.168.0.240 \
IDRAC_USER=root \
IDRAC_PW=calvin \
CHECK_INTERVAL=30

CMD /opt/adaptivefancontrol.sh && crond

0 comments on commit 057588e

Please sign in to comment.