Install and Use collectl Performance Monitoring Tool on Ubuntu 18.04 LTS

Monitoring system resources & performance analysis is an important task of any system administrator. There are many tools available for Linux to monitor system performance including, top, htop, free, etc. Collectl is a free, open source and light-weight performance monitoring tool that can be used to gather information of system resources such as, cpu, disk, memory, network, Infiniband, lustre, memory, nfs, slabs and many more. Unlike other monitoring tools, collectl focus on a small set of statistics. Collectl is capable of monitoring different parameters at the same time and report them in a suitable manner. Collectl comes with a verity of options that help you to identify any kind of system performance issues. Using collectl, you can generate the same output of mpstat, netstat, nfsstat, sar, ps, top and iostat.

Features

  • Ability to display the output in many formats.
  • Export the data in various file formats.
  • Ability to run as a service to monitor remote machines.
  • Monitor almost any subsystem.

In this tutorial, we will learn how to install and use Collectl on Ubuntu 18.04 server.

Requirements

  • A server running Ubuntu 18.04.
  • A root password is setup to your server.

Getting Started

Before starting, you will need to update your system with the latest version. You can do this by running the following command:

apt-get update -y
apt-get upgrade -y

Once your server is updated, restart your server to apply the changes.

Install Collectl

By default, Collectl is available in the Ubuntu 18.04 default repository. You can install it by running the following command:

apt-get install collectl -y

Once the installation has been completed, you can run the following command to list all the options available with collectl:

collectl --h

You should see the following output:

This is a subset of the most common switches and even the descriptions are
abbreviated.  To see all type 'collectl -x', to get started just type 'collectl'

usage: collectl [switches]
  -c, --count      count      collect this number of samples and exit
  -f, --filename   file       name of directory/file to write to
  -i, --interval   int        collection interval in seconds [default=1]
  -o, --options    options    misc formatting options, --showoptions for all
                                d|D - include date in output
                                  T - include time in output
                                  z - turn off compression of plot files
  -p, --playback   file       playback results from 'file' (be sure to quote
			      if wild carded) or the shell might mess it up
  -P, --plot                  generate output in 'plot' format
  -s, --subsys     subsys     specify one or more subsystems [default=cdn]
      --verbose               display output in verbose format (automatically
                              selected when brief doesn't make sense)

Various types of help
  -h, --help                  print this text
  -v, --version               print version
  -V, --showdefs              print operational defaults
  -x, --helpextend            extended help, more details descriptions too
  -X, --helpall               shows all help concatenated together

  --showoptions               show all the options
  --showsubsys                show all the subsystems
  --showsubopts               show all subsystem specific options
  --showtopopts               show --top options

  --showheader                show file header that 'would be' generated
  --showcolheaders            show column headers that 'would be' generated
  --showslabaliases           for SLUB allocator, show non-root aliases
  --showrootslabs             same as --showslabaliases but use 'root' names

Copyright 2003-2016 Hewlett-Packard Development Company, L.P.
collectl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the source kit

Working with Collectl

Now, run the collectl without any option will display information on cpu, disk and network stats in a very short and human readable format.

collectl

You should see the following output:

waiting for 1 second sample...
#<--------cpu--------><----------disks-----------><----------network---------->
#cpu sys inter  ctxsw KBRead  Reads KBWrit Writes   KBIn  PktIn  KBOut  PktOut 
  17  11   503    320      4      1     20      3      0      0      0       0 
   2   1   565    165      0      0      0      0      0      2      0       2 
   6   3   545     83      0      0      0      0      0      2      0       2 
   0   0   508     39      0      0      0      0      0      2      0       2 
   1   1   517     42      0      0      0      0      0      2      0       2 
   1   1   442     37      0      0      0      0      0      2      0       2 
   1   1   538     65      0      0     20      2      0      2      0       2 
   1   1   443     39      0      0      0      0      0      2      0       2 
   1   1   409     39      0      0      0      0      0      2      0       2 
   1   1   381     38      0      0      0      0      0      2      0       2 
   1   1   451     44      0      0      0      0      0      2      0       2 
   3   2   482     42      0      0      0      0      0      2      0       2 
   9   2   528    101      0      0      0      0      0      2      0       2 
   1   1   428     39      0      0      0      0      0      2      0       2 

You can also list the statistics for all subsystems with the following command:

collectl --all

Output:

waiting for 1 second sample...
#<--------cpu--------><-----------------memory-----------------><----------disks-----------><----------network----------><-------tcp--------><------sockets-----><----files---><------nfs totals------="">
#cpu sys inter  ctxsw Cpu0 Free Buff Cach Inac Slab  Map   Fragments KBRead  Reads KBWrit Writes   KBIn  PktIn  KBOut  PktOut   IP  Tcp  Udp Icmp  Tcp  Udp  Raw Frag Handle Inodes  Reads Writes Meta Comm 
   3   0   459     48  459 139M  63M 573M 413M  93M 136M jibaa4a59ab      0      0      0      0      0      0      0       0    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
  12   7   528    142  530 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      1       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   3   1   477     57  477 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   5   2   437     55  435 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   1   0   426     43  426 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   4   1   435     54  435 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44711      0      0    0    0 
   4   2   471     49  472 139M  63M 573M 413M  93M 136M jhbaa5959ab      0      0      0      0      0      2      0       2    0    0    0    0  144    0    0    0   1088  44712      0      0    0    0 

You can also use the collectl command with --top option as shown below:

collectl --top

Output:

# TOP PROCESSES sorted by time (counters are /sec) 14:14:24
# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command
 5194  root     20  1233    0 R   66M   27M  0  0.06  0.13  19  00:02.79    0    0    0    0 /usr/bin/perl 
    8  root     20     2    0 I     0     0  0  0.01  0.00   1  00:01.86    0    0    0    0 rcu_sched 
 1165  root     20   866    0 S  103M    7M  0  0.01  0.00   1  00:05.00    0    0    0    0 sshd: 
 3593  root     20     2    0 I     0     0  0  0.01  0.00   1  00:01.45    0    0    0    0 kworker/0:0 
    1  root     20     0    0 S   76M    9M  0  0.00  0.00   0  00:10.28    0    0    0    0 /sbin/init 
    2  root     20     0    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 kthreadd 
    4  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kworker/0:0H 
    6  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 mm_percpu_wq 
    7  root     20     2    0 S     0     0  0  0.00  0.00   0  00:02.75    0    0    0    0 ksoftirqd/0 
    9  root     20     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 rcu_bh 
   10  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 migration/0 
   11  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.03    0    0    0    0 watchdog/0 
   12  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 cpuhp/0 
   13  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kdevtmpfs 
   14  root      0     2    0 I     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 netns 
   15  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 rcu_tasks_kthre 
   16  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kauditd 

Monitor CPU, Memory and Disk Usage

You can monitor CPU usage by running the collectl with -sc option:

collectl -sc

Output:

waiting for 1 second sample...
#<--------cpu-------->
#cpu sys inter  ctxsw 
   1   1   461     35 
   2   2   631     71 
  11   0   472    109 
   1   1   552     48 
   1   1   457     39 
   0   0   566     46 
   5   3   572    101 
   0   0   543     38 
   1   1   445     40 
   1   1   591     43 
   1   1   441     36 
   0   0   565     51 

You can also see detail information of CPU usage with the following command:

collectl -sC

Output:

waiting for 1 second sample...

# SINGLE CPU STATISTICS
#   Cpu  User Nice  Sys Wait IRQ  Soft Steal Guest NiceG Idle
      0     2    0    3    0    0    0     0     0     0   94
      0     0    0    1    0    0    0     0     0     0   98
      0     0    0    1    0    0    0     0     0     0   98
      0     0    0    0    0    0    1     0     0     0   98
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    0    0    0    0     0     0     0  100
      0     1    0    1    0    0    0     0     0     0   97
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    1    1    0    1     0     0     0   96
      0     0    0    0    0    0    0     0     0     0  100
      0     0    0    1    0    0    0     0     0     0   98

To monitor memory usage of your system, run the following command:

collectl -sm

Output:

waiting for 1 second sample...
#<-----------memory----------->
#Free Buff Cach Inac Slab  Map 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 
 139M  63M 573M 413M  93M 136M 

Monitor memory usage with detail information with the following command:

collectl -sM

Output:

waiting for 1 second sample...

# MEMORY STATISTICS 
# Node    Total     Used     Free     Slab   Mapped     Anon    AnonH   Locked    Inact HitPct
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866844K  142800K   95928K   46160K   93416K        0    5408K  423952K 100.00
     0     985M  866968K  142676K   95928K   46160K   93416K        0    5408K  423952K 100.00

You can monitor disk usage with the following command:

collectl -sd

Output:

waiting for 1 second sample...
#<----------disks----------->
#KBRead  Reads KBWrit Writes 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      0      0 
      0      0      8      0 
      0      0      0      2

Monitor disk usage with detail information with the following command:

collectl -sD

Output:

waiting for 1 second sample...

# DISK STATISTICS (/sec)
#          <---------reads---------------><---------writes--------------><--------averages--------> Pct
#Name       KBytes Merged  IOs Size  Wait  KBytes Merged  IOs Size  Wait  RWSize  QLen  Wait SvcTim Util
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0
sda              0      0    0    0     0      20      1    1   20     0      20     0     0      0    0
sda              0      0    0    0     0       0      0    0    0     0       0     0     0      0    0

Monitor CPU, Memory and Disk at a Time

You can monitor CPU, Memory and Disk usage by running the single command:

collectl -scmd

Output:

waiting for 1 second sample...
#<--------cpu--------><-----------memory-----------><----------disks----------->
#cpu sys inter  ctxsw Free Buff Cach Inac Slab  Map KBRead  Reads KBWrit Writes 
   1   0   518     43 140M  63M 573M 413M  93M 135M      0      0      0      0 
   7   2   509    104 140M  63M 573M 413M  93M 135M      0      0     20      1 
   3   1   518     52 140M  63M 573M 413M  93M 135M      0      0      0      0 
   1   1   445     43 140M  63M 573M 413M  93M 135M      0      0      0      0 
   2   1   482     51 140M  63M 573M 413M  93M 135M      0      0      0      0 
   1   1   535     56 140M  63M 573M 413M  93M 135M      0      0      0      0 
   3   1   499     48 140M  63M 573M 413M  93M 135M      0      0      0      0 
   2   1   482     53 140M  63M 573M 413M  93M 135M      0      0     20      2 

Conclusion

In the above article, I have provided a brief overview of collectl. Collectl comes with a lot of options that make it easy to monitor your Linux system.

Share this page:

Suggested articles

0 Comment(s)

Add comment