Categories: All

cpustat – A Lightweight Process Stats Tool For Small Ubuntu Devices


cpustat is a lightweight tool for monitoring per-process cpu utilization (from /proc/$pid/stat) in a fast and efficient way with minimal overhead. It is ideal for small Ubuntu devices and now available in Ubuntu 15.10 Wily Werewolf.

Colin Ian King, an open source developer, has released a lightweight cpu stats monitoring tool called cpustats which he claims to be the most compact and efficient tool till date. Monitoring CPU per process is the everyday job of any devOps engineer or developer who is obsessed with the performance of his code.
There are plenty of tools such as “top” and “atop” that can show per-process CPU utilisation stats, but most of these aren’t useful on really slow low-power devices as they consume several tens of megacycles collecting and displaying the results.
cpustat, on the other hand, periodically dumps out the current CPU utilisation statistics of running processes and it has been optimised to have a minimal CPU overhead and typically uses about 35% of the CPU compared to “top”. cpustat also includes some simple statistical analysis options that can help characterise the way CPUs are being loaded.
Also read: Vifm – A Simple and Powerful Text Based File Manager for GNU/Linux
According to Colin Ian King
I developed cpustat to be compact and efficient, as well as provide enough stats to allow me to easily identify CPU sucking processes.   To optimise the code, I used tools such as perf to identify code hotspots as well as valgrind’scachegrind to identify poorly designed cache inefficient data structures.
He used fscanf() style parsing for /proc and hand-crafted numeric and string scanning parsing that saved several hundred thousand cycles per iteration. He also tweaked the hash table sizes to match the input data more appropriately and by careful re-use of heap allocations, he was able to reduce malloc()/free() calls and save some heap management overhead.
Some very frequent string lookups were replaced with hash lookups and frequently accessed data was duplicated rather than referenced indirectly to keep data local to reduce cache stalls and hence speed up data comparison lookup time.

How to build and use cpustat –

Step-1: git clone git://kernel.ubuntu.com/cking/cpustat.git.
Step-2: Go to cpustat folder and run – make and sudo make install.
Step -3: Now run cpustat. Use the manual for command line options:
Did you like this story? Tell your views in comments below.


spatsariya

Recent Posts

Snapchat Outage Sparks Fears of Internet Dependency as AWS DNS Error Disrupts Global Services

Snapchat users woke to a digital nightmare this morning as thousands reported being locked out…

50 minutes ago

Massive AWS Outage Exposes Dangerous Flaws in Cloud Computing

On Monday morning, October 20, 2025, millions worldwide found themselves locked out of essential digital…

2 hours ago

Inside the Platform’s Entrepreneurial Transformation

YouTube has evolved into an economic juggernaut that dominates the digital landscape. With 2.7 billion…

3 hours ago

PlayStation’s October Lineup is a Tale of Quantity over Curation

PlaySation dropped 25 games in one week in their latest October 25’ lineup, but most…

5 hours ago

5 Best Bitcoin Cloud Mining Sites in 2025 for Safe BTC Mining

Bitcoin mining continues to attract global attention as profitability improves and hardware costs rise. Cloud…

5 hours ago

Comcast’s Silence on Outage Exposes the Cost of Connectivity Without Competition

Comcast Xinfinity ran into a massive outage on October 19th, knocking out internet and TV services…

5 hours ago