Skip to main content

Crate ktop

Crate ktop 

Source
Expand description

§ktop

ktop is a Linux process monitor and process-action tool. It ships as a binary that can run either as a full terminal UI or as a non-interactive CLI helper for grep, anomaly inspection, and targeted process signals.

§Install

cargo install ktop

§TUI Mode

ktop

The TUI uses scrin core buffers, cells, colors, rectangles, and styles plus an Aisling effects layer. ktop presents changed cells as contiguous style runs, while Aisling provides sparse color/effect pulses that avoid repainting the whole terminal.

Useful keys:

  • / opens spotlight grep.
  • T toggles process tree mode.
  • A or Ctrl+A toggles anomaly mode.
  • s opens the signal palette.
  • K confirms SIGTERM for the selected process.
  • e toggles visual effects.

Mouse support is enabled in the TUI:

  • Hover over a row for quick actions.
  • Left click selects a process.
  • Right click opens the signal palette.
  • Middle click opens confirmed SIGTERM.

§CLI Fast Paths

These commands do not initialize the TUI, which makes them useful on loaded systems, degraded terminals, and scripts:

ktop --grep 'cmd:python user:root'
ktop --anomalies --limit 20
ktop --kill 'cmd:firefox' --signal TERM
ktop --kill 1234 --signal KILL --yes
ktop --version
ktop --diagnostics
ktop --stability-check --samples 120 --interval-ms 500

--kill accepts either a PID/comma-separated PID list or a spotlight query. It asks for confirmation unless --yes is provided and sends signals directly with libc::kill.

§Resource Bounds

Long-running TUI state is bounded: histories use capped ring buffers, App-side Scrin buffers are capped, tree view uses explicit-stack traversal, spotlight input and parsed query tokens have explicit limits, process and CPU samples have hard caps, command-line reads from /proc and retained process metadata strings have byte caps, and cached /etc/passwd usernames are capped before storage. Process metadata is evicted when a PID/start-time pair is no longer present in the current /proc snapshot. ktop --diagnostics prints the live process/sample counts and configured resource caps plus cap-hit state, while ktop --stability-check reports RSS, cap-hit state, and cache high-water marks across repeated bounded samples.

§Spotlight Query Language

Plain tokens match PID, user, process name, and command line. Field tokens include user:root, name:ssh, cmd:python, pid:123, ppid:1, uid:1000, state:R, cpu>20, mem<10, age>2h, and !token negation.

§Platform

ktop currently targets Linux and reads process data from /proc.

§Library API

This crate is published primarily as a binary application. The library target exists to provide docs.rs documentation for the installed command.

Constants§

VERSION
The package version published to crates.io.