Me personally i don't use sensors for this because it is more cpu heavy then getting the numbers from a file.
Your fanspeeds are stored in /sys/class/hwmon/hwmonX/fanX_input (were X are numbers).
With the
cat
command you can get the rpm out of that file and it almost takes no cpu to do! But because these folders sometimes switch it is best to run my script at every boot.If you run this script (best at every boot via /etc/rc.local) then you have all the hwmon folders and names stored in /etc/hwmon.
Now you know which folder belongs to which HardWareMONitoring device (name).
Code: Select all
#!/bin/bash
###########################################################
# #
# Checks which hwmon path belongs to which chipset name #
# #
# Run at boot via rc.local #
# #
###########################################################
hwmonfile="/etc/hwmon"
sudo rm -f "$hwmonfile"
arr=$(ls /sys/class/hwmon)
for hwmon in ${arr[@]}
do
path="/sys/class/hwmon/$hwmon"
name=$(cat $path/name)
# if name = nvme then find out which nvme it is!
if [ "$name" = "nvme" ]; then
name=$(find $path/device/ -maxdepth 1 -printf "%f\n" | grep nvme)
name=${name:0:5}
fi
if [ "$1" = "silent" ]; then
echo "$name $path" | sudo tee -a "$hwmonfile" > /dev/null
else
printf "SYSFS HWMON: "
echo "$name $path" | sudo tee -a "$hwmonfile"
fi
done
Code: Select all
acpitz /sys/class/hwmon/hwmon0
nvme0 /sys/class/hwmon/hwmon1
amdgpu /sys/class/hwmon/hwmon2
coretemp /sys/class/hwmon/hwmon3
nct6687 /sys/class/hwmon/hwmon4
Code: Select all
${exec echo $(cat $(cat /etc/hwmon | grep nct6687 | awk '{print $2}')/temp1_input)/1000 | bc}
Fan speed example
Code: Select all
${exec echo $(cat $(cat /etc/hwmon | grep nct6687 | awk '{print $2}')/fan1_input)}