How to Monitor Your Linux Performance With Sysstat

Spread the love

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.

Installation

To install sysstat on a RedHat based variant using yum:

yum -y install sysstat

To install on a Debian based variant using apt:

apt-get install sysstat

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:

gksu gedit /etc/default/sysstat

and set the “sadc” variable to true by changing the line to ENABLED="true".

Save and close the file. Finally, start the daemon:

/etc/init.d/sysstat start

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):

sar -u

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:

sar -u 2 10

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):

sar -P ALL 1 1

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:

sar -r 2 10

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:

iostat -d 2 10

Note:

  • 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:

iostat -x 2 5

Get information regarding running process

Use pidstat to report information regarding running process. The -d flag will list all processes on the machine:

pidstat -d

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:

pidstat - d 2 5

Another useful command is to use pidstat with the -r flag to analyze memory usage with particular processes:

pidstat -r 2 5

Conclusion

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.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Chuck Romano

Chuck Romano is a business and technology professional with over 10 years experience in document imaging and 11 years in computer repair. Chuck provides results driven expertise in fields such as Healthcare IT, document imaging/workflow systems, marketing, and management. He is a Linux enthusiast and evangelist.

Comments (1)