Sys::S...ocesses(3pm)
π NAME π
Sys::Statistics::Linux::Processes β bestie, it collects linux process statistics. that's the whole assignment. π
β¨ SYNOPSIS β¨
use Sys::Statistics::Linux::Processes;
my $lxs = Sys::Statistics::Linux::Processes->new;
# or Sys::Statistics::Linux::Processes->new(pids => \@pids)
$lxs->init;
sleep 1;
my $stat = $lxs->get;
π¦ DESCRIPTION π¦
okay so Sys::Statistics::Linux::Processes gathers process info straight out of the virtual /proc filesystem (procfs). that's it. that's the gig. π«Ά
want the full lore? go read the documentation of the front-end module Sys::Statistics::Linux. it's giving main character energy, fr.
π PROCESS STATISTICS π
πΈ generated by /proc/<pid>/stat, /proc/<pid>/status, /proc/<pid>/cmdline and getpwuid()
heads up bestie: if/etc/passwdisn't readable, the keyownergets set toN/a. no cap. π
ppidβ the parent process ID of the process.nlwpβ the number of light weight processes that runs by this process.ownerβ the owner name of the process.pgrpβ the group ID of the process.stateβ the status of the process.sessionβ the session ID of the process.ttynrβ the tty the process use.minfltβ the number of minor faults the process made.cminfltβ the number of minor faults the child process made.mayfltβ the number of mayor faults the process made.cmayfltβ the number of mayor faults the child process made.stimeβ the number of jiffies the process have beed scheduled in kernel mode.utimeβ the number of jiffies the process have beed scheduled in user mode.ttimeβ the number of jiffies the process have beed scheduled (user + kernel).cstimeβ the number of jiffies the process waited for childrens have been scheduled in kernel mode.cutimeβ the number of jiffies the process waited for childrens have been scheduled in user mode.priorβ the priority of the process (+15).niceβ the nice level of the process.sttimeβ the time in jiffies the process started after system boot.actimeβ the time in D:H:M:S (days, hours, minutes, seconds) the process is active.vsizeβ the size of virtual memory of the process.nswapβ the size of swap space of the process.cnswapβ the size of swap space of the childrens of the process.cpuβ the CPU number the process was last executed on.wchanβ the "channel" in which the process is waiting.fdβ this is a subhash containing each file which the process has open, named by its file descriptor.0is standard input,1standard output,2standard error, etc. Because only the owner or root can read/proc/<pid>/fdthis hash could be empty.cmdβ command of the process.cmdlineβ command line of the process.
π§ generated by /proc/<pid>/statm
all these stats are giving memory info, in pages:
sizeβ the total program size of the process.residentβ number of resident set size, this includes the text, data and stack space.shareβ total size of shared pages of the process.trsβ total text size of the process.drsβ total data/stack size of the process.lrsβ total library size of the process.dtpβ total size of dirty pages of the process (unused since kernel 2.6).
and guess what β you can convert pages to bytes or kilobytes. example: if the pagesize of your system is 4kb, then:
$Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 0; # pages (default)
$Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4; # convert to kilobytes
$Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4096; # convert to bytes
# or with
Sys::Statistics::Linux::Processes->new(pages_to_bytes => 4096);
π generated by /proc/<pid>/io
rcharβ bytes read from storage (might have been from pagecache).wcharβ bytes written.syscrβ number of read syscalls.syscwβ numner of write syscalls.read_bytesβ bytes really fetched from storage layer.write_bytesβ bytes sent to the storage layer.cancelled_write_bytesβ refer to docs.
See Documentation/filesystems/proc.txt for more (from kernel 2.6.20). iykyk π
π METHODS π
π new()
call new() to create a new object. iconic.
my $lxs = Sys::Statistics::Linux::Processes->new;
it's possible to handoff an array reference with a PID list. yes queen, filter away:
my $lxs = Sys::Statistics::Linux::Processes->new(pids => [ 1, 2, 3 ]);
it's also possible to set the path to the proc filesystem:
Sys::Statistics::Linux::Processes->new(
files => {
# This is the default
path => '/proc',
uptime => 'uptime',
stat => 'stat',
statm => 'statm',
status => 'status',
cmdline => 'cmdline',
wchan => 'wchan',
fd => 'fd',
io => 'io',
}
);
π init()
call init() to initialize the statistics. gotta set the stage before the show, bestie.
$lxs->init;
π get()
call get() to get the statistics. get() returns the statistics as a hash reference. slay.
my $stat = $lxs->get;
note:
processes that were created between the call of init() and get() are returned as well, but the keys minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime are set to the value 0.00 because there are no inititial values to calculate the deltas. π no history = no delta, that's just math.
π raw()
get raw values. untouched, unfiltered, raw. π₯
π EXPORTS π
no exports. nothing. zero. the way that it just doesn't export anything... periodt. π
β SEE ALSO β
proc(5)perldoc -f getpwuid
π REPORTING BUGS π
please report all bugs to <jschulz.cpan(at)bloonix.de>. she's listening, don't be shy. π¬
π 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.
and that's the whole page bestie π this little doc came from the User Contributed Perl Documentation section, generated under perl v5.36.0 on 2022-11-19 β go forth and read your /proc like the icon you are. π¦β¨
π¦ 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