Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: ctop – Top-like Interface for Monitoring Docker Containers  (Read 1635 times)

0 Members and 1 Guest are viewing this topic.

vyshnavk

  • Guest
ctop is a free open source, simple and cross-platform top-like command-line tool for monitoring container metrics in real-time. It allows you to get an overview of metrics concerning CPU, memory, network, I/O for multiple containers and also supports inspection of a specific container.


Docker Container Monitoring

At the time of writing this article, it ships with built-in support for Docker (default container connector) and runC; connectors for other container and cluster platforms will be added in future releases.

How to Install ctop in Linux Systems

Installing the latest release of ctop is as easy as running the following commands to download the binary for your Linux distribution and install it under /usr/local/bin/ctop and make it executable to run it.

Code: [Select]
$ sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.1/ctop-0.7.1-linux-amd64  -O /usr/local/bin/ctop
$ sudo chmod +x /usr/local/bin/ctop

Alternatively, install ctop via Docker using following command.

Code: [Select]
$ docker run --rm -ti --name=ctop -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest

Once you have installed ctop, you can run it to list all your containers whether active or not.

Code: [Select]
$ ctop


Monitor Docker Containers

You can use the Up and Down arrow keys to highlight a container and click Enter to select it. You will see a menu as shown in the following screenshot. Choose “single view” and click on it to inspect the selected container.


Monitor Single Docker Container

The following screenshot shows the single view mode for a specific container.


Inspect a Single Container

To display active containers only, use the -a flag.

Code: [Select]
$ ctop -a


Check Active Docker Container

To display CPU as % of system total, use the -scale-cpu option.

Code: [Select]
$ ctop -scale-cpu

You can also filter containers using the -f flag, for example.

Code: [Select]
$ ctop -f app

Additionally, you can select initial container sort field using the -s flag, and see the ctop help message as shown.

Code: [Select]
$ ctop -h

ctop is a simple top-like tool for visualizing and monitoring container metrics in real-time. In this article, we’ve expalined how to install and use ctop in Linux. You can share your thoughts or ask any questions via the comment form below.