1Sys::Statistics::Linux:U:sPerrocCeosnstersi(b3u)ted PerlSyDso:c:uSmteanttiasttiiocns::Linux::Processes(3)
2
3
4

NAME

6       Sys::Statistics::Linux::Processes - Collect linux process statistics.
7

SYNOPSIS

9           use Sys::Statistics::Linux::Processes;
10
11           my $lxs = Sys::Statistics::Linux::Processes->new;
12           # or Sys::Statistics::Linux::Processes->new(pids => \@pids)
13
14           $lxs->init;
15           sleep 1;
16           my $stat = $lxs->get;
17

DESCRIPTION

19       Sys::Statistics::Linux::Processes gathers process information from the
20       virtual /proc filesystem (procfs).
21
22       For more information read the documentation of the front-end module
23       Sys::Statistics::Linux.
24

PROCESS STATISTICS

26       Generated by /proc/<pid>/stat, /proc/<pid>/status, /proc/<pid>/cmdline
27       and getpwuid().
28
29       Note that if /etc/passwd isn't readable, the key owner is set to N/a.
30
31           ppid      -  The parent process ID of the process.
32           nlwp      -  The number of light weight processes that runs by this process.
33           owner     -  The owner name of the process.
34           pgrp      -  The group ID of the process.
35           state     -  The status of the process.
36           session   -  The session ID of the process.
37           ttynr     -  The tty the process use.
38           minflt    -  The number of minor faults the process made.
39           cminflt   -  The number of minor faults the child process made.
40           mayflt    -  The number of mayor faults the process made.
41           cmayflt   -  The number of mayor faults the child process made.
42           stime     -  The number of jiffies the process have beed scheduled in kernel mode.
43           utime     -  The number of jiffies the process have beed scheduled in user mode.
44           ttime     -  The number of jiffies the process have beed scheduled (user + kernel).
45           cstime    -  The number of jiffies the process waited for childrens have been scheduled in kernel mode.
46           cutime    -  The number of jiffies the process waited for childrens have been scheduled in user mode.
47           prior     -  The priority of the process (+15).
48           nice      -  The nice level of the process.
49           sttime    -  The time in jiffies the process started after system boot.
50           actime    -  The time in D:H:M:S (days, hours, minutes, seconds) the process is active.
51           vsize     -  The size of virtual memory of the process.
52           nswap     -  The size of swap space of the process.
53           cnswap    -  The size of swap space of the childrens of the process.
54           cpu       -  The CPU number the process was last executed on.
55           wchan     -  The "channel" in which the process is waiting.
56           fd        -  This is a subhash containing each file which the process has open, named by its file descriptor.
57                        0 is standard input, 1 standard output, 2 standard error, etc. Because only the owner or root
58                        can read /proc/<pid>/fd this hash could be empty.
59           cmd       -  Command of the process.
60           cmdline   -  Command line of the process.
61
62       Generated by /proc/<pid>/statm. All statistics provides information
63       about memory in pages:
64
65           size      -  The total program size of the process.
66           resident  -  Number of resident set size, this includes the text, data and stack space.
67           share     -  Total size of shared pages of the process.
68           trs       -  Total text size of the process.
69           drs       -  Total data/stack size of the process.
70           lrs       -  Total library size of the process.
71           dtp       -  Total size of dirty pages of the process (unused since kernel 2.6).
72
73       It's possible to convert pages to bytes or kilobytes. Example - if the
74       pagesize of your system is 4kb:
75
76           $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES =    0; # pages (default)
77           $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES =    4; # convert to kilobytes
78           $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4096; # convert to bytes
79
80           # or with
81           Sys::Statistics::Linux::Processes->new(pages_to_bytes => 4096);
82
83       Generated by /proc/<pid>/io.
84
85           rchar                 -  Bytes read from storage (might have been from pagecache).
86           wchar                 -  Bytes written.
87           syscr                 -  Number of read syscalls.
88           syscw                 -  Numner of write syscalls.
89           read_bytes            -  Bytes really fetched from storage layer.
90           write_bytes           -  Bytes sent to the storage layer.
91           cancelled_write_bytes -  Refer to docs.
92
93       See Documentation/filesystems/proc.txt for more (from kernel 2.6.20)
94

METHODS

96   new()
97       Call "new()" to create a new object.
98
99           my $lxs = Sys::Statistics::Linux::Processes->new;
100
101       It's possible to handoff an array reference with a PID list.
102
103           my $lxs = Sys::Statistics::Linux::Processes->new(pids => [ 1, 2, 3 ]);
104
105       It's also possible to set the path to the proc filesystem.
106
107            Sys::Statistics::Linux::Processes->new(
108               files => {
109                   # This is the default
110                   path    => '/proc',
111                   uptime  => 'uptime',
112                   stat    => 'stat',
113                   statm   => 'statm',
114                   status  => 'status',
115                   cmdline => 'cmdline',
116                   wchan   => 'wchan',
117                   fd      => 'fd',
118                   io      => 'io',
119               }
120           );
121
122   init()
123       Call "init()" to initialize the statistics.
124
125           $lxs->init;
126
127   get()
128       Call "get()" to get the statistics. "get()" returns the statistics as a
129       hash reference.
130
131           my $stat = $lxs->get;
132
133       Note:
134
135       Processes that were created between the call of init() and get() are
136       returned as well, but the keys minflt, cminflt, mayflt, cmayflt, utime,
137       stime, cutime, and cstime are set to the value 0.00 because there are
138       no inititial values to calculate the deltas.
139
140   raw()
141       Get raw values.
142

EXPORTS

144       No exports.
145

SEE ALSO

147       proc(5)
148
149       perldoc -f getpwuid
150

REPORTING BUGS

152       Please report all bugs to <jschulz.cpan(at)bloonix.de>.
153

AUTHOR

155       Jonny Schulz <jschulz.cpan(at)bloonix.de>.
156
158       Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved.
159
160       This program is free software; you can redistribute it and/or modify it
161       under the same terms as Perl itself.
162
163
164
165perl v5.28.1                      2019-02-0S2ys::Statistics::Linux::Processes(3)
Impressum