1Sys::Statistics::Linux:U:sCepruSCtoanttsr(i3b)uted PerlSDyosc:u:mSetnattaitsitoincs::Linux::CpuStats(3)
2
3
4

NAME

6       Sys::Statistics::Linux::CpuStats - Collect linux cpu statistics.
7

SYNOPSIS

9           use Sys::Statistics::Linux::CpuStats;
10
11           my $lxs = Sys::Statistics::Linux::CpuStats->new;
12           $lxs->init;
13           sleep 1;
14           my $stats = $lxs->get;
15
16       Or
17
18           my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => $file);
19           $lxs->init;
20           my $stats = $lxs->get;
21

DESCRIPTION

23       Sys::Statistics::Linux::CpuStats gathers cpu statistics from the
24       virtual /proc filesystem (procfs).
25
26       For more information read the documentation of the front-end module
27       Sys::Statistics::Linux.
28

CPU STATISTICS

30       Generated by /proc/stat for each cpu (cpu0, cpu1 ...). cpu without a
31       number is the summary.
32
33           user    -  Percentage of CPU utilization at the user level.
34           nice    -  Percentage of CPU utilization at the user level with nice priority.
35           system  -  Percentage of CPU utilization at the system level.
36           idle    -  Percentage of time the CPU is in idle state.
37           total   -  Total percentage of CPU utilization.
38
39       Statistics with kernels >= 2.6.
40
41           iowait  -  Percentage of time the CPU is in idle state because an I/O operation
42                      is waiting to complete.
43           irq     -  Percentage of time the CPU is servicing interrupts.
44           softirq -  Percentage of time the CPU is servicing softirqs.
45           steal   -  Percentage of stolen CPU time, which is the time spent in other
46                      operating systems when running in a virtualized environment (>=2.6.11).
47

METHODS

49   new()
50       Call "new()" to create a new object.
51
52           my $lxs = Sys::Statistics::Linux::CpuStats->new;
53
54       Maybe you want to store/load the initial statistics to/from a file:
55
56           my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => '/tmp/cpustats.yml');
57
58       If you set "initfile" it's not necessary to call sleep before "get()".
59
60       It's also possible to set the path to the proc filesystem.
61
62            Sys::Statistics::Linux::CpuStats->new(
63               files => {
64                   # This is the default
65                   path => '/proc'
66                   stat => 'stat',
67               }
68           );
69
70   init()
71       Call "init()" to initialize the statistics.
72
73           $lxs->init;
74
75   get()
76       Call "get()" to get the statistics. "get()" returns the statistics as a
77       hash reference.
78
79           my $stats = $lxs->get;
80
81   raw()
82       Get raw values.
83

EXPORTS

85       No exports.
86

SEE ALSO

88       proc(5)
89

REPORTING BUGS

91       Please report all bugs to <jschulz.cpan(at)bloonix.de>.
92

AUTHOR

94       Jonny Schulz <jschulz.cpan(at)bloonix.de>.
95
97       Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved.
98
99       This program is free software; you can redistribute it and/or modify it
100       under the same terms as Perl itself.
101
102
103
104perl v5.34.0                      2022-01-21Sys::Statistics::Linux::CpuStats(3)
Impressum