ExmonLib

ExmonLib is an Elixir library that provides functionality to extract system metrics and monitoring data from the host system. It collects information about CPU, RAM, disks, filesystem, and uptime.

Compatible with Linux only.

Installation

The package can be installed by adding exmon_lib to your list of dependencies in mix.exs:

def deps do
  [
    {:exmon_lib, "~> 0.1.0"}
  ]
end

Usage

Basic Usage

To extract all system metrics at once:

# Get all metrics
metrics = ExmonLib.extract()

# The result is a map with hostname as key
%{
  "hostname" => %{
    cpu: %{...},
    ram: %{...},
    disks: %{...},
    fs: %{...},
    uptime: %{...}
  }
}

Accessing Specific Metrics

You can access specific metrics from the result:

metrics = ExmonLib.extract()
hostname = Map.keys(metrics) |> List.first()

# Get CPU metrics
cpu_metrics = metrics[hostname][:cpu]
cpu_usage_percent = cpu_metrics[:percent]

# Get RAM metrics
ram_metrics = metrics[hostname][:ram]
free_memory = ram_metrics[:free]
total_memory = ram_metrics[:total]

# Get disk metrics
disk_metrics = metrics[hostname][:disks]

# Get filesystem metrics
fs_metrics = metrics[hostname][:fs]

# Get uptime information
uptime_metrics = metrics[hostname][:uptime]

Available Metrics

CPU Metrics

The CPU metrics include:

RAM Metrics

Memory usage information including:

Disk Metrics

Physical disk statistics for each disk in the system.

Filesystem Metrics

Filesystem usage data for each mounted filesystem.

Uptime Metrics

System uptime information.

Requirements

Documentation

Documentation can be generated with ExDoc.

TODO