Sysstat is a powerful logging and monitoring tool for Linux/Unix systems. It can be used to monitor system performance and troubleshoot problems. Though many distros have GUI based monitoring applications and API’s, sysstat is a go-to for power users and can log and track pretty much everything going on within your Linux box.
To install sysstat on a RedHat based variant using yum:
To install on a Debian based variant using apt:
If you are using a Ubuntu-based distro, you should be able to find sysstat in the software manager.
After the installation, you will need to edit the configuration file to run the daemon.
In the terminal:
and set the “sadc” variable to true by changing the line to
Save and close the file. Finally, start the daemon:
Common usage of Sysstat
The sysstat suite is obviously a collection of very extensive and detailed application. Here are some basic ways to use the tools in order to gain a feel for its troubleshooting guidance.
Check CPU usage
To check CPU usage stats for the current day (by default sar tracks the data every 10 minutes):
To display real-time CPU usage for a given amount of time, you can specify the intervals in seconds followed by how many entries you want to report. For example: the following will report total CPU usage every 2 seconds for a total of 10 times:
Most PCs have multiple cores nowadays. To view the activity of each specific core use the “
-P ALL” flag. The following shows a real-time snapshot of the 4 cores in my PC (same intervals and output parameters apply, below is 1 second 1 time):
Want to see how much memory is currently being used? Use
sar -r as follows to show real-time memory usage every 2 seconds for 10 times:
Display device report
To display a device report showing transfers per second (tps) and data read and write stats, showing data in real-time every 2 seconds, for 10 reports, type:
- tps = transfers per second
- Blk_read/s = amount of data read in blocks per second
- Blk_wrtn/s = amount of data written in blocks per second
- Blk_read = total blocks read
- Blk_wrtn = total blocks written
For extended I/O stats:
Get information regarding running process
pidstat to report information regarding running process. The
-d flag will list all processes on the machine:
To see real-time results of running processes, you can use the following, where like the above examples, the first number is the second interval and the second number is how many times to report:
Another useful command is to use
pidstat with the
-r flag to analyze memory usage with particular processes:
Sysstat is a very powerful monitoring tool for Linux and it is particularly useful in a server environment where there is no GUI available. The above mentioned only touch the surface of what sysstat is capable. If you have used sysstat in your PC/server, feel free to share with us the various ways you use it to monitor your system performance.
Our latest tutorials delivered straight to your inbox