kmon 0.2.1

Linux kernel manager and activity monitor
kmon-0.2.1 is not a library.
Visit the last successful build: kmon-1.7.1

The kernel is the part of the operating system that facilitates interactions between hardware and software components. On most systems, it is loaded on startup after the bootloader and handles I/O requests as well as peripherals like keyboards, monitors, network adapters, and speakers. Typically, the kernel is responsible for memory management, process management, device management, system calls, and security. Applications use the system call mechanism for requesting a service from the operating system and most of the time, this request is passed to the kernel using a library provided by the operating system to invoke the related kernel function. While the kernel performs these low-level tasks, it's resident on a separate part of memory named protected kernel space which is not accessible by applications and other parts of the system. In contrast, applications like browsers, text editors, window managers or audio/video players use a different separate area of the memory, user space. This separation prevents user data and kernel data from interfering with each other and causing instability and slowness, as well as preventing malfunctioning application programs from crashing the entire operating system.
There are different kernel designs due to the different ways of managing system calls and resources. For example, while monolithic kernels run all the operating system instructions in the same address space for speed, microkernels use different spaces for user and kernel services for modularity. Apart from those, there are hybrid kernels, nanokernels, and, exokernels. The hybrid kernel architecture is based on combining aspects of microkernel and monolithic kernels.

The Linux kernel is the open-source, monolithic and, Unix-like operating system kernel that used in the Linux distributions, various embedded systems such as routers and as well as in the all Android-based systems. Linus Torvalds conceived and created the Linux kernel in 1991 and it's still being developed by thousands of developers today. It's a prominent example of free and open source software and it's used in other free software projects, notably the GNU operating system. Although the Linux-based operating systems dominate the most of computing, it still carries some of the design flaws which were quite a bit of debate in the early days of Linux. For example, it has the largest footprint and the most complexity over the other types of kernels. But it's a design feature that monolithic kernels inherent to have. These kind of design issues led developers to add new features and mechanisms to the Linux kernel which other kernels don't have.

Unlike the standard monolithic kernels, the Linux kernel is also modular, accepting loadable kernel modules (LKM) that typically used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. Since LKMs could be loaded and unloaded to the system at runtime, they have the advantage of extending the kernel without rebooting and re-compiling. Thus, the kernel functionalities provided by modules would not reside in memory without being used and the related module can be unloaded in order to free memory and other resources.
Loadable kernel modules are located in /lib/modules with the .ko (kernel object) extension in Linux. While the lsmod command could be used for listing the loaded kernel modules, modprobe is used for loading or unloading a kernel module.

Here's a simple example of a Linux kernel module that prints a message when it's loaded and unloaded. The build and installation steps of the module using a Makefile are shown below.

make                         # build
sudo insmod lkm_example.ko   # install
sudo modprobe lkm_example    # load
sudo modprobe -r lkm_example # unload

dmesg output

The dmesg command is used above to retrieve the message buffer of the kernel.

kmon provides a text-based user interface for managing the Linux kernel modules and monitoring the kernel activities. By managing, it means loading, unloading, blacklisting and showing the information of a module. These updates in the kernel modules, logs about the hardware and other kernel messages can be tracked with the real-time activity monitor in kmon. Since the usage of different tools like dmesg and kmod are required for these tasks in Linux, kmon aims to gather them in a single terminal window and facilitate the usage as much as possible while preserving the functionality.

Installation

Cargo

kmon can be installed from crates.io using Cargo if Rust is installed.

cargo install kmon

Use the --force option to update.

cargo install kmon --force

AUR

kmon can be installed from available AUR packages using an AUR helper. For example,

trizen kmon

Manual

  1. Download the latest binary from releases.
wget https://github.com/orhun/kmon/releases/download/v[VERSION]/kmon-[VERSION].tar.gz
  1. Extract the files.
tar -xvzf kmon-*.tar.gz
  1. Run the binary.
./kmon
  1. Move binary to /usr/local/bin/ for running it from the terminal using kmon command. (Optional)

Note

libxcb should be installed for using the copy/paste commands of X11. *

Usage

kmon [FLAGS] [OPTIONS] [SUBCOMMANDS]

Flags

-h, --help       Prints help information
-r, --reverse    Reverse the kernel module list
-u, --unicode    Show Unicode symbols for the block titles
-V, --version    Prints version information

Options

-c, --color <COLOR>    Set the main color using hex or color name [default: darkgray]
-t, --tickrate <MS>    Set the refresh rate of the terminal [default: 250]

Subcommands

help    Prints this message or the help of the given subcommand(s)
sort    Sort kernel modules
kmon sort [FLAGS]

FLAGS:
    -n, --name    Sort modules by their names
    -s, --size    Sort modules by their sizes

Key Bindings

Press '?' while running the terminal UI to see key bindings.

[?], F1 Help
right/left, h/l Switch between blocks
up/down, k/j Scroll up/down [selected block]
pgup/pgdown Scroll up/down [kernel activities]
</> Scroll up/down [module information]
ctrl-t/b, home/end Scroll to top/bottom [module list]
ctrl-l/u, alt-c Clear the kernel ring buffer
[\], tab, backtab Show the next kernel information
[/], s, enter Search a kernel module
[+], i, insert Load a kernel module
[-], u, backspace Unload the kernel module
x, b, delete Blacklist the kernel module
y/n Execute/cancel the command
c/v Copy/paste
r, F5 Refresh
q, ctrl-c/d, ESC Quit

Examples

Docker

Docker Hub Build Status Package Registry Build Status

docker run -it --cap-add syslog orhunp/kmon:tagname

Build

docker build -t kmon .

Run

docker run -it --cap-add syslog kmon

Resources

Project

Links

License

GNU General Public License (3.0)

Copyright

Copyright (c) 2020, orhun