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.
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.
- 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
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.
$ 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
To view particular containers type use the
--type=TYPE option followed by the cgroups name (like docker, lxc, etc).
$ sudo ctop --type=docker
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
CTRL+P followed by
CTRL+Q to exit from interactive shell.
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.