Remotely monitoring my server's temperature and controlling the fan speed accordingly has been one of the more frustrating things I had to do. But that ends today! (Kind of...) Here's how I solved that issue with Python Flask and ipmitool.
- A system in the same network as the server installed with Python 3(This could very well be the server itself or a virtual machine running on the server. Baseline: machine should be able to reach server without any network issues)
- Dell Server with IDRAC and IPMI over LAN turned on
Solution to Issue
With the help of IPMI (Intelligent Platform Management Interface) over LAN, we would be able to query power supply usage, fan speed, server health, security details, and the state of operating systems. However, I'd be using this to query the server's temperature and change the fan speed.
One small hurdle is that we have to have a machine in the same network as the server (unless you want to expose your IPMI to the WWW). This bump can be overcome with the help of a custom made API exposed out to the internet through a reverse proxy. However its highly recommended that you obscure your API endpoint to prevent malicious actors from playing around with it. This can cause some serious damage to the hardware.
Here's the simple Python Flask API Server that I wrote. It performs 2 simple but crucial tasks.
- Get Current Server Temperature
- Set Server Fan Speed
The Flask application entirely depends on the system having the
ipmitool utility. Let's go ahead and install that first
apt-get install ipmitool -y
Installing Python3 and pip
apt-get install python3 python3-pip -y
git clone https://github.com/ItsNee/Dell-PowerEdge-R710-Fan-Controller-API.git
pip3 install -r requirements.txt
Here's how to background the API Server.
nohup python3 api-server.py&
Here's how to kill a background process:
Find the ProcessID
ps -faux | grep api-server
kill -9 1085872
https://api.myserver.com/ = [Returns a welcome string] https://api.myserver.com/get-temperature = [Returns the server's temperature] https://api.myserver.com/set-fan-speed/<SPEED> = [<SPEED> variable can be adjusted by end user]
IFTTT is a free application that I make use of in order to send web requests with a tap of a widget on my phone's home screen.
Creating an applet is as easy as picking "this" and "that". In my case, I went with "If button push, send web request"
And with that, I'm able to remotely change my server's Fan Speed with a push of a button from my phone's home screen!