NAME

OSLV::Monitor::Backends::cgroups - Backend for Linux cgroups.

VERSION

Version 1.0.2

SYNOPSIS

use OSLV::Monitor::Backends::cgroups;

my $backend = OSLV::Monitor::Backends::cgroups->new;

my $usable=$backend->usable;
if ( $usable ){
    $return_hash_ref=$backend->run;
}

The cgroup to name mapping is done like below.

systemd -> s_$name
user -> u_$name
docker -> d_$name
podman -> p_$name
anything else -> $name

Anything else is formed like below.

	$cgroup =~ s/^0\:\:\///;
    $cgroup =~ s/\/.*//;

The following ps to stats mapping are as below.

%cpu -> percent-cpu
%mem -> percent-memory
rss -> rss
vsize -> virtual-size
trs -> text-size
drs -> data-size
size -> size

"procs" is a total number of procs in that cgroup.

The rest of the values are pulled from the following files with the names kept as is.

cpu.stat
io.stat
memory.stat

The following mappings are done though.

pgfault -> minor-faults
pgmajfault -> major-faults
usage_usec -> cpu-time
system_usec -> system-time
user_usec -> user-time
throttled_usec -> throttled-time
burst_usec -> burst-time

METHODS

new

Initiates the backend object.

my $backend=OSLV::MOnitor::Backend::cgroups->new(obj=>$obj)

- base_dir :: Path to use for the base dir, where the proc/cgroup
        cache, linux_cache.json, is is created.
    Default :: /var/cache/oslv_monitor

- obj :: The OSLVM::Monitor object.

- time_divider :: What to use for "usec" to sec conversion. While normally
          the usec counters are microseconds, sometimes the value is in
          nanoseconds, despit the name.
    Default :: 1000000

run

$return_hash_ref=$backend->run(obj=>$obj);

usable

Dies if not usable.

eval{ $backend->usable; };
if ( $@ ){
    print 'Not usable because... '.$@."\n";
}

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-oslv-monitor at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=OSLV-Monitor. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc OSLV::Monitor

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by Zane C. Bowers-Hadley.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)