使用 Conky 显示每个核心的时钟频率

使用 Conky 显示每个核心的时钟频率

我正在使用 Conky 显示系统的大量信息。我设法显示了每个核心的负载百分比。但我不知道如何显示每个核心的时钟频率。我现在有的是:

${font sans-serif:bold:size=8}PROCESSORS ${hr 2}${font}
CPU1: ${cpu cpu1}% $alignr ${freq} MHz $alignr ${cpubar cpu1 8,60}
CPU2: ${cpu cpu2}% $alignr ${freq} MHz $alignr ${cpubar cpu2 8,60}
CPU3: ${cpu cpu3}% $alignr ${freq} MHz $alignr ${cpubar cpu3 8,60}
CPU4: ${cpu cpu4}% $alignr ${freq} MHz $alignr ${cpubar cpu4 8,60}
CPU5: ${cpu cpu5}% $alignr ${freq} MHz $alignr ${cpubar cpu5 8,60}
CPU6: ${cpu cpu6}% $alignr ${freq} MHz $alignr ${cpubar cpu6 8,60}
CPU7: ${cpu cpu7}% $alignr ${freq} MHz $alignr ${cpubar cpu7 8,60}
CPU8: ${cpu cpu8}% $alignr ${freq} MHz $alignr ${cpubar cpu8 8,60}

但这只给出了全局时钟频率,而不是每个核心的单独时钟频率。有人知道如何获取每个核心的单独时钟频率吗?

系统信息

  • Linux Mint 13 KDE,64 位(基于 Ubuntu 12.04)
  • Intel i7-2670QM(四核,多线程)

答案1

conky可以执行外部命令。所以/proc/cpuinfo有你需要的所有信息。见:

root@host:~$ cat /proc/cpuinfo | grep "cpu MHz"
cpu MHz         : 2667.000
cpu MHz         : 1998.000
cpu MHz         : 1998.000
cpu MHz         : 2667.000

我的情况是,有 4 个核心,其中两个是一个您可以使用以下工具找出您的 CPU 允许哪些步骤cpufreq-info

root@host:~$ cpufreq-info | grep "available frequency steps"
  available frequency steps: 2.67 GHz, 2.00 GHz
  available frequency steps: 2.67 GHz, 2.00 GHz
  available frequency steps: 2.67 GHz, 2.00 GHz
  available frequency steps: 2.67 GHz, 2.00 GHz

该包可以通过以下命令安装:

apt-get install cpufrequtils

有了这些信息,我会conky.conf像这样写

${font sans-serif:bold:size=8}PROCESSORS ${hr 2}${font}
CPU1: ${cpu cpu1}% $alignr ${exec awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu1 8,60}
CPU2: ${cpu cpu2}% $alignr ${exec awk '/cpu MHz/{i++}i==2{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu2 8,60}
CPU3: ${cpu cpu3}% $alignr ${exec awk '/cpu MHz/{i++}i==3{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu3 8,60}
CPU4: ${cpu cpu4}% $alignr ${exec awk '/cpu MHz/{i++}i==4{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu4 8,60}
CPU5: ${cpu cpu5}% $alignr ${exec awk '/cpu MHz/{i++}i==5{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu5 8,60}
CPU6: ${cpu cpu6}% $alignr ${exec awk '/cpu MHz/{i++}i==6{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu6 8,60}
CPU7: ${cpu cpu7}% $alignr ${exec awk '/cpu MHz/{i++}i==7{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu7 8,60}
CPU8: ${cpu cpu8}% $alignr ${exec awk '/cpu MHz/{i++}i==8{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu8 8,60}

就我而言,它是有效的,但我只有 4 个核心。

相关内容