Recently I received an email from someone who had read my previous article "lm-sensors, conky and AMD temperatures".  I though it might be helpful to pass along the question and my answer.

Hi, man. I want to test this script: https://theleftcoastgeek.net/index.php/general/5-lm-sensors-conky-and-amd-temperatures?showall=&start=1, but it returns:

<redacted>:~/mate-launchers$ dash sensors-correct.sh
Specified sensor(s) not found!
sensors-correct.sh: 86: [: -le: unexpected operator
sensors-correct.sh: 91: [: -ge: unexpected operator
sensors-correct.sh: 98: sensors-correct.sh: arithmetic expression: expecting primary: " (1200 - ) "

What would be the fix?



I provided the following answer:


My first two suspicions would be:

1. You do not have an AMD processor that uses the k10temp module. That was valid through the FX series CPUs, but it is not used in later CPUs.

2. You do not have the k10temp module loaded.

I am still running that script without error on the machine I wrote that for -- it runs an AMD FX 8350 -- which I now use as a server. My desktop currently runs a Threadripper 1950x and that script does not work because the k10temp sensor/module is no longer used. Since the sensor is not found, one of the variables is not provided with a value, so the math fails and I receive the same error message you are receiving.

Specifically, the lines

    # Get the CPU temp and HSF fan speed from sensors. This may take some fiddling
    # depending on your motherboard.
    cpu_temp=$(sensors k10temp-pci-00c3 | grep 'temp1' | awk -F'.' '{print $1}'| awk -F'+' '{print $2}')
    fanspeed=$(sensors it8728-isa-0228 | grep 'fan1' | awk '{print $2}' | cut -c1-4)

must be modified for your particular hardware as noted in the comments.

For my Threadripper, the CPU and fan sensors are on nct6779-isa-0290, but I can't say what yours might be. Nor can I say what you might have to capture with awk and how you might have to cut it.

For my desktop, the CPU temp does not have to be adjusted, as AMD uses a different reporting method now. So I get temp and fan speed in my conky without calling the correction script thus:

    sensors nct6779-isa-0290 | grep 'CPUTIN' | awk '{print $2}' | cut -c2-5

Again, depending on your hardware that may need to be modified.

Please remember that the blog article was written more than three years ago and hardware technology changes quickly.

Best wishes!



Legal Disclaimer:  I am not an Ubuntu apologist, but I do use Ubuntu and Kubuntu.  I am not a Fedora apologist, but I do use Fedora.  I am not a Windows apologist, but I do use Windows.  I'm not a FOSS apologist, but I use FOSS tools when I can and when they fit the job at hand.  I don't find any sense in a religious affiliation with tools and operating systems.  That's just asinine.