procs

procs is a replacement for ps written by Rust.

Build Status Changelog Crates.io codecov

Features

Platform

Installation

Download binary

Download from release page, and extract to the directory in PATH.

Cargo

You can install by cargo.

cargo install procs

macOS permission issue

In macOS, normal user can't access the process information of other users. So procs requires SUID as the same as ps command. If you add SUID to procs, do like below:

console $ sudo chown root [procs binary path] $ sudo chmod u+s [procs binary path]

Usage

Show all processes

Type procs only. It shows the information of all processes.

console $ procs

procs

Search by non-numeric keyword

If you add any keyword as argument, it is matched to USER, Command, Docker by default.

console $ procs zsh

procs_zsh

Search by numeric keyword

If a numeric is used as the keyword, it is matched to PID, TCP, UDP by default. Numeric is treated as exact match, and non-numeric is treated as partial match by default.

console $ procs --or 6000 60000 60001 16723

procs_port

Note that procfs permissions only allow identifying listening ports for processes owned by the current user, so not all ports will show up unless run as root.

Logical operation of search keywords

If there are some keywords, logical operation between the keywords can be specified by commandline option.

The default operation can be specified by ~/.procs.toml. See [search] section.

Show Docker container name

If you have access permission to docker daemon ( unix:///var/run/docker.sock ), Docker column is added.

console $ procs growi

procs_docker

Note that procs gets the container information through UNIX domain socket, so Docker Toolbox on macOS ( doesn't use UNIX domain socket ) is not supported. Docker Desktop for Mac is supported but not tested.

Pager

If output lines exceed terminal height, pager is used automatically. This behavior and pager command can be specified by configuration file.

Watch mode

If --watch <second> option is used, procs automatically updates output like top. The update interval can be specified by the option argument.

Sort column

Column sort order can be changed by --sorta or --sortd option. The last charactor of --sorta and --sortd means sort order: "a"scending and "d"escending.

The column for sort is selected by the option keyword. The keyword is matched with column kind that is shonw by --list option. If --sorta cputime, column is sorted by CpuTime with ascending order. If --sortd rss, column is sorted by VmRss with decending order. The keyword is matched partially and case is ignored.

The default sort is specified by [sort] section in ~/.procs.toml

Insert column

--insert option inserts new column to the position of Slot column. The column for insert is selected by the option keyword. The keyword is the same as sort option. A Slot column can be used by a inserted column. If many insertion is required, many Slot should be added. Unused Slot is not shown.

Configuration

You can change configuration by ~/.procs.toml like below. The complete example of ~/.procs.toml can be generated by --config option.

```toml [[columns]] kind = "Pid" style = "BrightYellow" numericsearch = true nonnumericsearch = false

[[columns]] kind = "Username" style = "BrightGreen" numericsearch = false nonnumericsearch = true align = "Right"

[style] header = "BrightWhite" unit = "BrightWhite"

[style.bypercentage] color000 = "BrightBlue" color025 = "BrightGreen" color050 = "BrightYellow" color075 = "BrightRed" color100 = "BrightRed"

[style.bystate] colord = "BrightRed" colorr = "BrightGreen" colors = "BrightBlue" colort = "BrightCyan" colorz = "BrightMagenta" colorx = "BrightMagenta" colork = "BrightYellow" colorw = "BrightYellow" colorp = "BrightYellow"

[style.byunit] colork = "BrightBlue" colorm = "BrightGreen" colorg = "BrightYellow" colort = "BrightRed" colorp = "BrightRed" color_x = "BrightBlue"

[search] numericsearch = "Exact" nonnumericsearch = "Partial" logic = "And"

[display] showself = false cuttoterminal = true cuttopager = false cuttopipe = false colormode = "Auto"

[sort] column = 0 order = "Ascending"

[docker] path = "unix:///var/run/docker.sock"

[pager] mode = "Auto" ```

[[columns]] section

[[columns]] section defines which columns are used. The first [[columns]] is shown at left side, and the last is shown at right side.

| Key | Value | Default | Description | | ----------------- | ------------------- | ------- | ----------------------------------------------------------- | | kind | See kind list | | Column type | | style | See style list | | Column style | | numericsearch | true, false | false | Whether the column can be matched with numeric keywords | | nonnumericsearch | true, false | false | Whether the column can be matched with non-numeric keywords | | align | Left, Right, Center | Left | Text alignment |

kind list

| procs kind | ps STANDARD FORMAT | Description | Linux | macOS | | ------------ | --------------------- | -------------------------------- | ----- | ----- | | Command | args | Command with all arguments | o | o | | ContextSw | -not supported- | Context switch count | o | o | | CpuTime | cputime | Cumulative CPU time | o | o | | Docker | -not supported- | Docker container name | o | o | | Eip | eip | Instruction pointer | o | | | Esp | esp | Stack pointer | o | | | Gid | egid | Group ID | o | o | | GidFs | fgid | File system group ID | o | | | GidReal | rgid | Real group ID | o | o | | GidSaved | sgid | Saved group ID | o | o | | Group | egroup | Group name | o | o | | GroupFs | fgroup | File system group name | o | | | GroupReal | rgroup | Real group name | o | o | | GroupSaved | sgroup | Saved group name | o | o | | MajFlt | majflt | Major page fault count | o | o | | MinFlt | minflt | Minor page fault count | o | o | | Nice | ni | Nice value | o | o | | Pid | pid | Process ID | o | o | | Policy | policy | Scheduling policy | o | o | | Ppid | ppid | Parent process ID | o | o | | Priority | pri | Priority | o | o | | Processor | psr | Currently assigned processor | o | | | ReadBytes | -not supported- | Read bytes from storage | o | o | | RtPriority | rtprio | Real-time priority | o | | | Separator | -not supported- | Show \| for column separation | o | o | | ShdPnd | pending | Pending signal mask for process | o | | | Slot | -not supported- | Slot for --insert option | o | o | | SigBlk | blocked | Blocked signal mask | o | | | SigCgt | caught | Caught signal mask | o | | | SigIgn | ignored | Ignored signal mask | o | | | SigPnd | pending | Pending signal mask for thread | o | | | Ssb | -not supported- | Speculative store bypass status | o | | | StartTime | start_time | Starting time | o | o | | State | s | Process state | o | o | | TcpPort | -not supported- | Bound TCP ports | o | o | | Threads | nlwp | Thread count | o | o | | Tty | tty | Controlling TTY | o | o | | UdpPort | -not supported- | Bound UDP ports | o | o | | Uid | euid | User ID | o | o | | UidFs | fuid | File system user ID | o | | | UidReal | ruid | Real user ID | o | o | | UidSaved | suid | Saved user ID | o | o | | UsageCpu | %cpu | CPU utilization | o | o | | UsageMem | %mem | Memory utilization | o | o | | User | euser | User name | o | o | | UserFs | fuser | File system user name | o | | | UserReal | ruser | Real user name | o | o | | UserSaved | suser | Saved user name | o | o | | VmData | -not supported- | Data size | o | | | VmExe | trs | Text segments size | o | | | VmHwm | -not supported- | Peak resident set size | o | | | VmLib | -not supported- | Library code size | o | | | VmLock | -not supported- | Locked memory size | o | | | VmPeak | -not supported- | Peak virtual memory size | o | | | VmPin | -not supported- | Pinned memory size | o | | | VmPte | -not supported- | Page table entries size | o | | | VmRss | rss | Resident set size | o | o | | VmSize | vsz | Physical page size | o | o | | VmStack | -not supported- | Stack size | o | | | VmSwap | -not supported- | Swapped-out virtual memory size | o | | | Wchan | wchan | Process sleeping kernel function | o | | | WriteByte | -not supported- | Write bytes to storage | o | o |

style list

There are some special styles like ByPercentage, ByState, ByUnit. These are the styles for value-aware coloring. For example, if ByUnit is choosen, color can be specified for each unit of value ( like K, M, G,,, ). The colors can be configured in [style.by_unit] section.

[style] section

[style] section defines colors of header, unit and each styles. The available list of color is below.

| Subsection | Key | Value | Default | Description | | ------------- | --------- | ---------------- | ------------- | -------------------- | | | header | See color list | BrightWhite | Header color | | | unit | See color list | BrightWhite | Unit color | | bypercentage | color000 | See color list | BrightBlue | Color at 0% - 25% | | bypercentage | color025 | See color list | BrightGreen | Color at 25% - 50% | | bypercentage | color050 | See color list | BrightYellow | Color at 50% - 75% | | bypercentage | color075 | See color list | BrightRed | Color at 75% - 100% | | bypercentage | color100 | See color list | BrightRed | Color at 100% - | | bystate | colord | See color list | BrightRed | Color at D state | | bystate | colorr | See color list | BrightGreen | Color at R state | | bystate | colors | See color list | BrightBlue | Color at S state | | bystate | colort | See color list | BrightCyan | Color at T state | | bystate | colorz | See color list | BrightMagenta | Color at Z state | | bystate | colorx | See color list | BrightMagenta | Color at X state | | bystate | colork | See color list | BrightYellow | Color at K state | | bystate | colorw | See color list | BrightYellow | Color at W state | | bystate | colorp | See color list | BrightYellow | Color at P state | | byunit | colork | See color list | BrightBlue | Color at unit K | | byunit | colorm | See color list | BrightGreen | Color at unit M | | byunit | colorg | See color list | BrightYellow | Color at unit G | | byunit | colort | See color list | BrightRed | Color at unit T | | byunit | colorp | See color list | BrightRed | Color at unit P | | byunit | colorx | See color list | BrightBlue | Color at other unit |

color list

[search] section

[search] section defines option for Keyword search.

| Key | Value | Default | Description | | ----------------- | ------------------ | ------- | ------------------------------------------------------- | | numericsearch | Exact, Partial | Exact | Whether numeric keywords match exactly or partially | | nonnumericsearch | Exact, Partial | Partial | Whether non-numeric keywords match exactly or partially | | logic | And, Or, Nand, Nor | And | Logical operation between keywords |

[display] section

[display] section defines option for output display.

| Key | Value | Default | Description | | --------------- | --------------------- | ------- | ---------------------------------------------------------------------------- | | showself | true, false | false | Whether the self process ( procs ) is shown | | cuttoterminal | true, false | true | Whether output lines are truncated for output into terminal | | cuttopager | true, false | false | Whether output lines are truncated for output into pager | | cuttopipe | true, false | false | Whether output lines are truncated for output into pipe | | colormode | Auto, Always, Disable | Auto | The default behavior of output coloring without --color commandline option | | separator | [String] | │ | String used as Separator | | ascending | [String] | ▲ | Ascending sort indicator | | descending | [String] | ▼ | Descending sort indicator |

If color_mode is Auto, color is enabled for terminal and pager, disabled for pipe.

[sort] section

[sort] section defines the column used for sort and sort order.

| Key | Value | Default | Description | | ------ | --------------------- | --------- | ------------------------------- | | column | [Number] | 0 | Column number to used for sort | | order | Ascending, Descending | Ascending | Sort order |

If column is 0, value is sorted by the left column.

[docker] section

[docker] section defines how to communicate to docker daemon.

| Key | Value | Default | Description | | ---- | ------ | --------------------------- | ----------------------------------- | | path | [Path] | unix:///var/run/docker.sock | UNIX domain socket to docker daemon |

[pager] section

[pager] section defines the behavior of pager.

| Key | Value | Default | Description | | ------- | --------------------- | -------- | ------------------------------------------------------------------------ | | mode | Auto, Always, Disable | Auto | The default behavior of pager usage without --pager commandline option | | command | [Command] | less -SR | Pager command |

If mode is Auto, pager is used only when output lines exceed terminal height. Default pager is less -SR ( if less is not found, more -f ).