The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

Version 0.0.1

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 -> cpu_usage_per
%mem -> mem_usage_per
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

METHODS

new

Initiates the backend object.

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

- obj :: The OSLVM::Monitor object.

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)