1Sys::Statistics::Linux:U:sCeormpCiolnattriiobnu(t3e)d PeSryls:D:oSctuamteinsttaitciso:n:Linux::Compilation(3)
2
3
4

NAME

6       Sys::Statistics::Linux::Compilation - Statistics compilation.
7

SYNOPSIS

9           use Sys::Statistics::Linux;
10
11           my $lxs  = Sys::Statistics::Linux->new( loadavg => 1 );
12           my $stat = $lxs->get;
13
14           foreach my $key ($stat->loadavg) {
15               print $key, " ", $stat->loadavg($key), "\n";
16           }
17
18           # or
19
20           use Sys::Statistics::Linux::LoadAVG;
21           use Sys::Statistics::Linux::Compilation;
22
23           my $lxs  = Sys::Statistics::Linux::LoadAVG->new();
24           my $load = $lxs->get;
25           my $stat = Sys::Statistics::Linux::Compilation->new({ loadavg => $load });
26
27           foreach my $key ($stat->loadavg) {
28               print $key, " ", $stat->loadavg($key), "\n";
29           }
30
31           # or
32
33           foreach my $key ($stat->loadavg) {
34               print $key, " ", $stat->loadavg->{$key}, "\n";
35           }
36

DESCRIPTION

38       This module provides different methods to access and filter the
39       statistics compilation.
40

METHODS

42   new()
43       Create a new "Sys::Statistics::Linux::Compilation" object. This creator
44       is only useful if you don't call "get()" of "Sys::Statistics::Linux".
45       You can create a new object with:
46
47           my $lxs  = Sys::Statistics::Linux::LoadAVG->new();
48           my $load = $lxs->get;
49           my $stat = Sys::Statistics::Linux::Compilation->new({ loadavg => $load });
50
51   Statistic methods
52       sysinfo()
53       cpustats()
54       procstats()
55       memstats()
56       pgswstats()
57       netstats()
58       netinfo()
59           "netinfo()" provides raw data - no deltas.
60
61       sockstats()
62       diskstats()
63       diskusage()
64       loadavg()
65       filestats()
66       processes()
67
68       All methods returns the statistics as a hash reference in scalar
69       context. In list all methods returns the first level keys of the
70       statistics. Example:
71
72           my $net  = $stat->netstats;                 # netstats as a hash reference
73           my @dev  = $stat->netstats;                 # the devices eth0, eth1, ...
74           my $eth0 = $stat->netstats('eth0');         # eth0 statistics as a hash reference
75           my @keys = $stat->netstats('eth0');         # the statistic keys
76           my @vals = $stat->netstats('eth0', @keys);  # the values for the passed device and @keys
77           my $val  = $stat->netstats('eth0', $key);   # the value for the passed device and key
78
79       Sorted ...
80
81           my @dev  = sort $stat->netstats;
82           my @keys = sort $stat->netstats('eth0');
83
84   pstop()
85       This method is looking for top processes and returns a sorted list of
86       PIDs as an array or array reference depending on the context. It
87       expected two values: a key name and the number of top processes to
88       return.
89
90       As example you want to get the top 5 processes with the highest cpu
91       usage:
92
93           my @top5 = $stat->pstop( ttime => 5 );
94           # or as a reference
95           my $top5 = $stat->pstop( ttime => 5 );
96
97       If you want to get all processes:
98
99           my @top_all = $stat->pstop( ttime => $FALSE );
100           # or just
101           my @top_all = $stat->pstop( 'ttime' );
102
103   search(), psfind()
104       Both methods provides a simple scan engine to find special statistics.
105       Both methods except a filter as a hash reference. It's possible to pass
106       the statistics as second argument if the data is not stored in the
107       object.
108
109       The method "search()" scans for statistics and rebuilds the hash tree
110       until that keys that matched your filter and returns the hits as a hash
111       reference.
112
113           my $hits = $stat->search({
114               processes => {
115                   cmd   => qr/\[su\]/,
116                   owner => qr/root/
117               },
118               cpustats => {
119                   idle   => 'lt:10',
120                   iowait => 'gt:10'
121               },
122               diskusage => {
123                   '/dev/sda1' => {
124                       usageper => 'gt:80'
125                   }
126               }
127           });
128
129       This would return the following matches:
130
131           * processes with the command "[su]"
132           * processes with the owner "root"
133           * all cpu where "idle" is less than 50
134           * all cpu where "iowait" is grather than 10
135           * only disk '/dev/sda1' if "usageper" is grather than 80
136
137       The method "psfind()" scans for processes only and returns a array
138       reference with all process IDs that matched the filter. Example:
139
140           my $pids = $stat->psfind({ cmd => qr/init/, owner => 'eq:apache' });
141
142       This would return the following process ids:
143
144           * processes that matched the command "init"
145           * processes with the owner "apache"
146
147       There are different match operators available:
148
149           gt  -  grather than
150           lt  -  less than
151           eq  -  is equal
152           ne  -  is not equal
153
154       Notation examples:
155
156           gt:50
157           lt:50
158           eq:50
159           ne:50
160
161       Both argumnents have to be set as a hash reference.
162
163       Note: the operators < > = ! are not available any more. It's possible
164       that in further releases could be different changes for "search()" and
165       "psfind()". So please take a look to the documentation if you use it.
166

EXPORTS

168       No exports.
169

TODOS

171          * Are there any wishs from your side? Send me a mail!
172

REPORTING BUGS

174       Please report all bugs to <jschulz.cpan(at)bloonix.de>.
175

AUTHOR

177       Jonny Schulz <jschulz.cpan(at)bloonix.de>.
178
179       Thanks to Moritz Lenz for his suggestion for the name of this module.
180
182       Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved.
183
184       This program is free software; you can redistribute it and/or modify it
185       under the same terms as Perl itself.
186
187
188
189perl v5.36.0                      2022-07S-y2s2::Statistics::Linux::Compilation(3)
Impressum