Linuxメモ : Rust製のprocs(モダンなpsコマンド)でプロセス表示
procs
procsはRust製のモダンなpsコマンド。
特徴は以下のとおり。
- Output by the colored and human-readable format
- Keyword search over multi-column
- Some additional information which are not supported by
ps- TCP/UDP port
- Read/Write throughput
- Docker container name
- More memory information
- Pager support
- Watch mode like
top - Tree view
インストール
README.mdのインストール方法によるとcargoやバイナリのダウンロードなどでインストールできる。
$ cargo install procs
ヘルプメッセージ。
$ procs --help
procs 0.9.20
USAGE:
procs [FLAGS] [OPTIONS] [--] [KEYWORD]...
FLAGS:
-a, --and AND logic for multi-keyword
-o, --or OR logic for multi-keyword
-d, --nand NAND logic for multi-keyword
-r, --nor NOR logic for multi-keyword
-l, --list Show list of kind
-t, --tree Tree view
-w, --watch Watch mode with default interval (1s)
--config Generate configuration sample file
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-W, --watch-interval <second> Watch mode with custom interval
-i, --insert <kind>... Insert column to slot
--sorta <kind> Sort column by ascending
--sortd <kind> Sort column by descending
-c, --color <color> Color mode [possible values: auto, always, disable]
-p, --pager <pager> Pager mode [possible values: auto, always, disable]
--interval <millisec> Interval to calculate throughput [default: 100]
ARGS:
<KEYWORD>... Keywords for search
使い方
procsコマンドを実行するとps auxと同様な結果が得られる。

検索
procs zshのように文字列を指定するとUSER, Command, Dockerカラムを対象に検索できる(部分一致)。

procs 10のように数値を指定するとPID, TCP, UDPカラムを対象に検索できる(完全一致)。
また、--and, --or, --nand, --norなどでの条件指定も可能。

ソート
ソートは--sorta(昇順), --sortd(降順)オプションで指定できる。
例えばMEMカラムを降順でソートしたい場合はprocs --sortd memのようにする。

対象カラムについては-lまたは--listオプションで確認可能。

ツリービュー
-tまたは--treeオプションでツリービュー表示ができる。

ウォッチモード
-wまたは--watchオプションでtopコマンドのように定期的に更新できる(デフォルトは1秒ごと)。
--watch-interval 3のようにすると3秒ごとに更新できる。
ウォッチモードは起動時にはPIDの昇順でソートされているが、画面上部に表示されているようにn, pでソート対象カラム、a, dで昇順、降順を切り替えられる。
