Ctop is a new command line based tool, which can be used to monitor progress in the container hierarchy. Container by using the controller group (cgroup) resource management functions, provides a virtual environment operating system level. Input and output of the tool from the cgroup collection and memory, CPU, block-related data, as well as the owner, boot time and other metadata, and presented in human-friendly format to the user, so you can quickly assess the health of the system. Based on the obtained data, it can be speculated that the lower container technique attempts. ctop also help to detect in low-memory environments who consume large amounts of memory.
Some features ctop follows:
Collect CPU, memory and input-output block metric
Collection and owners, container technology and statistical information related to the task
Sort by any field of information
In the tree view displays information
Folding / unfolding cgroup tree
Select and track cgroup / container
Choose to display data refresh time window
Pause Refresh Data
Detection based on systemd, Docker and LXC container
Based on advanced features Docker and LXC container
Open / shell connection for in-depth diagnosis
Stop / kill container types
ctop is written in Python, so, in addition to Python 2.6 or later outside (with a built-in cursor support), no other external dependencies. Pip recommend using Python installed, if you have not installed pip, please install and use pip install ctop.
Note: Sample article from Ubuntu (14.10) System
$ Sudo apt-get install python-pip
Installation using pip ctop:
poornima @ poornima-Lenovo: ~ $ sudo pip install ctop
[Sudo] password for poornima:
Downloading / unpacking ctop
Running setup.py (path: /tmp/pip_build_root/ctop/setup.py) egg_info forpackage ctop
Installing collected packages: ctop
Running setup.py install for ctop
changing mode of build / scripts-2.7 / ctop from644 to 755
changing mode of / usr / local / bin / ctop to 755
Successfully installed ctop
Cleaning up ...
If you choose not to use pip to install, you can also use wget installed directly from github:
poornima @ poornima-Lenovo: ~ $ wget https://raw.githubusercontent.com/yadutaf/ctop/master/cgroup_top.py -O ctop
--2015-04-2919: 32: 53-- https://raw.githubusercontent.com/yadutaf/ctop/master/cgroup_top.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com) ... 126.96.36.199
Connecting to raw.githubusercontent.com (raw.githubusercontent.com) | 188.8.131.52 |: 443 ... connected.
HTTP request sent, awaiting response ... 200 OK Length: 27314 (27K) [text / plain]
Saving to: ctop
100% [======================================>] 27,314 --.- K / s in0s
2015-04-2919: 32: 59 (61.0 MB / s) - ctop saved [27314/27314]
poornima @ poornima-Lenovo: ~ $ chmod + x ctop
If cgroup-bin package is not installed, you may encounter an error message, you can install the package needs to be resolved.
poornima @ poornima-Lenovo: ~ $ ./ctop
[ERROR] Failed to locate cgroup mountpoints.
poornima @ poornima-Lenovo: ~ $ sudo apt-get install cgroup-bin
ctop [--tree] [- refresh =] [- columns =] [- sort-col =] [- follow =] [- fold =, ...] ctop (-h | --help )
When you enter ctop screen, you can use the (up) and down (down) arrow keys to navigate between the containers. Click on a selected container is the container, press q or Ctrl + C to exit the container.
Now, let's look at a pile of options listed above exactly how to use it.
-h / --help - displays help letter
poornima @ poornima-Lenovo: ~ $ ctop -h
Usage: ctop [options]
-h, - help show this help message andexit
--tree show tree view bydefault
--refresh = REFRESH Refresh display every
--follow = FOLLOW Follow cgroup path
--columns = COLUMNS List of optional columns to display.Always includes
--sort-col = SORT_COL Select column to sort by initially.Can be changed
--tree - displays a tree view of the container
By default, the list view displays
When you enter ctop window, you can use the F5 button in between the tree / list view switching.
--fold = - folded in the tree view named path to the cgroup
This option requires the use of --tree combination of options.
Examples: ctop --tree --fold = / user.slice
'Ctop --fold' output
In ctop window, use the +/- keys to expand or collapse the child cgroup.
Note: At this moment, pip warehouse also not have the latest version of ctop, does not support the command line '--fold' option
--follow = - track / path highlighted cgroup
Examples: ctop --follow = / user.slice / user-1000.slice
As you can see in the screen below it, with a cgroup "/user.slice/user-1000.slice" path is highlighted, allowing users easy to trace, even if the display position has changed, too.
'Ctop --follow' output
You can also use the 'f' button to make the highlights are tracking the selected container. By default, tracing is turned off.
--refresh = - specified frequency to refresh the display, the default 1 seconds
This is for every user needs to change the display refresh rate is useful. Use 'p' button to pause and refresh select text.
--columns = - Limited show only the selected columns. 'Name' needs to be the first field, followed by followed by other fields. By default, the field includes: owner, processes, memory, cpu-sys, cpu-user, blkio, cpu-time
Examples: ctop --columns = name, owner, type, memory
'Ctop --column' output
-sort-col = - by the specified column. Default cpu-user sort
Examples: ctop --sort-col = blkio
If there are additional container Docker and LXC support, tracking options are also available:
press' a'- connected to the output terminal
press' e'- open container of a shell
press' s'- stop the container (SIGTERM)
press' k'- kill container (SIGKILL)
Currently Jean-Tiare Le Bigot also actively develop ctop in the hope that we can see the same commands as the top local features in the tool.