forked from orlikoski/fanoverlord
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipmifan.sh
executable file
·185 lines (158 loc) · 4.76 KB
/
ipmifan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
# ----------------------------------------------------------------------------------
# Every X seconds this script checks the temperature reported by the System Board Exhaust temperature sensor,
# and if deemed too high sends the raw IPMI command to adjust the fan speed on an R7910 server.
#
#
#
# Requires:
# ipmitool – yum install ipmitool
#
# ----------------------------------------------------------------------------------
# IPMI SETTINGS:
# DEFAULT IP: 192.168.0.120
IPMIHOST=192.168.108.59 # <IP Address of the iDRAC on the Server>
IPMIUSER=root # <User for the iDRAC>
IPMIPW=S*13qW6R+q@HQK2d07/- # <Password for the iDRAC
INTERVAL=30
# TEMPERATURE
# Change this to the temperature in celcius you are comfortable with.
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
# According to iDRAC Min Warning is 42C and Failure (shutdown) is 47C
IdleTemp="30"
LowTemp=( "31" "32" "33" )
MidTemp=( "34" "35" "36")
HighTemp=( "37" "38" "39")
MAXTEMP="40"
# Last Octal controls values to know
# Query Fan speeds
# ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type fan
#
# Fan Power Percentages
# 0x00 = 0%
# 0x64 = 100%
#
# R7910 RPM values
# 5 = 2400 RPM 5%
# a = 3360 RPM 10%
# 0f = 4080 RPM 15%
# 14 = 4920 RPM 20%
# 19 = 5640 RPM 25%
# 1e = 6480 RPM 30%
# 23 = 7200 RPM 35%
# 28 = 8040 RPM 40%
# 2d = xxxx RPM 45%
# 32 = xxxx RPM 50%
# 3c = xxxx RPM 60%
# 50 = xxxxx RPM 80%
# 10%
function FanLevel10()
{
echo "Setting fan speed to 10%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0xa
}
# 15%
function FanLevel15()
{
echo "Setting fan speed to 15%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x0f
}
# 20%
function FanLevel20()
{
echo "Setting fan speed to 20%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x14
}
# 25%
function FanLevel25()
{
echo "Setting fan speed to 25%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x19
}
# 30%
function FanLevel30()
{
echo "ASetting fan speed to 30%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x1e
}
# 35%
function FanLevel35()
{
echo "Setting fan speed to 35%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x23
}
# 40%
function FanLevel40()
{
echo "Setting fan speed to 40%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x28
}
# 45%
function FanLevel45()
{
echo "Setting fan speed to 45%"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x2d
}
# Auto-controled
function FanAuto()
{
echo "Dynamic fan control Active ($CurrentTemp C)"
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x01
}
function gettemp()
{
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type temperature | grep Exhaust | cut -d \| -f5 |grep -Po '\d{2}')
echo "$TEMP"
}
# Helper function for does an array contain a this value
array_contains () {
local array="$1[@]"
local seeking=$2
for element in "${!array}"; do
if [[ $element == $seeking ]]; then
return 1
fi
done
return 0
}
# Start by setting the fans to default low level
#echo "Info: Activating manual fan speeds 10%"
#ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00
#ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x0f
#FanLevel15
while :
do
CurrentTemp=$(gettemp)
echo "System Board Exhaust Temp: $CurrentTemp Celcius"
echo " "
if [[ $CurrentTemp > $MAXTEMP ]]; then
FanAuto
fi
if [[ $CurrentTemp < $IdleTemp ]]; then
FanLevel20
fi
array_contains LowTemp $CurrentTemp
result=$(echo $?)
if [ "$result" -eq 1 ] ; then
FanLevel25
fi
array_contains MidTemp $CurrentTemp
result=$(echo $?)
if [ "$result" -eq 1 ] ; then
FanLevel35
fi
array_contains HighTemp $CurrentTemp
result=$(echo $?)
if [ "$result" -eq 1 ] ; then
FanLevel45
fi
sleep $INTERVAL
done