Sys::S...ocStats(3pm)

πŸ“¦
version 0.66 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Sys::Statistics::Linux::ProcStats β€” the manual, but make it cute πŸ’–

okay bestie, so this is Sys::S...ocStats(3pm) β€” a User Contributed Perl Documentation page, and it's literally the moment you finally learn how to get your Linux process stats without crying. i gotchu 🫢


✨ NAME ✨

Sys::Statistics::Linux::ProcStats β€” Collect linux process statistics.

like, it collects linux process statistics. that's the whole vibe. πŸ“


✨ SYNOPSIS ✨

use Sys::Statistics::Linux::ProcStats;

my $lxs = Sys::Statistics::Linux::ProcStats->new;
$lxs->init;
sleep 1;
my $stat = $lxs->get;

Or, if you're feeling fancy:

my $lxs = Sys::Statistics::Linux::ProcStats->new(initfile => $file);
$lxs->init;
my $stat = $lxs->get;

✨ DESCRIPTION ✨

So Sys::Statistics::Linux::ProcStats gathers process statistics from the virtual /proc filesystem (that's procfs, iykyk). πŸ’…

For more deets, go read the documentation of the front-end module Sys::Statistics::Linux. it's the main character, this one's the supporting bestie. πŸ‘‘


✨ IMPORTANT ✨

not me renaming things 😭 β€” the key procs_blocked got renamed to blocked! write that down bestie, it WILL matter.

✨ LOAD AVERAGE STATISTICS ✨

These are generated by /proc/stat and /proc/loadavg. iconic duo fr fr 🌈

  • new β€” Number of new processes that were produced per second.
  • runqueue β€” The number of currently executing kernel scheduling entities (processes, threads).
  • count β€” The number of kernel scheduling entities that currently exist on the system (processes, threads).
  • blocked β€” Number of processes blocked waiting for I/O to complete (Linux 2.5.45 onwards).
  • running β€” Number of processes in runnable state (Linux 2.5.45 onwards).

✨ METHODS ✨

🌸 new()

Call new() to create a new object. boom. you have a thing now. ✨

my $lxs = Sys::Statistics::Linux::ProcStats->new;

Maybe you want to store/load the initial statistics to/from a file? say less:

my $lxs = Sys::Statistics::Linux::ProcStats->new(initfile => '/tmp/procstats.yml');

If you set initfile it's not necessary to call sleep before get(). so you can just skip the nap, no biggie 😴❌

It's also possible to set the path to the proc filesystem:

Sys::Statistics::Linux::ProcStats->new(
   files => {
       # This is the default
       path    => '/proc',
       loadavg => 'loadavg',
       stat    => 'stat',
   }
);

🌸 init()

Call init() to initialize the statistics. it's giving setup era πŸ’…

$lxs->init;

🌸 get()

Call get() to get the statistics. get() returns the statistics as a hash reference. yes, a hash reference, hold it gently πŸŽ€

my $stat = $lxs->get;

🌸 raw()

Get raw values. just the raw, unfiltered truth. no cap. πŸ’€


✨ EXPORTS ✨

No exports. nothing. zero. not a single one. it's giving minimalist. πŸ™ˆ


✨ SEE ALSO ✨

proc(5) β€” go read that too, bestie, it's the source material. πŸ“š


✨ REPORTING BUGS ✨

Please report all bugs to <jschulz.cpan(at)bloonix.de>. found a bug? don't be shy, tell them, they wanna know 🫢


✨ AUTHOR ✨

Jonny Schulz <jschulz.cpan(at)bloonix.de>. the legend themselves πŸ‘‘


Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


okay and that's the whole page bestie, you ate that. πŸ’–βœ¨πŸŽ€πŸ¦‹

this was Sys::S...ocStats(3pm), straight from perl v5.36.0, dated 2022-11-19 β€” mwah, slay, periodt. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from