| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Linux::SysInfo; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
236988
|
use 5.006; |
|
|
4
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
21
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
85
|
|
|
6
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
176
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.15 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION; |
|
19
|
|
|
|
|
|
|
BEGIN { |
|
20
|
4
|
|
|
4
|
|
147
|
$VERSION = '0.15'; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Linux::SysInfo qw; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $si = sysinfo; |
|
28
|
|
|
|
|
|
|
print "$_: $si->{$_}\n" for keys %$si; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module is a wrapper around the C Linux system call. |
|
33
|
|
|
|
|
|
|
It gives information about the current uptime, load average, memory usage and processes running. |
|
34
|
|
|
|
|
|
|
Other systems have also this system call (e.g. Solaris), but in most cases the returned information is different. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 CONSTANTS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 C |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This constant is set to C<1> if your kernel supports the three extended fields C, C and C ; and to C<0> otherwise. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
BEGIN { |
|
47
|
4
|
|
|
4
|
|
20
|
require XSLoader; |
|
48
|
4
|
|
|
|
|
1763
|
XSLoader::load(__PACKAGE__, $VERSION); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 C |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This function takes no argument. |
|
54
|
|
|
|
|
|
|
It returns C on failure or a hash reference whose keys are the members name of the C on success : |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
C |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Seconds elapsed since the system booted. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
C, C, C |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1, 5 and 15 minutes load average. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
C |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Total usable main memory size. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
C |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Available memory size. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
C |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Amount of shared memory. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
C |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Memory used by buffers. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
C |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Total swap space size. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
C |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Swap space still available. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
C |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Number of current processes. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Prior to Linux 2.3.23 on i386 and 2.3.48 on all other architectures, the memory sizes were given in bytes. |
|
115
|
|
|
|
|
|
|
Since then, the following members are also available and all the memory sizes are given as multiples of C bytes : |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
C |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Total high memory size. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
C |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Available high memory size. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
C |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Memory unit size in bytes. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 EXPORT |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
The only function of this module, C, and the constant C are only exported on request. |
|
142
|
|
|
|
|
|
|
Functions are also exported by the C<:funcs> tag, and constants by C<:consts>. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
|
145
|
|
|
|
|
|
|
|
|
146
|
4
|
|
|
4
|
|
31
|
use base qw; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
679
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
our @EXPORT = (); |
|
149
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
150
|
|
|
|
|
|
|
'funcs' => [ qw ], |
|
151
|
|
|
|
|
|
|
'consts' => [ qw ] |
|
152
|
|
|
|
|
|
|
); |
|
153
|
|
|
|
|
|
|
our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; |
|
154
|
|
|
|
|
|
|
$EXPORT_TAGS{'all'} = [ @EXPORT_OK ]; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 BINARY COMPATIBILITY |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If you upgrade your kernel to a greater version than 2.3.23 on i386 or 2.3.48 on any other platform, you will need to rebuild the module to access the extended fields. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Moreover, since the perl hash function has changed after the 5.6 version, you will also need to recompile the module if you upgrade your perl from a version earlier than 5.6. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L 5.6. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
A C compiler. |
|
167
|
|
|
|
|
|
|
This module may happen to build with a C++ compiler as well, but don't rely on it, as no guarantee is made in this regard. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
The C man page. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L : Gather information about your system. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L : Try several different methods to retrieve the load average. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L : Wrapper to the C BSD system call. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 AUTHOR |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 BUGS |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
|
188
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 SUPPORT |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
perldoc Linux::SysInfo |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Copyright 2007,2008,2009,2010,2013,2017 Vincent Pit, all rights reserved. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
201
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; # End of Linux::SysInfo |