Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ REMOTE_GPU_TEMP_OFFSET=15
# -----------------------------------------------------------------------------
# Fan curve
# -----------------------------------------------------------------------------
# The controller chooses the highest matching level:
# Enabled by default: interpolate between the low/medium/high/critical anchors
# and round duty up to an integer percent. Below TEMP_LOW uses FAN_SPEED_IDLE;
# distinct idle/low speeds intentionally jump at TEMP_LOW (no idle temp anchor).
# At/above TEMP_CRITICAL, clamp to FAN_SPEED_CRITICAL. No hysteresis in this mode.
FAN_SPEED_INTERPOLATION=true
# Set false for the original stepwise curve and downshift-only HYSTERESIS:
# The controller then chooses the highest matching level:
# idle: temp < TEMP_LOW
# low: TEMP_LOW <= temp < TEMP_MEDIUM
# medium: TEMP_MEDIUM <= temp < TEMP_HIGH
Expand All @@ -101,13 +107,13 @@ TEMP_MEDIUM=70
TEMP_HIGH=75
TEMP_CRITICAL=80

FAN_SPEED_IDLE=25
FAN_SPEED_IDLE=30
FAN_SPEED_LOW=30
FAN_SPEED_MEDIUM=40
FAN_SPEED_HIGH=50
FAN_SPEED_CRITICAL=60

# Prevent fan speed flapping near thresholds. Downshifts wait until the
# Stepwise mode only (FAN_SPEED_INTERPOLATION=false). Downshifts wait until the
# temperature falls this many degrees below the previous level threshold.
HYSTERESIS=2

Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Container](https://img.shields.io/badge/container-GHCR-blue)](https://github.com/DF-wu/iDRACFanSpeedControl/pkgs/container/idrac-fan-control)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)

A fan controller for Dell PowerEdge servers. It sets the fan duty cycle through iDRAC IPMI OEM raw commands, then selects a fan-curve level from pluggable temperature sources: ESXi NVMe SMART, iDRAC sensors, local Linux disks, and local or remote NVIDIA GPUs.
A fan controller for Dell PowerEdge servers. It sets the fan duty cycle through iDRAC IPMI OEM raw commands, then calculates fan speed from a configurable curve using pluggable temperature sources: ESXi NVMe SMART, iDRAC sensors, local Linux disks, and local or remote NVIDIA GPUs.

> [!CAUTION]
> This project has been tested on only my Dell PowerEdge R730xd with iDRAC 8. Other server models and iDRAC firmware versions are untested and must not be assumed compatible. This program temporarily overrides Dell's automatic fan control; use it at your own risk. During initial setup, keep the iDRAC Web UI or a physical console available. Verify `manual`, `restore`, and `diagnose` on your own hardware before running `auto` for an extended period. If the server overheats, readings become unreliable, or behavior is abnormal, run `restore` immediately and stop the container.
Expand Down Expand Up @@ -173,10 +173,13 @@ Before unattended operation, confirm each item:
```mermaid
flowchart TD
R[All valid readings] --> M{Select highest adjusted temperature}
M --> L[temperature_level]
M --> I{FAN_SPEED_INTERPOLATION?}
I -- true --> C[Interpolate anchors and round duty up]
C --> F
I -- false --> L[temperature_level]
L --> H{Lower than previous level?}
H -- No --> S[Increase immediately or keep level]
H -- Yes --> X{Below previous threshold - HYSTERESIS?}
H -- Yes --> X{At or below previous threshold - HYSTERESIS?}
X -- No --> S2[Keep previous level]
X -- Yes --> S3[Move to lower level]
S --> F[Apply fan speed]
Expand All @@ -185,18 +188,24 @@ flowchart TD
R -. All sources fail .-> FS[FAILSAFE_FAN_SPEED]
```

The default curve is shown below. `validate` ensures that thresholds are strictly increasing, fan speeds never decrease, and the fail-safe speed is not lower than the critical speed.
The default interpolation anchors and boundary speeds are shown below. Between anchors, duty rises linearly; the logged level names still describe the temperature band. `validate` ensures that thresholds are strictly increasing, fan speeds never decrease, and the fail-safe speed is not lower than the critical speed.

| Level | Decision temperature | Default fan speed |
| Level | Anchor / boundary temperature | Default fan speed |
| --- | --- | --- |
| `idle` | `<65°C` | 25% |
| `low` | `65–69°C` | 30% |
| `medium` | `70–74°C` | 40% |
| `high` | `75–79°C` | 50% |
| `idle` | `<65°C` | 30% |
| `low` | `65°C` | 30% |
| `medium` | `70°C` | 40% |
| `high` | `75°C` | 50% |
| `critical` | `>=80°C` | 60% |
| `failsafe` | All sources fail | 70% |

Moving to a lower fan level requires the temperature to fall by `HYSTERESIS` degrees below the relevant threshold, preventing repeated speed changes near a boundary. Moving to a higher level is immediate. Each source owns its adjustment: local and remote GPUs subtract their configured offset, Linux disks subtract `LINUX_DISK_TEMP_OFFSET`, and all results have a minimum of 0°C.
`FAN_SPEED_INTERPOLATION=true` is the default, including for existing configurations that omit the option. It joins `(TEMP_LOW, FAN_SPEED_LOW)`, `(TEMP_MEDIUM, FAN_SPEED_MEDIUM)`, `(TEMP_HIGH, FAN_SPEED_HIGH)`, and `(TEMP_CRITICAL, FAN_SPEED_CRITICAL)` with straight segments. Duty is rounded **up** to an integer percentage, stays monotonic within the validated 1–100% range, uses `FAN_SPEED_IDLE` below `TEMP_LOW`, and clamps to `FAN_SPEED_CRITICAL` at or above `TEMP_CRITICAL`. There is no invented idle-temperature anchor: distinct idle and low speeds intentionally cause a jump at `TEMP_LOW`.

Interpolation ignores `HYSTERESIS` and the previous level in both directions. Each successful collection cycle uses the current demand immediately, including increases within the same level; unchanged integer duty does not send another fan command. There is no additional smoothing, PID, or rate limit. For example, thresholds `65/70/75/80` and speeds `30/35/45/60/65` produce `45/48/51/54/57/60%` at `70/71/72/73/74/75°C`.

Set `FAN_SPEED_INTERPOLATION=false` to restore the original stepwise behavior: each anchor speed is held until the next threshold, and only downshifts wait for the temperature to reach the previous level threshold minus `HYSTERESIS` (equality releases the hold). Upshifts are immediate. In the TUI, change this switch under **Fan curve**; `config` and read-only `diagnose` show the mode and whether hysteresis is active.

Each source owns its adjustment: local and remote GPUs subtract their configured offset, Linux disks subtract `LINUX_DISK_TEMP_OFFSET`, and all results have a minimum of 0°C.

## Configuration reference

Expand Down Expand Up @@ -244,8 +253,9 @@ Moving to a lower fan level requires the temperature to fall by `HYSTERESIS` deg
| Variable | Default | Description |
| --- | --- | --- |
| `TEMP_LOW/MEDIUM/HIGH/CRITICAL` | `65/70/75/80` | Strictly increasing thresholds in °C |
| `FAN_SPEED_IDLE/LOW/MEDIUM/HIGH/CRITICAL` | `25/30/40/50/60` | Values from 1–100% that must not decrease |
| `HYSTERESIS` | `2` | Degrees below the previous threshold required before lowering fan speed |
| `FAN_SPEED_IDLE/LOW/MEDIUM/HIGH/CRITICAL` | `30/30/40/50/60` | Values from 1–100% that must not decrease; unset idle follows low |
| `FAN_SPEED_INTERPOLATION` | `true` | Piecewise linear interpolation with ceiling rounding; `false` restores legacy steps |
| `HYSTERESIS` | `2` | Stepwise mode only: degrees below the previous threshold required before lowering fan speed |
| `FAILSAFE_ON_ERROR` | `true` | Uses a conservative speed when all sources fail |
| `FAILSAFE_FAN_SPEED` | `70` | Must be greater than or equal to the critical speed |
| `MANUAL_FAN_SPEED` | `35` | Used by `manual` when no argument is provided |
Expand Down Expand Up @@ -360,7 +370,7 @@ make validate-example # DRY_RUN smoke test that does not require .env
make docker-build
```

Tests cover the source interface, Linux SMART collection, multi-host remote GPUs, source offsets, SDR parsing, hysteresis, fail-safe behavior, configuration validation, credential redaction, health freshness, diagnostics, and safe TUI configuration round-trips. Real hardware, SSH targets, disks, iDRAC, and GPUs must still be verified with `diagnose` on your management network.
Tests cover the source interface, Linux SMART collection, multi-host remote GPUs, source offsets, SDR parsing, interpolation anchors/rounding/bounds, legacy hysteresis, control-cycle state and fail-safe recovery, configuration validation, credential redaction, health freshness, diagnostics, and safe TUI configuration round-trips. Real hardware, SSH targets, disks, iDRAC, and GPUs must still be verified with `diagnose` on your management network.

## Project structure

Expand Down
34 changes: 22 additions & 12 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ sequenceDiagram
```mermaid
flowchart TD
R[所有有效 readings] --> M{取最高 adjusted temperature}
M --> L[temperature_level]
M --> I{FAN_SPEED_INTERPOLATION?}
I -- true --> C[錨點間線性插值並向上取整]
C --> F
I -- false --> L[temperature_level]
L --> H{比上一檔更低?}
H -- 否 --> S[立即升檔或維持]
H -- 是 --> X{低於前一檔 threshold - HYSTERESIS?}
H -- 是 --> X{小於等於前一檔 threshold - HYSTERESIS?}
X -- 否 --> S2[維持上一檔]
X -- 是 --> S3[降到新檔]
S --> F[套用 fan speed]
Expand All @@ -185,18 +188,24 @@ flowchart TD
R -. 全部失敗 .-> FS[FAILSAFE_FAN_SPEED]
```

預設曲線如下;`validate` 會確保 threshold 嚴格遞增、fan speed 不遞減,且 fail-safe 不低於 critical speed。
預設插值錨點與邊界速度如下。錨點間的 duty 線性增加,日誌 level 仍表示溫度區間;`validate` 會確保 threshold 嚴格遞增、fan speed 不遞減,且 fail-safe 不低於 critical speed。

| Level | 決策溫度 | 預設風扇 |
| Level | 錨點/邊界溫度 | 預設風扇 |
| --- | --- | --- |
| `idle` | `<65°C` | 25% |
| `low` | `65–69°C` | 30% |
| `medium` | `70–74°C` | 40% |
| `high` | `75–79°C` | 50% |
| `idle` | `<65°C` | 30% |
| `low` | `65°C` | 30% |
| `medium` | `70°C` | 40% |
| `high` | `75°C` | 50% |
| `critical` | `>=80°C` | 60% |
| `failsafe` | 所有來源失敗 | 70% |

降檔會等待 `HYSTERESIS` 度,避免溫度在閾值附近來回跳速;升檔不延遲。每個來源自行調整讀值:本機與遠端 GPU 分別扣除各自 offset,Linux 磁碟扣除 `LINUX_DISK_TEMP_OFFSET`,最低都不會小於 0°C。
`FAN_SPEED_INTERPOLATION=true` 預設開啟;舊設定檔未加入此選項時也會啟用。控制器以 `(TEMP_LOW, FAN_SPEED_LOW)`、`(TEMP_MEDIUM, FAN_SPEED_MEDIUM)`、`(TEMP_HIGH, FAN_SPEED_HIGH)`、`(TEMP_CRITICAL, FAN_SPEED_CRITICAL)` 為四個錨點做分段線性插值,duty **向上取整**為整數百分比。驗證後的曲線單調不減且介於 1–100%;低於 `TEMP_LOW` 使用 `FAN_SPEED_IDLE`,達到或超過 `TEMP_CRITICAL` 固定使用 `FAN_SPEED_CRITICAL`。沒有額外的 idle 溫度錨點:idle 與 low 速度不同時,`TEMP_LOW` 處會有刻意保留的跳差。

插值模式在升降溫時都不套用 `HYSTERESIS`,也不受前次 level 限制。每次成功收集後立即依目前需求決定速度,同一 level 內升溫也立即提高 duty;整數 duty 未變時不重送命令。不額外加入平滑、PID 或速率限制。例如閾值 `65/70/75/80`、速度 `30/35/45/60/65` 時,`70/71/72/73/74/75°C` 對應 `45/48/51/54/57/60%`。

設定 `FAN_SPEED_INTERPOLATION=false` 可恢復原本階梯模式:維持該檔速度直到下一閾值,僅降檔需等到溫度低於或等於「前一檔閾值減 `HYSTERESIS`」,升檔不延遲。TUI 的 **Fan curve** 可切換此選項;`config` 與唯讀 `diagnose` 會顯示模式及遲滯是否生效。

每個來源自行調整讀值:本機與遠端 GPU 分別扣除各自 offset,Linux 磁碟扣除 `LINUX_DISK_TEMP_OFFSET`,最低都不會小於 0°C。

## 設定參考

Expand Down Expand Up @@ -244,8 +253,9 @@ flowchart TD
| 變數 | 預設 | 說明 |
| --- | --- | --- |
| `TEMP_LOW/MEDIUM/HIGH/CRITICAL` | `65/70/75/80` | 嚴格遞增的°C threshold |
| `FAN_SPEED_IDLE/LOW/MEDIUM/HIGH/CRITICAL` | `25/30/40/50/60` | 1–100%,不可遞減 |
| `HYSTERESIS` | `2` | 降檔所需低於前 threshold 的°C |
| `FAN_SPEED_IDLE/LOW/MEDIUM/HIGH/CRITICAL` | `30/30/40/50/60` | 1–100%,不可遞減;idle 未設定時沿用 low |
| `FAN_SPEED_INTERPOLATION` | `true` | 分段線性插值並向上取整;`false` 恢復原本階梯模式 |
| `HYSTERESIS` | `2` | 僅階梯模式:降檔所需低於前 threshold 的°C |
| `FAILSAFE_ON_ERROR` | `true` | 所有來源失敗時使用保守速度 |
| `FAILSAFE_FAN_SPEED` | `70` | 必須 >= critical speed |
| `MANUAL_FAN_SPEED` | `35` | `manual` 未帶參數時使用 |
Expand Down Expand Up @@ -360,7 +370,7 @@ make validate-example # 不需要 .env 的 DRY_RUN smoke test
make docker-build
```

測試涵蓋統一 source 介面、Linux SMART 收集、多主機 remote GPU、source offset、SDR parsing、hysteresis、fail-safe、設定驗證、credential redaction、health freshness、診斷 preview,以及 TUI 設定檔安全 round-trip。真實硬體、SSH target、磁碟、iDRAC 與 GPU 仍須在管理網路上以 `diagnose` 驗證。
測試涵蓋統一 source 介面、Linux SMART 收集、多主機 remote GPU、source offset、SDR parsing、插值錨點/取整/邊界、原本降檔遲滯、控制循環狀態與 fail-safe 復原、設定驗證、credential redaction、health freshness、診斷 preview,以及 TUI 設定檔安全 round-trip。真實硬體、SSH target、磁碟、iDRAC 與 GPU 仍須在管理網路上以 `diagnose` 驗證。

## 專案結構

Expand Down
17 changes: 15 additions & 2 deletions USAGE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,26 @@ GPU_TEMP_OFFSET=15

同時確認 Compose 的 `gpus: all` 已啟用、主機有 NVIDIA Container Toolkit,再用 `diagnose` 驗證;GPU 失敗不應被悄悄當作 0°C。

### 降低閾值附近的跳速
### 線性插值與階梯模式

```dotenv
FAN_SPEED_INTERPOLATION=true
```

預設開啟,舊 `.env` 沒有此選項也會啟用。TUI 的 **Fan curve** 可切換,Compose 經由既有 `env_file: .env` 傳入;修改後需重建容器才會套用。`config` 與唯讀 `diagnose` 會顯示目前模式及遲滯是否生效。

插值以 `TEMP_LOW/MEDIUM/HIGH/CRITICAL` 及相對應的 `FAN_SPEED_LOW/MEDIUM/HIGH/CRITICAL` 為錨點,錨點間線性計算並向上取整為整數 duty。低於 `TEMP_LOW` 保留 `FAN_SPEED_IDLE`,達到/超過 `TEMP_CRITICAL` 固定為 critical speed;idle 與 low 不同時在 `TEMP_LOW` 會跳差,沒有另設 idle 溫度錨點。例如閾值 `65/70/75/80`、速度 `30/35/45/60/65` 時,`70/71/72/73/74/75°C` 對應 `45/48/51/54/57/60%`。

插值模式不使用 `HYSTERESIS`,不受前次 level 限制。每次收集後立即依需求升降速,同 level 內也會更新;整數 duty 相同時不重送命令。不加入額外平滑、PID 或速率限制。感測器最大值、offset、異常讀值過濾與 fail-safe 保護維持原有行為。

若要恢復原本階梯模式與降檔遲滯:

```dotenv
FAN_SPEED_INTERPOLATION=false
HYSTERESIS=3
```

Hysteresis 只延遲降檔,不延遲升檔。若溫度持續上升,critical 仍會立即生效。
此時每檔維持固定速度;Hysteresis 只延遲降檔,溫度降到前一檔閾值減 `HYSTERESIS`(含等號)就釋放。升檔不延遲,critical 仍會立即生效。

### 提高感測器失敗時的保護

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ services:
idrac-fan-control:
image: ghcr.io/df-wu/idrac-fan-control:latest
container_name: idrac-fan-control
# Fan options, including FAN_SPEED_INTERPOLATION=true by default, come
# from .env. Set it to false there for legacy steps and downshift hysteresis.
env_file:
- .env
volumes:
Expand Down
10 changes: 8 additions & 2 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ iDRAC Fan Control diagnostics (read-only)
[PASS] iDRAC/IPMI 2.60, PowerEdge R730xd
[PASS] source:idrac Inlet Temp=24C, Exhaust Temp=39C
[PASS] source:esxi t10.NVMe...=46C
[PASS] decision preview 46C -> idle (25%), no command sent
[PASS] decision preview 46C -> idle (30%), no command sent

Result: PASS - controller dependencies are ready.
```
Expand Down Expand Up @@ -201,4 +201,10 @@ docker inspect idrac-fan-control --format '{{json .Mounts}}'

請勿附上 `.env`、密碼、SSH private key、公開可達的管理 IP 或完整 service tag。

文件最後檢視:2026-08-15。
## 插值模式與預期速度不同

`FAN_SPEED_INTERPOLATION` 預設為 `true`,包括未設定此選項的舊 `.env`。先用 `config` 確認模式與四個錨點,再用唯讀 `diagnose` 檢查目前最高有效調整溫度對應的 duty;插值會向上取整,並忽略 `HYSTERESIS`。同一 level 中的 duty 也可能不同,日誌 level 僅表示溫度區間。

低於 `TEMP_LOW` 仍使用 idle,達到 `TEMP_LOW` 使用 low;兩者不同時會跳差,不會在兩者間另造溫度錨點。達到/超過 critical 固定使用 critical speed。若要保留舊階梯行為與只延遲降檔的遲滯,設 `FAN_SPEED_INTERPOLATION=false`,並在更新 `.env` 後重建容器。TUI 的 **Fan curve** 也可切換。診斷不會送出風扇控制命令。

文件最後檢視:2026-11-01。
Loading
Loading