You are not logged in.
Hi,
I just installed the Genmon on my Gentoo Linux system.
I am following the guide to show informations about CPU Frequency and Temperature.
I am trying to use the provided example script:
#!/bin/bash
echo "<img>/usr/share/icons/Bluecurve/16x16/apps/gnome-monitor.png</img>"
declare -i cpuFreq
cpuFreq=$(cat /proc/cpuinfo | grep "cpu MHz" | sed 's/\ \ */ /g' | cut -f3 -d" " | cut -f1 -d".")
if [ $cpuFreq -ge 1000 ]
then
cpu=$(echo $cpuFreq | cut -c1).$(echo $cpuFreq | cut -c2)GHz
else
cpu=${cpuFreq}MHz
fi
echo "<txt>"$(cat /proc/acpi/thermal_zone/THM/temperature | sed 's/\ \ */ /g' | cut -f2 -d" ")" C</txt>"
echo "<tool>Freq: "$cpu"</tool>"
although modified a bit the url of the image, like this:
echo "<img>/usr/share/icons/Tango/16x16/apps/gnome-monitor.png</img>"
After I set the genmon plugin in the panel, it shows only this: 'CPU [the image of gnome-monitor.png]C'.
If I run the script in the commandline I get error messages:
<img>/usr/share/icons/Tango/16x16/apps/gnome-monitor.png</img>
/home/pali/Irataim/Programozas/Bash/xfce4_genmon_plugin_CPU_FreqTerm: line 4: 1197
1197
1197
1197: syntax error in expression (error token is "1197
1197
1197")
/home/pali/Irataim/Programozas/Bash/xfce4_genmon_plugin_CPU_FreqTerm: line 5: [: -ge: unary operator expected
<tool>Freq: MHz</tool>
cat: /proc/acpi/thermal_zone/THM/temperature: No such file or directory
<txt> C</txt>
If I run just a part of this script:
cat /proc/cpuinfo | grep "cpu MHz" | sed 's/\ \ */ /g' | cut -f3 -d" " | cut -f1 -d"."
I get this output:
1197
1197
1197
1197
so it seems to me that, that it could works on a singlecore CPU but not on multicore CPU, right?
It would be good enough if we could get the average of the CPU cores frequencies out there.
So here we could put some math to calculate the frequencies of cpu cores, right?
If I run the other part of the script:
cat /proc/acpi/thermal_zone/THM/temperature | sed 's/\ \ */ /g' | cut -f2 -d" "
I get this output:
cat: /proc/acpi/thermal_zone/THM/temperature: No such file or directory
The /proc/acpi/ directory is deprecated, says in the kernel menuconfig out here.
So which command should use instead to obtain the CPU temperature?
Best, Pál
Offline
Yes, this is an old script and only works with single core CPUs. Try this script instead (assumes that lscpu is installed and that system temperature is captured in /sys/class):
#!/bin/bash
CPU=$(lscpu | grep "CPU MHz" | awk '{print $3}' | cut -f1 -d.)
TEMP="N/A"
[[ $CPU == "" ]] && CPU="N/A"
if [ -f /sys/class/thermal/thermal_zone*/temp ]; then
TEMP=$(cat /sys/class/thermal/thermal_zone*/temp | awk '{print ($1 / 1000) "C" }')
fi
#echo $CPU
#echo $TEMP
# do the genmon
echo "<img>/usr/share/icons/Bluecurve/16x16/apps/gnome-monitor.png</img><txt>$CPU / $TEMP</txt><tool>CPU: $CPU
TEMP: $TEMP</tool>"
exit 0
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
It works, although I changed again the image url.
Now the plugin shows the frequency and the temperature.
Thank you very much!!
Offline
[ Generated in 0.006 seconds, 7 queries executed - Memory usage: 529.8 KiB (Peak: 531.09 KiB) ]