Skip to content

polyvariant/scala-monitor

Repository files navigation

scala-monitor

CLI utility that discovers running Scala/JVM-related processes (sbt, bloop, metals, scalac, scala-cli, mill, coursier, scalafmt, scalafix, etc.) and displays a formatted table with PID, type, memory usage (RSS/VSZ/SWAP), thread count, mem%, and project path.

Install

cs install --contrib scala-monitor
Alternative installation methods

Linux (x86_64 / aarch64):

ARCH=$(uname -m | sed 's/arm64/aarch64/') && curl -sL https://github.com/polyvariant/scala-monitor/releases/latest/download/scala-monitor-${ARCH}-pc-linux > scala-monitor && chmod +x scala-monitor && ./scala-monitor

macOS (Apple Silicon / Intel):

ARCH=$(uname -m | sed 's/arm64/aarch64/') && curl -sL https://github.com/polyvariant/scala-monitor/releases/latest/download/scala-monitor-${ARCH}-apple-darwin > scala-monitor && chmod +x scala-monitor && ./scala-monitor

Build from source:

scala-cli --power package . -o scala-monitor

Produces a scala-monitor native binary.

Run

scala-monitor

For a top-like live view that continuously refreshes the output every 0.1s, run under watch:

watch -n 0.1 scala-monitor

Experimental: scala-monitor --tui launches a built-in terminal UI for interactive monitoring.

Help

$ ./scala-monitor --help
run
  -f --filter <str>  Filter processes by key=value (repeatable). Keys: type, project. Use * as
                     wildcard for contains matching, case insensitive
  -o --output <str>  Output format: 'full' (table) or 'pid' (just PIDs)

Usage

./scala-monitor                          # full table (default)
./scala-monitor -o pid                   # only print PIDs
./scala-monitor --filter type=bloop      # filter by process type
./scala-monitor -f type=sbt -f project=*cats*  # multiple filters
./scala-monitor -f type=metals -o pid    # filter Metals processes, output PIDs only
./scala-monitor -f project=~/.local*     # filter by project path

Options

Flag Long Default Description
-o --output full Output format: full (table) or pid (PIDs only)
-f --filter Filter by key=value. Keys: type, project. Use * for wildcard (case insensitive). Repeatable.

Example output

$ ./scala-monitor
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  SCALA PROCESS MONITOR
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  PID      TYPE                RSS          VSZ       SWAP   MEM%   THR  PROJECT                                           
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  2513087  sbt              2.3 GB      23.5 GB       0 kB   7.3%    55  ~/Code/personal/smithy4s                          
  2503995  Metals           698 MB     158.3 GB       0 kB   2.2%    58  ~/Code/personal/scala-monitor                     
  2647652  Bloop            157 MB     384.1 GB       0 kB   0.5%    35  ~/.local/share/scalacli/bloop                     
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  TOTAL: 3 processes, 3.1 GB RSS, 565.9 GB VSZ
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

With flags

$ ./scala-monitor -o pid
2513087
2503995
2647652
$ ./scala-monitor -f type=metals
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  SCALA PROCESS MONITOR
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  PID      TYPE                RSS          VSZ       SWAP   MEM%   THR  PROJECT                                           
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  2503995  Metals           699 MB     158.3 GB       0 kB   2.2%    50  ~/Code/personal/scala-monitor                     
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  TOTAL: 1 processes, 699 MB RSS, 158.3 GB VSZ
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

$ ./scala-monitor -f type=metals -o pid
2503995

Requirements

  • Linux or macOS
  • For building from source: Scala CLI with Scala Native support

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors