Sys::S...SwStats(3pm)
β¨ 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 π
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
- debian bookworm: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms