Monitor Linux performance using sysstat tool
- Monitor Linux performance using sysstat tool
Sysstat is a robust logging and performance monitoring utility for Linux/Unix systems. It can be used to keep track of system performance and usage activity.
Sysstat saves the statistics collected in a file that can be exported into various formats such as JSON, CSV, etc. Though many Linux distributions include GUI-based monitoring apps, sysstat is especially useful in a server setting.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system Monitoring queries.
In this context, we shall look into how to use the sysstat tool to collect key system information on Linux.
For further information on Systat, check out the Sysstat Documentation http://sebastien.godard.pagesperso-orange.fr/documentation.html.
The Sysstat package is available in the default package repositories and may be installed with the commands below:
$ sudo apt install sysstat
The sysstat suite comprises various tools that help collect information on CPU and I/O statistics. Here, we will discuss how to use the tools to get system information. These tools include:
Sars is used to collect system statistics such as CPU utilization, memory among others. View your CPU utilization statistics for the day. Sar monitors data every 10 minutes by default:
$ sar -u
To display real-time CPU utilization for a set period of time, specify the intervals in seconds followed by the number of entries to report. For instance, to view total CPU utilization every 3 seconds for a total of 15 times run:
$ sar -u 3 15
Currently, the majority of PCs have several cores. To display the statistics of each core use the sars command followed by the "-P ALL" parameter as shown below:
$ sar -P ALL 1 1
This will display the system's four cores with the same time interval and output parameters applied.
To display the amount of memory in use at a particular time use the -r option:
$ sar -r
Use the iostat command to display a device report showing current data transfer per second (tps), average block rate, and data read and write statistics. Run the following command:
$ iostat -d
The columns in the output represent:
To view extended I/O statistics run:
$ iostat -x
The pidstat command is used to keep track of each individual task managed by the kernel. To get information about the running processes, run the pidstat command followed by -d parameter:
$ pidstat -d
You can also pidstat with the -r option to analyze memory usage with particular processes:
$ pidstat -r
This article covers how to install Linux Sysstat Utilities For Monitoring System Performance. In fact, Sysstat is a powerful monitoring tool for Linux environments.
Basically, Sysstat is actually a collection of utilities designed to collect information about the performance of a Linux installation and record them over time.
Main features of Sysstat:
Different methods of installing Sysstat on any Linux distribution ?
1. Install from RHEL/Fedora/CentOS
$ sudo yum install sysstat
CentOS and Fedora systems call the collector process using a cron job in /etc/cron.d and it's enabled by default. On recent versions, systemd is used instead of cron. You may need to enable and start the sysstat service:
$ sudo systemctl enable sysstat
$ sudo systemctl start sysstat
2. Install from Ubuntu
$ sudo apt-get install sysstat
Then enable data collecting:
$ sudo vi /etc/default/sysstat
change ENABLED="false" to ENABLED="true"
save the file
Last, restart the sysstat service:
$ sudo service sysstat restart
3. Install Sysstat from sources
Clone sysstat public repository with:
$ git clone git://github.com/sysstat/sysstat
Then configure sysstat for your system:
$ cd sysstat
You can set several variables and parameters on the command line. For example you can enter the following option to activate data collecting (either using cron or systemd):
$ ./configure --enable-install-cron
Enter ./configure --help to display all possible options.
Finally, Compile and install:
$ sudo make install