README.md

# 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`:

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

## Usage

### Basic Usage

To extract all system metrics at once:

```elixir
# 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:

```elixir
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:
- `percent`: CPU usage percentage
- `user`, `nice`, `system`, `idle`, `iowait`, `irq`, `softirq`, `steal`: Raw CPU counters
- `load_1`, `load_5`, `load_15`: System load averages for 1, 5, and 15 minutes

### RAM Metrics

Memory usage information including:
- `total`: Total memory
- `free`: Free memory
- `used`: Used memory
- `buffers`, `cached`: Memory used for buffers and cache

### 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

- Elixir ~> 1.18
- Linux-based operating system (metrics are collected from `/proc` filesystem)

## Documentation

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc).

## TODO
- [ ] Tests
- [ ] Network stats
- [ ] Error handling
- [ ] Code cleaning