[download]

local/bin/temperature

   1 #!/bin/bash
   2 
   3 sensors=$(sensors)
   4 
   5 cpu_temp=$(awk '/CPUTIN/ { print int($2) }' <<< "$sensors")
   6 cpu_name=$(awk '/model name/ { print $6; exit }' /proc/cpuinfo)
   7 
   8 mbr_temp=$(awk '/SYSTIN/ { print int($2) }' <<< "$sensors")
   9 mbr_name=$(paste -d ' ' /sys/devices/virtual/dmi/id/board_{vendor,name})
  10 
  11 fans=($(awk '/fan/ { print $2, substr($1, 4, 1) }' <<< "$sensors"))
  12 IFS=', ' read gpu_temp gpu_name < <(nvidia-smi --query-gpu=temperature.gpu,name --format=csv,noheader)
  13 
  14 printf '%s\t%d°C\t%s\n'   \
  15 CPU $cpu_temp "$cpu_name" \
  16 GPU $gpu_temp "$gpu_name" \
  17 MBR $mbr_temp "$mbr_name" | awk 'int($2)'
  18 
  19 cd /sys/block && paste  <(cat sd?/queue/rotational) \
  20 <(hddtemp -qn /dev/sd?) <(cat sd?/device/model)     |
  21 awk 'BEGIN { FS = OFS = "\t" } int($2) { print ($1 ? "HDD" : "SSD"), $2 "°C", $3 }'
  22 
  23 printf 'FAN\t%d\t#%d\n' "${fans[@]}" | awk 'int($2)'