[ANN] TerminalSystemMonitor.jl: Displays usage of CPU, RAM, and optionally GPU

Introduction

This Julia package TerminalSystemMonitor.jl displays CPU and RAM usage information on your computer.

It should work on many platforms such as Windows, macOS and Linux (including RaspberryPi 4,5 with 64bit OS)
If necessary, you can display the usage of GPU resources.

Installation

julia> using Pkg; Pkg.add("TerminalSystemMonitor.jl")

Basic usage

julia> using TerminalSystemMonitor; monitor()

This should output like below:

╭───────────────────────╮╭───────────────────────╮╭───────────────────────╮
│      ┌               ┐││      ┌               ┐││      ┌               ┐│
│id:  0┤■■ 14           ││id:  4┤ 3              ││id:  8┤ 0              │
│id:  1┤■ 13            ││id:  5┤ 3              ││id:  9┤ 0              │
│id:  2┤■ 7.1           ││id:  6┤ 1              ││id: 10┤ 0              │
│id:  3┤■ 6.9           ││id:  7┤ 0              ││id: 11┤ 0              │
│      └               ┘││      └               ┘││      └               ┘│
╰───────────────────────╯╰───────────────────────╯╰───────────────────────╯
╭──────────────────────────────────────────────╮
│     ┌                              ┐         │
│Mem: ┤■■■■■■■■■■■■■■■■■■■ 84.985      96.0 GiB│
│     └                              ┘         │
│      Load average: 1.46 1.81 2.09            │
│      Uptime: 13 days, 21:30:29

If the width of your terminal is small (i.e., displaysize(stdout)[1] is small), our package TerminalSystemMonitor.jl
will try adjust the layout graphs displaying CPU usage:

╭───────────────────────╮
│      ┌               ┐│
│id:  0┤■■ 22.2         │
│id:  1┤■■ 19           │
│id:  2┤■ 15            │
│id:  3┤■ 10            │
│      └               ┘│
╰───────────────────────╯
╭───────────────────────╮
│      ┌               ┐│
│id:  4┤ 0              │
│id:  5┤ 0              │
│id:  6┤ 0              │
│id:  7┤ 0              │
│      └               ┘│
╰───────────────────────╯
╭───────────────────────╮
│      ┌               ┐│
│id:  8┤■ 8             │
│id:  9┤ 1              │
│id: 10┤ 1              │
│id: 11┤ 0              │
│      └               ┘│
╰───────────────────────╯
╭────────────────────────────────────────────╮
│     ┌                              ┐       │
│                                            │
│Mem: ┤■■■■■■■■■■■■■■■■■■■ 84.826            │
│96.0 GiB                                    │
│     └                              ┘       │
│                                            │
│      Load average: 1.72 1.8 2.06           │
│      Uptime: 13 days, 21:31:54             │

Monitoring GPU usage

The TerminalSystemMonitor.jl uses Package Extensions feature. See

https://www.youtube.com/watch?v=TiIZlQhFzyk to learn more.

We need to load some auxiliary packages before calling TerminalSystemMonitor.monitor.

NVIDIA GPU

If your computer has several NVIDIA’s GPU, try the following Julia command:

julia> using CUDA; using TerminalSystemMonitor; monitor()

Mac computers with Apple silicon

If your computer is a Apple M-series device, so called computers with Apple silicon, try the following Julia command:

julia> using MacOSIOReport; using TerminalSystemMonitor; monitor()

The MacOSIOReport.jl can be found at GitHub - AtelierArith/MacOSIOReport.jl: Porting macmon project to Julia using ObjectiveC.jl. I ported the vladkens/macmon project to Julia for TerminalSystemMonitor. I hope you like this package.

百聞は一見に如かず(Seeing is believing.) Give it try!

50 Likes

Awesome! Really cool to see a seemless way to monitur both CPU, RAM and GPU all from within a Julia process :heart:

2 Likes

Have you looked in the new “app packaging” capabilities that Pkg provides? You can now ship applications, not just libraries with Pkg. It would be interesting to have this available in that manner.

8 Likes

I’m curious about this, but I’m not sure where in the docs for Pkg.jl it might be. Do you have a link to some docs for this feature?

It will be out in 1.12, it is in the dev version of the docs: ?. Apps · Pkg.jl

3 Likes

nice! i would suggest orienting the CPU bars vertically, instead of having three separate plots you could then just have one that spans the entire width.

This package is very useful in terms of functionality, but there are some problems with the display. I guess you’re probably using the clear screen command every second, and the actual display screen of the derivative keeps flickering (vscode+julia REPL).

I’ve seen a better way to do this, which is to just move the cursor to the specified position and overwrite the output, as shown in Term.jl/src/progress.jl at master · FedeClaudi/Term.jl · GitHub.

The package’s idea of implementing progress bars is also suitable for your system monitor:

Progress bars displays are updated in the background while your code executes. This is done by having the display rendering code run on a separate thread.

3 Likes