.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Sys::Statistics::Linux::Processes 3pm" .TH Sys::Statistics::Linux::Processes 3pm "2019-03-21" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Sys::Statistics::Linux::Processes \- Collect linux process statistics. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Sys::Statistics::Linux::Processes; \& \& my $lxs = Sys::Statistics::Linux::Processes\->new; \& # or Sys::Statistics::Linux::Processes\->new(pids => \e@pids) \& \& $lxs\->init; \& sleep 1; \& my $stat = $lxs\->get; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Sys::Statistics::Linux::Processes gathers process information from the virtual \&\fI/proc\fR filesystem (procfs). .PP For more information read the documentation of the front-end module Sys::Statistics::Linux. .SH "PROCESS STATISTICS" .IX Header "PROCESS STATISTICS" Generated by \fI/proc//stat\fR, \fI/proc//status\fR, \&\fI/proc//cmdline\fR and \fI\f(BIgetpwuid()\fI\fR. .PP Note that if \fI/etc/passwd\fR isn't readable, the key owner is set to \fIN/a\fR. .PP .Vb 10 \& 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. \& 0 is standard input, 1 standard output, 2 standard error, etc. Because only the owner or root \& can read /proc//fd this hash could be empty. \& cmd \- Command of the process. \& cmdline \- Command line of the process. .Ve .PP Generated by \fI/proc//statm\fR. All statistics provides information about memory in pages: .PP .Vb 7 \& 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). .Ve .PP It's possible to convert pages to bytes or kilobytes. Example \- if the pagesize of your system is 4kb: .PP .Vb 3 \& $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); .Ve .PP Generated by \fI/proc//io\fR. .PP .Vb 7 \& 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. .Ve .PP See Documentation/filesystems/proc.txt for more (from kernel 2.6.20) .SH "METHODS" .IX Header "METHODS" .SS "\fBnew()\fP" .IX Subsection "new()" Call \f(CW\*(C`new()\*(C'\fR to create a new object. .PP .Vb 1 \& my $lxs = Sys::Statistics::Linux::Processes\->new; .Ve .PP It's possible to handoff an array reference with a \s-1PID\s0 list. .PP .Vb 1 \& my $lxs = Sys::Statistics::Linux::Processes\->new(pids => [ 1, 2, 3 ]); .Ve .PP It's also possible to set the path to the proc filesystem. .PP .Vb 10 \& Sys::Statistics::Linux::Processes\->new( \& files => { \& # This is the default \& path => \*(Aq/proc\*(Aq, \& uptime => \*(Aquptime\*(Aq, \& stat => \*(Aqstat\*(Aq, \& statm => \*(Aqstatm\*(Aq, \& status => \*(Aqstatus\*(Aq, \& cmdline => \*(Aqcmdline\*(Aq, \& wchan => \*(Aqwchan\*(Aq, \& fd => \*(Aqfd\*(Aq, \& io => \*(Aqio\*(Aq, \& } \& ); .Ve .SS "\fBinit()\fP" .IX Subsection "init()" Call \f(CW\*(C`init()\*(C'\fR to initialize the statistics. .PP .Vb 1 \& $lxs\->init; .Ve .SS "\fBget()\fP" .IX Subsection "get()" Call \f(CW\*(C`get()\*(C'\fR to get the statistics. \f(CW\*(C`get()\*(C'\fR returns the statistics as a hash reference. .PP .Vb 1 \& my $stat = $lxs\->get; .Ve .PP Note: .PP Processes that were created between the call of \fBinit()\fR and \fBget()\fR 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. .SS "\fBraw()\fP" .IX Subsection "raw()" Get raw values. .SH "EXPORTS" .IX Header "EXPORTS" No exports. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fB\fBproc\fB\|(5)\fR .PP \&\fBperldoc \-f getpwuid\fR .SH "REPORTING BUGS" .IX Header "REPORTING BUGS" Please report all bugs to . .SH "AUTHOR" .IX Header "AUTHOR" Jonny Schulz . .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.