Sysstat linux ��� ���

Sysstat linux ��� ���

sysstat — System performance tools for the Linux operating system

(C) 1999-2021 Sebastien GODARD (sysstat (at) orange (dot) fr)

The sysstat package contains various utilities, common to many commercial Unixes, to monitor system performance and usage activity:

  • iostat reports CPU statistics and input/output statistics for block devices and partitions.
  • mpstat reports individual or combined processor related statistics.
  • pidstat reports statistics for Linux tasks (processes) : I/O, CPU, memory, etc.
  • tapestat reports statistics for tape drives connected to the system.
  • cifsiostat reports CIFS statistics.

Sysstat also contains tools you can schedule via cron or systemd to collect and historize performance and activity data:

  • sar collects, reports and saves system activity information (see below a list of metrics collected by sar).
  • sadc is the system activity data collector, used as a backend for sar.
  • sa1 collects and stores binary data in the system activity daily data file. It is a front end to sadc designed to be run from cron or systemd.
  • sa2 writes a summarized daily activity report. It is a front end to sar designed to be run from cron or systemd.
  • sadf displays data collected by sar in multiple formats (CSV, XML, JSON, etc.) and can be used for data exchange with other programs. This command can also be used to draw graphs for the various activities collected by sar using SVG (Scalable Vector Graphics) format.

Default sampling interval is 10 minutes but this can be changed of course (it can be as small as 1 second).

System statistics collected by sar:

  • Input / Output and transfer rate statistics (global, per device, per partition and per network filesystem)
  • CPU statistics (global and per CPU), including support for virtualization architectures
  • Memory, hugepages and swap space utilization statistics
  • Virtual memory, paging and fault statistics
  • Process creation activity
  • Interrupt statistics (global, per CPU and per interrupt, including potential APIC interrupt sources, hardware and software interrupts)
  • Extensive network statistics: network interface activity (number of packets and kB received and transmitted per second, etc.) including failures from network devices; network traffic statistics for IP, TCP, ICMP and UDP protocols based on SNMPv2 standards; support for IPv6-related protocols
  • Fibre Channel traffic statistics
  • Software-based network processing (softnet) statistics
  • NFS server and client activity
  • Sockets statistics
  • Run queue and system load statistics
  • Kernel internal tables utilization statistics
  • Swapping statistics
  • TTY devices activity
  • Power management statistics (instantaneous and average CPU clock frequency, fans speed, devices temperature, voltage inputs)
  • USB devices plugged into the system
  • Filesystems utilization (inodes and blocks)
  • Pressure-Stall Information statistics

Sysstat key features:

  • Display average statistics values at the end of the reports.
  • On-the-fly detection of new devices (disks, network interfaces, etc.) that are created or registered dynamically.
  • Support for UP and SMP machines, including machines with hyperthreaded or multi-core processors.
  • Support for hotplug CPUs (it detects automagically processors that are disabled or enabled on the fly) and tickless CPUs.
  • Works on many different architectures, whether 32- or 64-bit.
  • Needs very little CPU time to run (written in C).
  • System statistics collected by sar/sadc can be saved in a file for future inspection. You can configure the length of data history to keep. There is no limit for this history length but the available space on your storage device.
  • System statistics collected by sar/sadc can be exported in various different formats (CSV, XML, JSON, SVG, etc.). DTD and XML Schema documents are included in sysstat package. JSON output format is also available for mpstat and iostat commands.
  • iostat can display statistics for devices managed by drivers in userspace like spdk.
  • Smart color output for easier statistics reading.
Читайте также:  Wps office локализация linux

  • Internationalization support (sysstat has been translated into numerous different languages). Sysstat is now part of the Translation Project.
  • Sysstat commands can automatically select the unit used to display sizes for easier reading (see option —human ):

  • Graphs can be generated (SVG format — Scalable Vector Graphics) and displayed in your favorite web browser. See some sample screenshots below:

Sysstat is Open Source / Free Software, and is freely available under the GNU General Public License, version 2. The latest version of sysstat can always be found on my web site at:

See the CHANGES file to know the new features/improvements/bug fixes added in this release of sysstat. Sysstat development can be tracked on GitHub.

Install from RHEL/Fedora/CentOS

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:

Install from Ubuntu

Then enable data collecting:

Last, restart the sysstat service:

Install from sources

Clone sysstat public repository with:

Then configure sysstat for your system:

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

Enter ./configure —help to display all possible options.
Note: There is another way to configure sysstat instead of entering ./configure : This is the Interactive Configuration script (iconfig) which will ask you for the value of the main sysstat variables and parameters. Enter ./iconfig then answer the questions or enter Return to accept the (sane) default values. For yes/no questions, answer ‘y’ or ‘n’ (without the quotes): It is case sensitive! You can also enter ‘?’ to get a help message that will explain the meaning of each variable or parameter.

Compile and install:

Please use the BUG_REPORT template file to report a bug: It contains important data that should be provided for this. Please also remember to read the FAQ that comes with sysstat or is available from the Wiki page on GitHub.

Opening an issue or a pull request on GitHub is the preferred way to report a bug or submit a patch. Patches and suggestions for improvements are always welcome!

If you are reading this README file then you are probably about to use the sysstat tools to help you monitor your system and maybe troubleshoot some performance issues. Good choice. Sysstat is made for you. Moreover sysstat is free software and always will be.

Читайте также:  Как удалить все файлы архивации windows

Yet have you ever considered making a donation to sysstat, regardless of how much your contribution is? This in turn would encourage me to keep up the work as good as it can be. Oh, and it would certainly also help me explain to my wife why I spend so much time in front of my computer instead of taking care of the household 😉

Click on the «Donate PayPal» button above at the beginning of this file. You can also make a donation from my web page.

Sebastien GODARD — sysstat (at) orange (dot) fr

Источник

20 Useful Commands of ‘Sysstat’ Utilities (mpstat, pidstat, iostat and sar) for Linux Performance Monitoring

In our last article, we have learned about installing and upgrading the sysstat package and understanding briefly about the utilities which comes with the package.

  1. Sysstat – Performance and Usage Activity Monitoring Tool For Linux

20 Sysstat Commands for Linux Monitoring

Today, we are going to work with some interesting practical examples of mpstat, pidstat, iostat and sar utilities, which can help us to identify the issues. We have different options to use these utilities, I mean you can fire the commands manually with different options for different kind of work or you can create your customized scripts according to your requirements. You know Sysadmins are always bit Lazy, and always tried to find out the easy way to do the things with minimum efforts.

mpstat – Processors Statistics

1. Using mpstat command without any option, will display the Global Average Activities by All CPUs.

2. Using mpstat with option ‘-P‘ (Indicate Processor Number) and ‘ALL’, will display statistics about all CPUs one by one starting from 0. 0 will the first one.

3. To display the statistics for N number of iterations after n seconds interval with average of each cpu use the following command.

4. The option ‘I‘ will print total number of interrupt statistics about per processor.

5. Get all the above information in one command i.e. equivalent to “-u -I ALL -p ALL“.

pidstat – Process and Kernel Threads Statistics

This is used for process monitoring and current threads, which are being managed by kernel. pidstat can also check the status about child processes and threads.

Syntax

6. Using pidstat command without any argument, will display all active tasks.

7. To print all active and non-active tasks use the option ‘-p‘ (processes).

8. Using pidstat command with ‘-d 2‘ option, we can get I/O statistics and 2 is interval in seconds to get refreshed statistics. This option can be handy in situation, where your system is undergoing heavy I/O and you want to get clues about the processes consuming high resources.

9. To know the cpu statistics along with all threads about the process id 4164 at interval of 2 sec for 3 times use the following command with option ‘-t‘ (display statistics of selected process).

10. Use the ‘-rh‘ option, to know the about memory utilization of processes which are frequently varying their utilization in 2 second interval.

11. To print all the process of containing string “VB“, use ‘-t‘ option to see threads as well.

Читайте также:  Астра линукс реального времени

12. To get realtime priority and scheduling information use option ‘-R‘ .

Here, I am not going to cover about Iostat utility, as we are already covered it. Please have a look on “Linux Performance Monitoring with Vmstat and Iostat” to get all details about iostat.

sar – System Activity Reporter

Using “sar” command, we can get the reports about whole system’s performance. This can help us to locate the system bottleneck and provide the help to find out the solutions to these annoying performance issues.

The Linux Kernel maintains some counter internally, which keeps track of all requests, their completion time and I/O block counts etc. From all these information, sar calculates rates and ratio of these request to find out about bottleneck areas.

The main thing about the sar is that, it reports all activities over a period if time. So, make sure that sar collect data on appropriate time (not on Lunch time or on weekend.:)

13. Following is a basic command to invoke sar. It will create one file named “sarfile” in your current directory. The options ‘-u‘ is for CPU details and will collect 5 reports at an interval of 2 seconds.

14. In the above example, we have invoked sar interactively. We also have an option to invoke it non-interactively via cron using scripts /usr/local/lib/sa1 and /usr/local/lib/sa2 (If you have used /usr/local as prefix during installation time).

  1. /usr/local/lib/sa1 is a shell script that we can use for scheduling cron which will create daily binary log file.
  2. /usr/local/lib/sa2 is a shell script will change binary log file to human-readable form.

Use the following Cron entries for making this non-interactive:

At the back-end sa1 script will call sadc (System Activity Data Collector) utility for fetching the data at a particular interval. sa2 will call sar for changing binary log file to human readable form.

15. Check run queue length, total number of processes and load average using ‘-q‘ option.

16. Check statistics about the mounted file systems using ‘-F‘.

17. View network statistics using ‘-n DEV‘.

18. View block device statistics like iostat using ‘-d‘.

19. To print memory statistics use ‘-r‘ option.

20. Using ‘safd -d‘, we can extract data in format which can be processed using databases.

You can also save this to a csv and then can draw chart for presentation kind of stuff as below.

Network Graph

That’s it for now, you can refer man pages for more information about each option and don’t forget to tell about article with your valuable comments.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Оцените статью