# cpu-stat **Repository Path**: mirrors_GerHobbelt/cpu-stat ## Basic Information - **Project Name**: cpu-stat - **Description**: A command line program to get CPU usage statistics on Linux systems. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-11-01 - **Last Updated**: 2026-06-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cpu-stat A command line program to get CPU usage statistics on Linux systems. ![cpu-stat](https://github.com/vivaladav/cpu-stat/blob/master/data/imgs/CPU-STAT-logo-256.png?raw=true) I created cpu-stat to have a quick and simple answer to the question "what's the CPU usage of my system right now?" and that's what you get when you run the program with no options. The intended use is for scripts or system monitoring tools which do not want to parse */proc/stat* directly to get CPU usage stats. For people interested in understanding more about how things work under the hood, I wrote a [tutorial](http://blog.davidecoppola.com/2016/12/cpp-program-to-get-cpu-usage-from-command-line-in-linux/) describing a much simpler version of this program and providing more information on the different CPU states. NOTE: cpu-stat requires Linux kernel 2.6.33 or newer. ## Installation To build cpu-stat you will need [SCons](http://scons.org/). **simple build** This will build cpu-stat in debug mode. Executable file will be in *bin/debug*. `scons` **build in release mode** This will build cpu-stat in release mode. Executable file will be in *bin/release*. `scons mode=release` **install release build** This will install cpu-stat in */usr/bin/*. `sudo scons mode=release install` **clean release build** This will remove all files generated by a release build. `sudo scons mode=release -c install` You can omit *install* at the end to remove only build files and keep the installed executable. ## Usage **Print options** | flag | description | default | | ---- | ------------| ------- | | -a \| --all | print active time percentage for all CPUs, starting with total | false | | -c \ | print stats only for selected CPU. | - | | -f \| --full-state | print time percentage of all states | false | | -p \ | set the decimal precision of printed numbers | 2 | | -s \ | print time percentage for specific state [0-9] | - | | -v \| --verbose | enable verbose mode | false | **Other options** | flag | description | default | | ---- | ------------| ------- | | -d \ | set delay time (in ms) between 2 snapshots of CPU data | 100 | | -h \| --help | print help | - | | --version | print the version number | - | ## Examples Print percentage of active time for total CPU: ``` $ cpu-stat 2.50 ``` Print percentage of active time for all CPUs in verbose mode (with labels): ``` $ cpu-stat -a -v tot] 5.00% 0] 0.00% 1] 0.00% 2] 20.00% 3] 0.00% ``` Print percentage of idle time (state 3) for CPU 2 using 4 digits as decimal precision: ``` $ cpu-stat -s 3 -c 2 -p 4 100.0000 ``` Print percentage of all states for all CPUs in verbose mode (with labels): ``` $ cpu-stat -a -v -f tot] usr: 0.00% | sys: 0.00% | nic: 0.00% | idl: 100.00% | iow: 0.00% | hir: 0.00% | sir: 0.00% | ste: 0.00% | gue: 0.00% | gun: 0.00% | 0] usr: 0.00% | sys: 0.00% | nic: 0.00% | idl: 100.00% | iow: 0.00% | hir: 0.00% | sir: 0.00% | ste: 0.00% | gue: 0.00% | gun: 0.00% | 1] usr: 0.00% | sys: 0.00% | nic: 0.00% | idl: 100.00% | iow: 0.00% | hir: 0.00% | sir: 0.00% | ste: 0.00% | gue: 0.00% | gun: 0.00% | 2] usr: 0.00% | sys: 0.00% | nic: 0.00% | idl: 100.00% | iow: 0.00% | hir: 0.00% | sir: 0.00% | ste: 0.00% | gue: 0.00% | gun: 0.00% | 3] usr: 0.00% | sys: 0.00% | nic: 0.00% | idl: 90.91% | iow: 9.09% | hir: 0.00% | sir: 0.00% | ste: 0.00% | gue: 0.00% | gun: 0.00% | ``` ## Contribute If you want to contribute to cpu-stat check out this guide about [how to contribute to an open source project on GitHub](http://blog.davidecoppola.com/2016/11/howto-contribute-to-open-source-project-on-github/) first.