gleam_os_mon

Package Version Hex Docs

A rather minimal wrapper around the functions found in os_mon.

It probably goes without saying, but this functionality is only available when runnning on BEAM.

Quick start

import gleam/os_mon
import gleam/os_mon/cpu
import gleam/os_mon/disk
import gleam/os_mon/mem
import gleam/io

pub fn main() {
  assert Ok(_) = os_mon.start()

  #("avg1", cpu.average_1())
  |> io.debug

  #("memory (GiB)", mem.get_system_memory_data().total / 1024 / 1024 / 1024)
  |> io.debug

  #("disk", disk.get_disk_data())
  |> io.debug
}

This will output something like:

#("avg1", 79)
#("memory (GB)", 125)
#("disk", //erl(#{
  "/" => {disk,"/",520187392,68},
  "/big" => {disk,"/big",20214949760,44},
  "/boot" => {disk,"/boot",522984,38},
  "/dev" => {disk,"/dev",6591368,0},
  "/dev/shm" => {disk,"/dev/shm",65913676,3},
  "/home" => {disk,"/home",405588736,59},
  "/mnt" => {disk,"/mnt",166689536,1},
  "/run" => {disk,"/run",32956840,1},
  "/run/user/1000" => {disk,"/run/user/1000",13182732,1},
  "/run/wrappers" => {disk,"/run/wrappers",65913672,1}}))

Installation

This package can be added to your Gleam project:

gleam add gleam_os_mon

Development

gleam test  # Run the tests
gleam shell # Run an Erlang shell

TODO

Most basic things are implemented, but os_sup and nteventlog are more Windows specific, so I’m not going to work on them myself. PRs are welcome though.

Search Document