1 package Linux::SysInfo;
10 Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call.
25 use Linux::SysInfo qw/sysinfo/;
28 print "$_: $si->{$_}\n" for keys %$si;
32 This module is a wrapper around the C<sysinfo(2)> 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.
38 =head2 C<LS_HAS_EXTENDED>
40 This constant is set to C<1> if your kernel supports the three extended fields C<totalhigh>, C<freehigh> and C<mem_unit> ; and to C<0> otherwise.
48 XSLoader::load(__PACKAGE__, $VERSION);
53 This function takes no argument.
54 It returns C<undef> on failure or a hash reference whose keys are the members name of the C<struct sysinfo> on success :
62 Seconds elapsed since the system booted.
66 C<load1>, C<load5>, C<load15>
68 1, 5 and 15 minutes load average.
74 Total usable main memory size.
80 Available memory size.
86 Amount of shared memory.
92 Memory used by buffers.
98 Total swap space size.
104 Swap space still available.
110 Number of current processes.
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<mem_unit> bytes :
123 Total high memory size.
129 Available high memory size.
135 Memory unit size in bytes.
141 The only function of this module, C<sysinfo>, and the constant C<LS_HAS_EXTENDED> are only exported on request.
142 Functions are also exported by the C<:funcs> tag, and constants by C<:consts>.
146 use base qw/Exporter/;
150 'funcs' => [ qw/sysinfo/ ],
151 'consts' => [ qw/LS_HAS_EXTENDED/ ]
153 our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
154 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
156 =head1 BINARY COMPATIBILITY
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.
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.
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.
171 The C<sysinfo(2)> man page.
173 L<Sys::Info> : Gather information about your system.
175 L<Sys::CpuLoad> : Try several different methods to retrieve the load average.
177 L<BSD::getloadavg> : Wrapper to the C<getloadavg(3)> BSD system call.
181 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
183 You can contact me by mail or on C<irc.perl.org> (vincent).
187 Please report any bugs or feature requests to C<bug-linux-sysinfo at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-SysInfo>.
188 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
192 You can find documentation for this module with the perldoc command.
194 perldoc Linux::SysInfo
196 Tests code coverage report is available at L<http://www.profvince.com/perl/cover/Linux-SysInfo>.
198 =head1 COPYRIGHT & LICENSE
200 Copyright 2007,2008,2009,2010 Vincent Pit, all rights reserved.
202 This program is free software; you can redistribute it and/or modify it
203 under the same terms as Perl itself.
207 1; # End of Linux::SysInfo