Skip to content

Instantly share code, notes, and snippets.

@Anexgohan
Created June 19, 2026 06:51
Show Gist options
  • Select an option

  • Save Anexgohan/b05d4a80e6a2c63e747ed2d60d62558b to your computer and use it in GitHub Desktop.

Select an option

Save Anexgohan/b05d4a80e6a2c63e747ed2d60d62558b to your computer and use it in GitHub Desktop.
read-only hardware/fan discovery for Pankha fan-control
#!/usr/bin/env bash
#
set -u
echo "=== Pankha fan diagnostic (read-only) ==="
echo "date : $(date -Is 2>/dev/null)"
echo "host : $(hostname 2>/dev/null)"
echo "kernel : $(uname -r 2>/dev/null)"
echo "cmdline : $(cat /proc/cmdline 2>/dev/null)"
echo
echo "--- Super I/O / it87 module ---"
if lsmod 2>/dev/null | grep -qi it87; then
lsmod 2>/dev/null | grep -i it87
modinfo it87 2>/dev/null | grep -E '^(filename|version|srcversion):' || true
else
echo "it87 NOT loaded (on ITE boards you may need: modprobe it87, often with"
echo " acpi_enforce_resources=lax or the driver's ignore_resource_conflict=1)"
fi
echo
echo "--- hwmon chips ---"
for h in /sys/class/hwmon/hwmon*; do
[ -e "$h" ] || continue
echo "$h -> $(cat "$h/name" 2>/dev/null)"
done
echo
echo "--- fan / pwm map ---"
echo "(pick a CHASSIS fan with rpm>0 and writable=yes for the control test)"
for h in /sys/class/hwmon/hwmon*; do
[ -e "$h" ] || continue
name=$(cat "$h/name" 2>/dev/null)
for f in "$h"/fan[0-9]*_input; do
[ -e "$f" ] || continue
n=$(basename "$f" | sed 's/fan//; s/_input//')
pp="$h/pwm${n}"
pe="$h/pwm${n}_enable"
printf ' %-12s %s fan%s: rpm=%-6s pwm=%-4s enable=%-3s writable=%s\n' \
"$name" "$h" "$n" \
"$(cat "$f" 2>/dev/null)" \
"$( [ -e "$pp" ] && cat "$pp" 2>/dev/null || echo - )" \
"$( [ -e "$pe" ] && cat "$pe" 2>/dev/null || echo - )" \
"$( [ -w "$pp" ] && echo yes || echo no )"
done
done
echo
echo "--- dmesg (it87 lines) ---"
dmesg 2>/dev/null | grep -i it87 | tail -n 20 || echo "(no it87 dmesg lines, or dmesg restricted)"
echo
echo "--- sensors ---"
if command -v sensors >/dev/null 2>&1; then
sensors 2>/dev/null
else
echo "(lm-sensors 'sensors' not installed)"
fi
echo
echo "=== done. Next: run pankha-pwm-test.sh on one chassis fan from the map above ==="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment