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
で昇順、降順を切り替えられる。