Sysstat is a powerful Linux system performance monitoring tool written in C language. This is the best tool I found for the debugging the performance issue on your Linux systems. Sysstat is an opensource and freely available tool. This tutorial will help you to install Sysstat package on your system and monitor Linux system performance.
The sysstat package provides a number of utilities for collecting the system use activities and system performance.
- iostat – Used for CPU statistics and input/output statistics for the block devices and partitions and generate report.
- mpstat – Used for processor related statistics and reports.
- pidstat – Used for I/O, CPU, memory statistics for Linux processes and generate report.
- tapestat – Used for the statistics for tape drives attached to Linux system.
- cifsiostat – Used for generating reports CIFS statistics.
- sar – Used for collects and saves all the system activities and report.
Install Sysstat on Linux
You can opt one of the below method to install Sysstat on your system. The package manager may have older version, so you can try with the source installation.
1. Install with Package Manager
Sysstat package is available in default package repositories, You can install using the following commands. But the default repositories have older version of packages. So we recommend to use installation with source in next step. If you still want to use package manager just run below commands.
sudo yum install sysstat ## CentOS and RHEL systems sudo dnf install sysstat ## Fedora 22+ systems sudo apt install sysstat ## Ubuntu and Debian based systems
Let’s enable the sysstat monitoring. Edit the following file and set
ENABLED="true" and save it.
sudo vim /etc/default/sysstat
After that enable the service and start it.
sudo systemctl enable sysstat sudo systemctl start sysstat
2. Install from Source
Download the latest stable version from its official website. I always recommend to use stable version on production servers. For development systems you can try with current development version.
Here are the commands to download current stable release 11.6.2 and install on your system.
wget http://pagesperso-orange.fr/sebastien.godard/sysstat-12.3.2.tar.gz tar -zxf sysstat-12.3.2.tar.gz cd sysstat-12.3.2/ ./configure make make install
Using this method all the binary files are installed under /usr/local/bin directory and the library files are installed under /usr/local/lib directory. Now edit sysstat configuration file and adjust settings.
ENABLED="true" in above file and save it.
View Current CPU Usage
Use sar command with
-u option to view CPU statics of current date.
You can also view the real-time CPU uses by specifying the time interval and number of times to show data. For example, to view real-time CPU uses for 5 times with the difference of 1 second.
sar -u 1 5
You can view the CPU utilization data in more depth. Nowadays most of the CPU’s are multi-core. To view utilization details of each core individually use
-P ALL command.
sar -P ALL 1 3
View Device Usage
Use the iostat command to find disk statics. It shows the current data transfer per second, the total number of blocks read and write to disk and an average block per seconds.
iostat -d 1 5
- tps – Transfers per second.
- Blk_read/s – Total amount of data read in blocks per second.
- Blk_wrtn/s – Total amount of data written in blocks per second.
- Blk_read – Total blocks read.
- Blk_wrtn – Total blocks written.
You can view more extended I/O statics of disk using the following command.
iostat -x 1 5
View Running Process Resource Utilization
Using pidstat command with switch
-d provides you details of currently running processes on systems.
Also try pidstat with -r to show resource utilization by processes on every 1 second for the 5 times.
pidstat -r 1 5
Memory Utilization Data
Use sar command with
-r to view the current memory utilization details for the 5 times on every 1 second.
sar -r 1 5
Thank you so much. useful information!
Many thanks for this useful explanation, I admit I didn’t use systat and now it will be among my favorite commands.