Last active
November 16, 2025 11:53
-
-
Save lambdan/214b3c9ba90fb6c0cb267459799771ba to your computer and use it in GitHub Desktop.
CPU/AIO/Nvidia temperature monitoring script on Arch Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # requires bc, lm-sensors, nvidia-smi | |
| CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | uniq | sed 's/model name[[:space:]]*:[[:space:]]*//') | |
| SENSORS_OUTPUT="" | |
| # Helper functions for min/max tracking | |
| declare -A MIN_VALUES | |
| declare -A MAX_VALUES | |
| function update_min_max { | |
| # $1: key, $2: value | |
| local key="$1" | |
| local val="$2" | |
| if [[ -z "${MIN_VALUES[$key]}" || $(echo "$val < ${MIN_VALUES[$key]}" | bc -l) -eq 1 ]]; then | |
| MIN_VALUES[$key]="$val" | |
| fi | |
| if [[ -z "${MAX_VALUES[$key]}" || $(echo "$val > ${MAX_VALUES[$key]}" | bc -l) -eq 1 ]]; then | |
| MAX_VALUES[$key]="$val" | |
| fi | |
| } | |
| function print_min_max { | |
| # $1: key, $2: unit | |
| echo "(min: ${MIN_VALUES[$1]}$2, max: ${MAX_VALUES[$1]}$2)" | |
| } | |
| function cpu_temp { | |
| VAL=$(echo "$SENSORS_OUTPUT" | grep -e Tccd1 | awk '{print $2}' | sed 's/+//;s/°C//') | |
| update_min_max "cpu_temp" "$VAL" | |
| echo "$CPU_MODEL" | |
| echo -n " temperature: $VAL°C " | |
| print_min_max "cpu_temp" "°C" | |
| } | |
| function gpu_temp { | |
| POWER_LIMIT=$(nvidia-smi --query-gpu=power.limit --format=csv,noheader,nounits | head -n1) | |
| while IFS=, read -r name temp power; do | |
| temp=${temp//[!0-9]/} | |
| power=$(echo "$power" | sed 's/ W//') | |
| update_min_max "gpu_temp" "$temp" | |
| update_min_max "gpu_power" "$power" | |
| echo "$name" | |
| echo -n " temperature: $temp °C " | |
| print_min_max "gpu_temp" " °C" | |
| echo -n " power: $power W " | |
| echo "$(print_min_max "gpu_power" " W") (limit: $POWER_LIMIT W)" | |
| done < <(nvidia-smi --query-gpu=name,temperature.gpu,power.draw --format=csv,noheader) | |
| } | |
| function aio_temps { | |
| COOLANT=$(echo "$SENSORS_OUTPUT" | grep -e "Coolant temp" | awk '{print $3}' | sed 's/+//;s/°C//') | |
| PUMP=$(echo "$SENSORS_OUTPUT" | grep -e "Pump speed" | awk '{print $3}' | sed 's/+//;s/°C//') | |
| FAN=$(echo "$SENSORS_OUTPUT" | grep -e "Fan speed" | awk '{print $3}' | sed 's/+//;s/ RPM//') | |
| if [[ "$COOLANT" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then | |
| update_min_max "liquid_temp" "$COOLANT" | |
| fi | |
| if [[ "$PUMP" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then | |
| update_min_max "pump_speed" "$PUMP" | |
| fi | |
| if [[ "$FAN" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then | |
| update_min_max "fan_speed" "$FAN" | |
| fi | |
| echo "AIO" | |
| echo -n " liquid temperature: $COOLANT °C " | |
| print_min_max "liquid_temp" " °C" | |
| echo -n " pump speed: $PUMP RPM " | |
| print_min_max "pump_speed" " RPM" | |
| echo -n " fan speed: $FAN RPM " | |
| print_min_max "fan_speed" " RPM" | |
| } | |
| while true | |
| do | |
| clear | |
| SENSORS_OUTPUT=$(sensors) | |
| cpu_temp | |
| echo "" | |
| aio_temps | |
| echo "" | |
| gpu_temp | |
| sleep 1 | |
| done |
Author
lambdan
commented
Nov 16, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment