Have you been searching for a top like interface for container metrics and monitoring?. Ctop is a command line tool written to provide a concise and condensed overview of real-time metrics for containers running in your system. This command line tool comes with built-in support for both Docker and runC container engines.

Features of Ctop:

  • Lightweight: It has low resource overhead making it suitable to run on any hardware.
  • Monitoring in Real-time: It will give you realtime monitoring information of containers usage of CPU, memory, network, and storage.
  • Intuitive & Interactive interface: Has an easy to navigate and use interface with simple filtering using keyboard shortcuts.
  • Container management Support: You can easily start, restart, stop, and do container inspection from the interface.
  • Nice Resource visualization: With graphs and charts visualization it’s easy to monitor resource usage trends.
  • Cross-platform support: Ctop can be installed on macOS, Windows, and on Linux.

Installing ctop on Linux / macOS

Ctop is written in Go and distributed as binary file which you can quickly download from Github and install it. Fetch the latest release for your platform and download with your wget or curl command.

Install ctop on Linux

For Linux systems we’ll download the binary file, extract and put in in the system PATH.

curl -s https://api.github.com/repos/bcicen/ctop/releases/latest | grep browser_download_url|grep linux-amd64 | cut -d '"' -f 4 | wget -i -
chmod +x ctop-*-linux-amd64
sudo mv ctop-*-linux-amd64 /usr/local/bin/ctop

Confirm installation by checking its version.

$ ctop -v
ctop version 0.7.7, build 11a1cb1 go1.18

Install ctop on macOS

If you’re running OS X, you can install ctop with brew or by downloading the latest pre-built binary file from Github.

Install ctop with brew:

brew install ctop

For manual package download, it is similar to below.

curl -s https://api.github.com/repos/bcicen/ctop/releases/latest | grep browser_download_url|grep darwin-amd64 | cut -d '"' -f 4 | wget -i -
chmod +x ctop-*-darwin-amd64
sudo mv ctop-*-darwin-amd64 /usr/local/bin/ctop

Confirm that is working.

$ ctop  --help
 Usage of ctop:
   -a    show active containers only
   -connector string
         container connector to use (default "docker")
   -f string
         filter containers
   -h    display this help dialog
   -i    invert default colors
   -r    reverse container sort order
   -s string
         select container sort field
   -scale-cpu
         show cpu as % of system total
   -v    output version information and exit

Launching and using ctop

Using ctop is easy, just run the command ctop and you should get containers metrics displayed to you in realtime.

$ ctop

Sample output

top command docker containers

Ctop Keybindings

KeyAction
<enter>Open container menu
aToggle display of all (running and non-running) containers
fFilter displayed containers (esc to clear when open)
HToggle ctop header
hOpen help dialog
sSelect container sort field
rReverse container sort order
oOpen single view
lView container logs (t to toggle timestamp when open)
SSave current configuration to file
qQuit ctop

Running ctop in Docker container

If you have big love for containers, you can run ctop in a docker container. But first install Docker in your system using the guide below,

Once docker is installed and running, spin up ctop container by running:

docker run --rm -ti \
  --name=ctop \
  -v /var/run/docker.sock:/var/run/docker.sock \
  quay.io/vektorlab/ctop:latest

Other interesting container articles.

LEAVE A REPLY

Please enter your comment!
Please enter your name here