ctop – Command line based Linux containers monitoring tool

Docker is a software that allows operating-system-level virtualization, it also known as containerization.

It uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and others to allows independent containers to run within a single Linux instance.

Docker provides a way to run applications securely isolated in a container, packaged with all its dependencies and libraries.

Recent days Linux containers are famous, even most of us already working on it and few of us started learning about it.

We have already covered few articles about the famous GUI (Graphical User Interface) tools such as Portainer & Rancher. This will help us to manage containers through GUI.

Suggested Read :
(#) Portainer – A Simple Docker Management GUI
(#) Rancher – A Complete Container Management Platform For Production Environment
(#) cTop – A Command-Line Tool For Container Monitoring And Management In Linux
(#) Dry – An Interactive CLI Manager For Docker Containers

Also we had covered article about the famous CLI (Command Line Interface) tools such as cTOP & Dry.

Today we are going to discuss similar topic about the tools called cTOP.

What is ctop

ctop is a command line / text based Linux Containers monitoring tool that works just like you expect.

ctop will collect all metrics it can from cgroups in realtime and render them to instantly give you an overview of the global system health.

It currently collects metrics related to cpu, memory and block IO usage as well as metadata such as owning user (mostly for systemd based containers), uptime and attempts to guess the container managing technology behind.

ctop Futures

  • collects cpu, pids, memory and blkio metrics
  • collects metadata like task count, owning user, container technology
  • sort by any column
  • filter by container type (docker, lxc, systemd, …)
  • optionally display logical/tree view
  • optionally fold/unfold sub cgroup tree
  • optionally follow selected cgroup/container
  • optionally pause the refresh (typically, to select text)
  • detects Docker, LXC, unprivileged LXC, OpenVZ and systemd based containers
  • supports advanced features for Docker, LXC and OpenVZ based containers
  • detects qemu-kvm virtual machines (with libvirt only)
  • supports advanced features for qemu-kvm VMs (via virsh)
  • open a shell/attach to supported container types for further diagnose
  • stop/kill/chek pointing supported container types
  • click to sort / reverse
  • click to select cgroup

Suggested Read :
(#) How to install Docker in Linux
(#) How to play with Docker images on Linux
(#) How to play with Docker containers on Linux
(#) How to Install, Run Applications inside Docker Containers

How to install ctop in Linux

We can install ctop using below two methods. It requires at least Python 2.6 with builtin curses support to run.

pip installation is a recommended method to install ctop on Linux. Make sure you should have installed python-pip package on your system. If no, use the following command to install it.

For Debian/Ubuntu users, use Apt Command or Apt-Get Command to install pip package.

$ sudo apt install python-pip

For Archlinux users, use Pacman Command to install pip package.

$ sudo pacman -S python-pip

For Fedora users, use DNF Command to install pip package.

$ sudo dnf install python-pip

For CentOS/RHEL users, use YUM Command to install pip package.

$ sudo yum install python-pip

For openSUSE users, use Zypper Command to install pip package.

$ sudo zypper install python-pip

Finally run the following pip command to install ctop tool.

$ sudo pip install ctop
$ sudo ctop

As an alternate you can directly grab the self-contained source file directly from github and run it in place.

$ wget https://raw.githubusercontent.com/yadutaf/ctop/master/cgroup_top.py -O ctop
$ chmod +x ctop
$ sudo mv /usr/local/bin/ctop
$ sudo ctop

How to use ctop

Simple fire the cTOP command to load the CLI interface with list view. It shows all the local cgroups such as used by Docker, LXC, SystemD, etc,.

To view particular containers type use the --type=TYPE option followed by the cgroups name (like docker, lxc, etc).

$ sudo ctop --type=docker

Hit F5 to toggle tree view.

Select the corresponding container using UP/DOWN arrows to manage it, then use the available options such as stop, kill, attach, enable shell to manage.

Hit e to launch a container shell. Now, you are in inside the container and perform your activity. To testing purpose, we are going to check the distribution information. Finally, type exit or CTRL+P followed by CTRL+Q to exit from interactive shell.

Hit s to stop a container. you can able to see three containers here, we are going to stop “elastic_nobel” container by hitting “s” button.

Yes, it’s gone because i can see only two containers.

Hit k to kill a container shell. You can able to see two containers here, we are going to kill “nifty_shtern” container by hitting “k” button. Wait few sec then it will go off. Yes, it’s gone.

Hit q to exit from ctop command.


Few disadvantages on this tool, we will raise this to developer for further enhancement.

  • There is no option available to list inactive containers.
  • We can’t kick start the inactive containers as there is no option for that.

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

Your email address will not be published. Required fields are marked *