PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

Check CPU usage in Linux with XFreq

Updated - January 3, 2018 by Arnab Satapathi

XFreq is an awesome tool to check CPU usage in Linux for Intel CPUs, offers both CLI and GUI interface, xfreq-gui and xfreq-cli respectively.

This is exclusively for Intel CPU's, covers current Intel 6th generation Skylake CPU series as well as old Core 2 series. The GUI shows different widgets, covering various CPU related information like CPU frequency, CPU load, temperature, Turbo Boost and others.

The XFreq follows a client-server model to check CPU usage in Linux/UNIX, first start the XFreq server as root then check CPU usage with the previous tools as normal user.

Contents

  • Install XFreq in GNU/Linux
  • XFreq, check CPU usage in Linux
  • Credits and conclusion

Install XFreq in GNU/Linux

Though this software is around us since January of 2014, but not available in the software repository of any GNU/Linux distribution, so we have to compile it from source.

I'm using Debian Testing for compilation, the procedure is exactly same for any other Debian based distros like Ubuntu, Linux Mint. For other distros, just modify the package install commands.

1 . Install necessary softwares to compile XFreq,

sudo apt-get install git build-essential libc6-dev libx11-dev

2 . Get the latest source code from this github repo

cd ~/
git clone https://github.com/cyring/xfreq.git

3 . Compile XFreq

cd xfreq/
make -j2

That's all building complete, there is no default install rule, till now, you can install it wherever you like, I'm copying the binaries to /usr/local/bin/ for easier access.

cd ~/xfreq

sudo cp svr/bin/xfreq-intel /usr/local/bin/
sudo cp gui/bin/xfreq-gui /usr/local/bin/
sudo cp cli/bin/xfreq-cli /usr/local/bin/

You could also strip the binaries to make them smaller in size.

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.
sudo strip -s /usr/local/bin/xfreq-*

XFreq, check CPU usage in Linux

First load some kernel modules, so the server part could collect the necessary data,

sudo modprobe msr
sudo modprobe dmi-sysfs       # optional

XFreq-intel is the server part, before starting the server, let's have a look at few available server configuration options.

  1. -h      Print the help messages
  2. -A     Print out the built-in CPU architectures
  3. -c      Pick up an architecture, an integer, from the previous command.
  4. -B     Enable SmBIOS , 1 enable, 0 disable
  5. -S     Set clock source, look at the -S option in help meaasge

Just starting the server may show incorrect results, I've to use those extra options too, look at the command bellow.

sudo xfreq-intel -S 1 -B 1 -c 26

Open up another terminal window/tab and run the xfreq-cli or xfreq-gui application, this time no root privilege required

xfreq-gui

A screenshot bellow, click to zoomcheck cpu usage linux xfreq

Now the CLI part, nothing fancy here, just start the server with proper options as root and run xfreq-cli in another terminal tab. This should look like bellow.

Average C-states
Turbo     C0      C1      C3      C6      C7
40.90%   5.44%   6.34%   0.16    0.00%  88.05%

CPU#  F=1333.00 x R  Temp     IPS   IPC      CPI       Task scheduling
  0   696.40    0.52   42     0.00  0.06   17.25                (    0)
  1   187.64    0.14   42     0.01  0.33    3.00                (    0)
  2   374.17    0.28   47     0.00  0.05   18.21                (    0)
  3  1418.57    1.06   47     0.01  0.10    9.86                (    0)

Credits and conclusion

Special thanks to the developer,

  1. http://blog.cyring.free.fr/
  2. https://github.com/cyring/xfreq

XFreq also runs on FreeBSD, and I'll say it's a great tool as CPU usage monitor and also to know various CPU related info, extremely helpful for beginners, the downside is XFreq supports only Intel CPUs.

Do you have any question or suggestion ? Just drop a comment, I'll be happy to talk about it.

Filed Under: how to, linux basics Tagged With: CPU, microcode

Your comments
  1. ector62 says

    November 5, 2016

    I apologize, but I was referring to
    /etc/mikincipio.conf
    you know if you should be loaded modules mikincipio.conf?

    Reply
    • Arnab says

      November 5, 2016

      If you need to load the modules automatically during boot, add them under /etc/modprobe.d/ with a .conf file, no need to add them on /etc/mkinitcpio.conf , as they don't needed to be loaded by the initrd.
      Have a great day 🙂 !

      Reply
  2. ector62 says

    November 5, 2016

    I was wondering if you were put in / etc / default / grub
    then just give modprobe
    thanks again for the quick response
    good day

    Reply
  3. ector62 says

    November 5, 2016

    good morning
    I use arch linux but I must add:
    msr
    dmi-sysfs
    in / etc / default / grub
    or you just give modprobe?
    thank for the info

    Reply
    • Arnab says

      November 5, 2016

      Hi Ector, thanks again !
      But exactly where you're using msr and dmi-sysfs in /etc/default/grub ? And why they're necessary ?
      I'm loading those kernel modules with modprobe, no problem at all !
      The developer is also running Archlinux (most probably), you can contact with him with the Google+ link provided above.

      Reply
  4. ector62 says

    November 4, 2016

    thank for the article and big thank at delopever,He did a great job.
    best regards
    ector

    Reply
    • Arnab says

      November 4, 2016

      Thanks for the feedback !

      Reply
  5. CyrIng says

    June 12, 2016

    Thank you for your article.

    It’s the first time, I can see XFreq running with a SandyBridge. What a great surprise to see c7 states in action !
    I have also noticed that your BCLK was badly estimated, 1333MHz sounds wrong, beside oc
    I would recommend to click TSC in GUI or start server with it. I suspect that BIOS FSB freq was badly read by XFreq.
    Sandy Base Clock should be 100MHz

    Without any users interested in, I gave up XFreq for CoreFreq

    https://github.com/cyring/CoreFreq

    CoreFreq is a Linux device driver which targets precision and low CPU overhead.
    Still experimental, no GUI, it has no dependency with the msr.ko Linux module.

    Let me know how I can improve the software .

    Regards

    Reply
    • Arnab says

      June 12, 2016

      Hi and it’s awesome to hear from the XFreq developer.

      When I switch to clock source to TSC or any other sources except BIOS, CPU core frequencies are heavily messed up, 20~60 MHz !!!! and the base clock is around 99.79 MHz, and 100 MHz whiile using SPEC or ROM as source. Yeah, the FSB frequency is 1333 MHz.

      Surely I’ll try CoreFreq as soon as possible, and will write up here.

      And how can I send you some feedback ? through mail ?

      Reply
      • CyrIng says

        June 12, 2016

        Yes, feel free to use the email supplied in comment .
        Also, you would better contact me through G+
        https://plus.google.com/116215143685999462002

        Btw, 99-100 MHz looks OK,
        which multiplied by a 29 ratio results to an operational frequency of 2,9 GHz

        If your cores run low freq < 60 MHz, perhaps they are doing anything? Thus, give some load to the system, such as 7zip benchmark, or p5burn, mmxburn, etc
        You may see Turbo in action when 1 or few cores are "stressed"

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap