-
Notifications
You must be signed in to change notification settings - Fork 3
/
dellfanctrl
58 lines (53 loc) · 2.01 KB
/
dellfanctrl
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
#!/bin/bash
# This is Dell R510 FAN control script. Should be compatible with R710 and others with DRAC 6
# IMPI commands used:
# ipmitool raw 0x30 0x30 0x01 0x00 # Disable system FAN control
# ipmitool raw 0x30 0x30 0x02 0xff 0x08 # Set FAN speed in percents
# ipmitool raw 0x30 0x30 0x01 0x01 # Enable system FAN control
# tested on FreeBSD 11.1 (FreeNAS) using `root` user
echo "Dell R510 FAN control script v1.0"
usage_example() {
echo "Example usage:"
echo -e "Enable automatic FAN control:\t\t$0 auto"
echo -e "Disable automatic FAN control:\t\t$0 manual"
echo -e "Disable & set speed to N percents:\t$0 set 10"
}
runthis() {
echo "Running: $1"
$1
EXIT_CODE=$?
if [ $EXIT_CODE == 0 ]; then
echo "Command executed successfully"
else
echo "Execution failed with status $EXIT_CODE"
fi
}
if [ $# == 0 ]; then
echo -e "There is not enough parameters for this script!\n"
usage_example
else
if [ $1 == "auto" ]; then
runthis "ipmitool raw 0x30 0x30 0x01 0x01"
elif [ $1 == "manual" ]; then
runthis "ipmitool raw 0x30 0x30 0x01 0x00"
elif [ $1 == "set" ]; then
SET_SPEED=15
if [ $2 -gt 0 ] && [ $2 -le 100 ]; then
SET_SPEED=`printf "%x\n" $2`
else
echo "Entered number is not in the range [1..100]: $2"
exit
fi
if [ `echo $SET_SPEED | wc -c` -eq 2 ]; then
SET_SPEED=0$SET_SPEED
fi
echo "Setting FAN speed to $2%"
runthis "ipmitool raw 0x30 0x30 0x02 0xff 0x$SET_SPEED"
elif [ $1 == "status" ]; then
echo "Current system status:"
ipmitool sensor | grep -iE "fan|temp" | awk -F"|" '{if($2!~"na"){print $1$2}}'
else
echo "Unknown parameter!"
usage_example
fi
fi