Sys::Monitor::Lite

A lightweight system monitoring toolkit. Using the script/sys-monitor-lite script you can collect CPU, memory, disk, network, and other Linux metrics in JSON format. It runs entirely on Perl with no external dependencies.

Features

Installation

To install from CPAN:

cpanm Sys::Monitor::Lite

To use it directly from the repository:

git clone https://github.com/yourname/sys-monitor-lite.git
cd sys-monitor-lite
perl Makefile.PL && make install

You can also run the scripts in the repository directly without installing.

Usage (Command Line)

Collect metrics once

script/sys-monitor-lite --once

Collect continuously at 5-second intervals (default)

script/sys-monitor-lite --interval 5

Limit the metrics collected and output as JSON Lines

script/sys-monitor-lite --interval 10 --collect cpu,mem,disk --output jsonl

Key options

| Option | Description | | ----------- | ---- | | --interval <seconds> | Interval for repeated collection. Defaults to 5 seconds. Values ≤ 0 collect only once. | | --once | Collects metrics once. Equivalent to omitting --interval. | | --collect <list> | Comma-separated list selecting from system,cpu,load,mem,disk,net. | | --output <format> | Choose json (default) or jsonl. | | --pretty | Format JSON output (jsonl ignores this). | | --help | Show help (POD). |

The JSON output can be combined with tools such as jq or jq-lite.

script/sys-monitor-lite --once | jq '.mem.used_pct'

Using as a Perl Module

use Sys::Monitor::Lite qw(collect_all to_json);

my $metrics = collect_all();
print to_json($metrics, pretty => 1);

Instead of collect_all, you can pass an array reference like collect(["cpu", "mem"]) to specify which metrics to gather.

Available Data

License

MIT License

Author

Shingo Kawamura (@kawamurashingo)