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

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

✨ NAME ✨

Sys::Statistics::Linux::PgSwStats β€” bestie, this one collects your Linux paging and swapping statistics πŸ’– (and yes, that's the whole Sys::S...SwStats(3pm) situation β€” she's a Perl module, she's from the User Contributed Perl Documentation collection, and she's here to spill the tea on your pages).


🌸 SYNOPSIS 🌸

Okay so here's the vibe, copy-paste and go:

use Sys::Statistics::Linux::PgSwStats;

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

Or, if you already saved your init stats somewhere and wanna skip the whole waiting thing:

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Sys::Statistics::Linux::PgSwStats gathers paging and swapping statistics from the virtual /proc filesystem (procfs). That's it, that's the job, and she does it flawlessly πŸ’…

For more info, go read the documentation of the front-end module Sys::Statistics::Linux. She's the main character, this one's her supporting cast 🫢


πŸ‘‘ PAGING AND SWAPPING STATISTICS πŸ‘‘

These are generated by /proc/stat or /proc/vmstat. Slay.

  • pgpgin β€” Number of pages the system has paged in from disk per second.
  • pgpgout β€” Number of pages the system has paged out to disk per second.
  • pswpin β€” Number of pages the system has swapped in from disk per second.
  • pswpout β€” Number of pages the system has swapped out to disk per second.

Now the plot twist 😭 the following statistics are only available by kernels from 2.6:

  • pgfault β€” Number of page faults the system has made per second (minor + major).
  • pgmajfault β€” Number of major faults per second the system required loading a memory page from disk.

πŸ’œ METHODS πŸ’œ

🌈 new()

Call new() to create a new object. Iconic behaviour, truly.

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

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

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

If you set initfile it's not necessary to call sleep before get(). No cap, you just skip the nap πŸ’€

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

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

⭐ init()

Call init() to initialize the statistics.

$lxs->init;

πŸ’– get()

Call get() to get the statistics. get() returns the statistics as a hash reference.

my $stat = $lxs->get;

πŸŽ€ raw()

Get raw values. That's the whole thing, she's lowkey mysterious like that πŸ™ˆ


✨ EXPORTS ✨

No exports. Nothing. Zero. Empty. She gives nothing away for free πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


😭 REPORTING BUGS 😭

Please report all bugs to <jschulz.cpan(at)bloonix.de>. Bestie, be nice about it, fr fr 🫢


🌸 AUTHOR 🌸

Jonny Schulz <jschulz.cpan(at)bloonix.de>.


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 that's the whole page, you ate that πŸ“

And that's a wrap, bestie β€” this gem is from perl v5.36.0, dated 2022-11-19, and it's giving legendary documentation energy πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from