Apero.OS (Apero v1.0.0)

Copy Markdown View Source

Operating system information utilities for Apero.

Provides a unified interface for querying system metadata regardless of the underlying platform (Linux, macOS, Windows).

Example

iex> info = Apero.OS.info()
iex> info.type in [:linux, :macos, :windows, :unknown]
true

Summary

Functions

Returns the CPU architecture of the current machine.

Returns true if running inside a container (Docker, Podman, LXC).

Returns the number of logical CPU cores available to the OS.

Returns the distribution name on Linux (reads /etc/os-release), "macOS" on Darwin, or "Windows" on win32.

Returns the machine hostname.

Returns a consolidated map of system information.

Returns the OS kernel version string, or "unknown" if unavailable.

Returns true if the current process is running as root / Administrator.

Returns the total system RAM in megabytes, or 0 if unavailable.

Returns the operating system type.

Returns true if running under WSL (Windows Subsystem for Linux).

Types

arch()

@type arch() :: :x86_64 | :arm64 | :arm | :i386 | :unknown

os_type()

@type os_type() :: :linux | :macos | :windows | :unknown

Functions

arch()

@spec arch() :: arch()

Returns the CPU architecture of the current machine.

Possible values: :x86_64, :arm64, :arm, :i386, :unknown.

container?()

@spec container?() :: boolean()

Returns true if running inside a container (Docker, Podman, LXC).

cpu_count()

@spec cpu_count() :: pos_integer()

Returns the number of logical CPU cores available to the OS.

distro()

@spec distro() :: binary()

Returns the distribution name on Linux (reads /etc/os-release), "macOS" on Darwin, or "Windows" on win32.

hostname()

@spec hostname() :: binary()

Returns the machine hostname.

info()

@spec info() :: map()

Returns a consolidated map of system information.

Keys: :type, :arch, :hostname, :distro, :kernel_version, :cpu_count, :total_memory_mb.

kernel_version()

@spec kernel_version() :: binary()

Returns the OS kernel version string, or "unknown" if unavailable.

root?()

@spec root?() :: boolean()

Returns true if the current process is running as root / Administrator.

total_memory_mb()

@spec total_memory_mb() :: non_neg_integer()

Returns the total system RAM in megabytes, or 0 if unavailable.

type()

@spec type() :: os_type()

Returns the operating system type.

Possible values: :linux, :macos, :windows, :unknown.

wsl?()

@spec wsl?() :: boolean()

Returns true if running under WSL (Windows Subsystem for Linux).