Hello good people. Linux monitoring is a crucial activity for any systems administrator. I know that having the right tools for this purpose is not an easy task. In this article, we’ll look at the Linux top command alternative called gotop.
Gotop is a terminal based graphical activity monitor inspired by gtop. I’ll cover gtop installation in a different article. Unlike Gtop which is written in Node.js, gotop is written in Golang.
Installing gotop on Linux – CentOS, Ubuntu e.t.c
Since gotop is distributed as a binary package, there is no prerequisite apart from git and curl packages which you can easily install on your Linux distribution.
Install git and curl on CentOS / Fedora
sudo yum -y install git curl
Installing git and curl on Ubuntu / Debian
sudo apt update && sudo apt -y install git curl
Clone gotop source from Github.
$ git clone --depth 1 https://github.com/cjbassi/gotop.git Cloning into 'gotop'... remote: Counting objects: 603, done. remote: Compressing objects: 100% (460/460), done. remote: Total 603 (delta 140), reused 463 (delta 123), pack-reused 0 Receiving objects: 100% (603/603), 1.19 MiB | 3.46 MiB/s, done. Resolving deltas: 100% (140/140), done.
Navigate to the gotop directory and run auto-installer script.
cd gotop ./scripts/download.sh
The script will download a gotop binary for your Linux CPU architecture. Supported architectures are:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2045k 100 2045k 0 0 3559k 0 --:--:-- --:--:-- --:--:-- 3559k
The command above will download the latest stable archive and extract it. You should see a binary package named gotop in your current directory, you need to copy this to a path in your $PATH.
echo $PATH sudo mv gotop /usr/local/bin cd ~/
Confirm you can use gotop command:
$ which gotop
/usr/local/bin/gotop
$ gotop -V
3.0.0
Linux Process Monitoring with gotop
To run gotop, just type the name of the command on your terminal shell:
gotop
This will run gotop with the default command options. You should get a screen like below:
The help page can be accessed from:
$ gotop --help
Usage: gotop [options]
Options:
-c, --color=NAME Set a colorscheme.
-h, --help Show this screen.
-m, --minimal Only show CPU, Mem and Process widgets.
-r, --rate=RATE Number of times per second to update CPU and Mem widgets [default: 1].
-V, --version Print version and exit.
-p, --percpu Show each CPU in the CPU widget.
-a, --averagecpu Show average CPU in the CPU widget.
-f, --fahrenheit Show temperatures in fahrenheit.
-s, --statusbar Show a statusbar with the time.
-b, --battery Show battery level widget ('minimal' turns off).
Colorschemes:
default
default-dark (for white background)
solarized
monokai
vice
From above help screen, you can pass some options to filter output you get. E.g
Show minimal output, i.e CPU and RAM usage stats using:
$ gotop --minimal
The output should be similar to below:
Gotop key bindings
- q or <Ctrl-c> : Used to quit gotop program
- <up>/<down> and j/k: Navigate up and down
- <Ctrl-d> and <Ctrl-u>: up and down half a page
- <Ctrl-f> and <Ctrl-b>: up and down a full page
- gg and G: Jump to top and bottom
- <tab>: toggle process grouping
- dd: kill the selected process or process group
- h and l: zoom in and out of CPU and Mem graphs
- ?: toggles keybind help menu
You can also do sorting based on memory or cpu usage:
- c: Sort based on CPU utilization
- m: Sort based on Memory usage
- p: Sort based PID
The color schemes for gotop are available under the colorschemes directory:
$ ls colorschemes/ default_dark.go monokai.go solarized.go template.go default.go monokai.png solarized.png
You can set a different Colorscheme can be set with the -c flag followed its name, e.g
$ gotop -c monokai
It should start gotop with monokai colorscheme.
That’s all for today. Enjoy using a gotop command for easy to visualize process monitoring and your server compute resource utilization.