/ilo-fans-controller

Easily manage your HP server's fans speeds, anywhere!

Primary LanguagePHPMIT LicenseMIT

iLO Fans Controller

Webpage Screenshot
Easily manage your HP's server fans speeds, anywhere!


NOTE: The v1.0.0 is a complete rewrite of the tool, so any feedback is appreciated!
If you find any bug or have any suggestion, please open an issue. Thanks! 😄

FAQ

How does it work? 🛠

This tool is a single PHP script that uses the php-curl extension to get the current server fan speeds from the iLO REST api and the php-ssh2 extension to set the fan speeds using the patched iLO SSH interface. You can also create custom presets to set a specific fan configuration with a single click, all with a simple and clean web interface made using Alpine.js and TailwindCSS.

Can I use this tool with my HP server? 🖥️

This tool requires a patched iLO firmware that expose to the iLO SSH interface some commands to manipulate the fans speeds. You can find more information about this patch on this Reddit post.

As of now, the patch (and so this tool) only works for Gen8 & Gen9 servers with iLO 4.

Gen10 servers with iLO 5 are not supported at the moment.

I prefer the original version™, can I still use it?

Sure, although I spent a lot of time rewriting the tool from scratch so I would recommend using this version instead.

Anyway, you can download the original version™ from the GitHub releases page.

Why PHP? And why a single file? 📄

Answer #1: In my opinion, PHP is perfect for this type of tasks where you need to do some server-side things and something easy to deploy (you just need a web server with PHP installed).

Answer #2: I wanted to make this tool as easy as possible to install and use, so I decided to put everything in a single file.

Why did you make this? 🤔

See my original comment on r/homelab to know the story behind this tool!

How can I offer you a coffee? ☕

If you found this tool useful, consider offering me a coffee using PayPal or Ko-fi to support my work! Thank you so much! 🙏


How to install

IMPORTANT!

Again, this tool works thanks to a patched iLO firmware that expose to the iLO SSH interface some commands to manipulate the fans speeds.

This patch is required to use this tool!

The following guide was run on

  • An HP DL380e G8 server
  • Patched iLO 4 Advanced v2.77 (07 December 2020)
  • A Proxmox container (LXC) running Ubuntu 22.04
  • Apache 2 & PHP 8.1

Preparing the environment

  1. Update the system:

    sudo apt-get update && sudo apt-get upgrade
  2. Install the required packages (apache2, php8.1, php8.1-curl and php8.1-ssh2):

    sudo apt-get install apache2 php8.1 php8.1-curl php8.1-ssh2

Downloading the tool

  1. Download and extract the latest source code using wget and tar:

    wget -qL https://github.com/alex3025/ilo-fans-controller/archive/refs/tags/1.0.0.tar.gz -O - | tar -xz
  2. Enter the directory:

    cd ilo-fans-controller-1.0.0

Configuring and installing the tool

  1. Open the config.inc.php file you favourite text editor and change the variables according to your configuration.

    NOTE: Remember that $ILO_HOST is the IP address of your iLO interface, not of the server itself.

    NOTE: It's recommended to create a new iLO user with the minimum privileges required to access the SSH interface and the REST api (Remote Console Access).

    Here is an example:

    <?php
    
    /*
    ILO ACCESS CREDENTIALS
    --------------
    These are used to connect to the iLO
    interface and manage the fan speeds.
    */
    
    $ILO_HOST = '192.168.1.69';
    $ILO_USERNAME = 'Administrator';
    $ILO_PASSWORD = 'AdministratorPassword1234';
    
    ?>
  2. When you're done, create a new subdirectory in your web server root directory (usually /var/www/html/) and copy the config.inc.php, ilo-fans-controller.php and favicon.ico to it:

    sudo mkdir /var/www/html/ilo-fans-controller
    sudo cp config.inc.php ilo-fans-controller.php favicon.ico /var/www/html/ilo-fans-controller/

    Then rename ilo-fans-controller.php to index.php (to make it work without specifying the filename in the URL):

    sudo mv /var/www/html/ilo-fans-controller/ilo-fans-controller.php /var/www/html/ilo-fans-controller/index.php
  3. That's it! Now you can reach the tool at http://<your-server-ip>/ilo-fans-controller/ (or http://<your-server-ip>/ilo-fans-controller/index.php for API requests).

NOTE: If the web server where you installed this tool will be reachable from outside your network, remember to setup some sort of authentication (like Basic Auth) to prevent unauthorized fan management at 2AM.


Troubleshooting

The first thing to do when you encounter a problem is to check the logs.

If you are using Apache, PHP errors are logged in the /var/log/apache2/error.log file.

If you think you found a bug, please open an issue and I'll take a look.

Below you can find some common problems and their solutions.

The presets are not saved

If you see the following error in the logs when you create a new preset:

PHP Warning:  file_put_contents(presets.json): Failed to open stream: Permission denied in .../index.php on line X

This is probably because the presets.json file is not writable by the web server user.
To fix this, run the following command to change the file owner to www-data (the default Apache user):

sudo chown www-data:www-data /var/www/html/ilo-fans-controller/presets.json

API Documentation (WIP)

The tool exposes a simple API that can be used to:

  • Get the current fan speeds from iLO
  • Set the fan speeds

There is also a way to manage the presets (get existing and add new ones) but it's not documented yet.
If you wish to do that, you can check inside the source code how that works

The following examples use cURL to show how to use the API, but you can use any other tool you want.

Get the fan speeds (GET)

To use this API you need to add ?api=fans at the end of the URL.
Example: http://<server ip>/ilo-fans-controller/index.php?api=fans

JSON structure (response)
{
    "Fan 1": 85,
    "Fan 2": 48,
    "Fan 3": 69,
    "Fan 4": 18,
    "Fan 5": 44,
    "Fan 6": 96
}
cURL example:
curl http://<server ip>/ilo-fans-controller/index.php?api=fans

Set the fan speeds (POST)

JSON structure example
{
    "action": "fans",
    // You can use either an object or a single number value (that will be applied to all fans):
    // Example: `fans: { ... }` or `fans: 50`
    "fans": {
        "Fan 1": 40,
        "Fan 2": 23,
        "Fan 5": 70
        // ...
    }
}
cURL example
curl -X POST http://<server ip>/ilo-fans-controller/index.php -H 'Content-Type: application/json' -d '{"action": "fans", "fans": 50}'

This command will set all fans to 50%.
I personally use this command to slow down the fans automatically when my server boots.