sysstat: check device performance

tux_compsysstat is a collection of utilities to collect performance information and a plethora of other metrics from the system. The utilities are grouped in 4 sets:

  • sar / sadc / sadf : collects system activity information in audit mode (memory, paging, swap…)
  • iostat / tapestat / nfsiostat / cifsiostat : CPU, I/O, partition, disk information
  • mpstat : processor statistics
  • pidstat : process statistics

The full package is written in C and runs very fast.

Features

  • Monitors several metrics:
    > Input / Output and transfer rate statistics (global, per device, per partition, per network filesystem and per Linux task / PID).
    > CPU statistics (global, per CPU and per Linux task / PID), including support for virtualization architectures.
    > Memory, hugepages and swap space utilization statistics.
    > Virtual memory, paging and fault statistics.
    > Per-task (per-PID) memory and page fault statistics.
    > Global CPU and page fault statistics for tasks and all their children.
    > 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; supports IPv6-related protocols, Fibre Channel traffic statistics.
    > NFS server and client activity.
    > Socket statistics.
    > Run queue and system load statistics.
    > Kernel internal tables utilization statistics.
    > System and per Linux task switching activity.
    > Swapping statistics.
    > TTY device 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).
    > Tape drives statistics.
  • Calculates average statistics over sampling period.
  • Dynamic device detection.
  • SupportsĀ UP and SMP, x86 and x86_64 arch, devices with hyper-threaded or multi-core processors.
  • Export stats in several formats.
  • Present data as graphs usingĀ isag (packaged).

Installation

To install on Ubuntu, run:

$ sudo apt-get install sysstat

Usage

Due to the number of tools, covering all is beyond the scope of this article. Please refer to the official documentation that links to the man page of each tool.

However, we loved a feature of pidstat which shows which processes are using the CPU in a user-defined interval (we used 1 sec):

$ pidstat 1
Linux 4.3.0-040300-generic (tux) 	Sunday 08 November 2015 	_x86_64_	(4 CPU)

08:17:00  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
08:17:01  IST   116      1119    1.00    0.00    0.00    1.00     0  tor
08:17:01  IST  1000      4107    1.00    0.00    0.00    1.00     2  yandex_browser
08:17:01  IST  1000      5323    3.00    2.00    0.00    5.00     1  yandex_browser
08:17:01  IST  1000      6850    1.00    0.00    0.00    1.00     0  pidstat

08:17:01  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
08:17:02  IST     0       463    0.00    1.00    0.00    1.00     1  irq/29-iwlwifi
08:17:02  IST  1000      1097    1.00    0.00    0.00    1.00     2  altyo
08:17:02  IST  1000      5323    5.00    1.00    0.00    6.00     2  yandex_browser
08:17:02  IST  1000      6850    1.00    0.00    0.00    1.00     0  pidstat

08:17:02  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
08:17:03  IST  1000      5323    5.00    0.00    0.00    5.00     2  yandex_browser
08:17:03  IST  1000      6850    0.00    1.00    0.00    1.00     0  pidstat
^C

Average:      UID       PID    %usr %system  %guest    %CPU   CPU  Command
Average:        0       463    0.00    0.33    0.00    0.33     -  irq/29-iwlwifi
Average:     1000      1097    0.33    0.00    0.00    0.33     -  altyo
Average:      116      1119    0.33    0.00    0.00    0.33     -  tor
Average:     1000      4107    0.33    0.00    0.00    0.33     -  yandex_browser
Average:     1000      5323    4.33    1.00    0.00    5.33     -  yandex_browser
Average:     1000      6850    0.67    0.33    0.00    1.00     -  pidstat

To monitor a single process in intervals of 1 second:

$ pidstat -p PID 1

5 thoughts on “sysstat: check device performance”

  1. Hi, Arun!

    Do you know if any of these tools can be used to monitor a single process? procexp can do it, like in this screenshot where it is monitoring Firefox:

    But the project seems not to have been mantained for some time already!

      1. $ pidstat -p 2109 1
        Linux 4.3.0-040300-generic (tux) 	Monday 09 November 2015 	_x86_64_	(4 CPU)
        
        07:33:50  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
        07:33:51  IST  1000      2109    0.00    0.00    0.00    0.00     0  yandex_browser
        07:33:52  IST  1000      2109    1.00    0.00    0.00    1.00     2  yandex_browser
        07:33:53  IST  1000      2109    1.00    0.00    0.00    1.00     2  yandex_browser
        07:33:54  IST  1000      2109    0.00    0.00    0.00    0.00     2  yandex_browser
        ^C
        Average:     1000      2109    0.50    0.00    0.00    0.50     -  yandex_browser

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s