1 package Linux::SysInfo;
8 Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call.
16 our $VERSION = '0.03';
20 use Linux::SysInfo qw/sysinfo/;
23 print "$_: $si->{$_}\n" for keys %$si;
27 This module is a wrapper around the sysinfo(2) Linux system call. It gives information about the current uptime, load average, memory usage and processes running. Other systems have also this system call (e.g. Solaris), but in most cases the returned information is different.
31 The only function of this module, C<sysinfo>, and the constant C<LS_HAS_EXTENDED> are only exported on request.
35 use base qw/Exporter/;
37 our @EXPORT_OK = qw/sysinfo LS_HAS_EXTENDED/;
39 our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK ] );
43 XSLoader::load('Linux::SysInfo', $VERSION);
49 This function takes no argument. It returns undef on failure or a hash reference whose keys are the members name of the struct sysinfo on success :
55 Seconds elapsed since the system booted.
57 =item C<load1>, C<load5>, C<load15>
59 1, 5 and 15 minutes load average.
63 Total usable main memory size.
67 Available memory size.
71 Amount of shared memory.
75 Memory used by buffers.
79 Total swap space size.
83 Swap space stil available.
87 Number of current processes.
91 Prior to Linux 2.3.23 on i386 and 2.3.48 on all other architectures, the memory sizes were given in bytes. Since then, the following members are also available and all the memory sizes are given as multiples of mem_unit bytes :
97 Total high memory size.
101 Available high memory size.
105 Memory unit size in bytes.
111 =head2 LS_HAS_EXTENDED
113 This constant is set to 1 if your kernel supports the three extended fields C<totalhigh>, C<freehigh> and C<mem_unit> ; and to 0 otherwise.
115 =head1 BINARY COMPATIBILITY
117 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.
119 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.
123 The C<sysinfo(2)> man page.
125 L<Sys::Info> : Gather information about your system.
127 L<Sys::CpuLoad> : Try several different methods to retrieve the load average.
129 L<BSD::getloadavg> : Wrapper to the C<getloadavg(3)> BSD system call.
133 Vincent Pit, C<< <perl at profvince.com> >>
137 Please report any bugs or feature requests to
138 C<bug-linux-sysinfo at rt.cpan.org>, or through the web interface at
139 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-SysInfo>.
140 I will be notified, and then you'll automatically be notified of progress on
141 your bug as I make changes.
145 You can find documentation for this module with the perldoc command.
147 perldoc Linux::SysInfo
149 =head1 COPYRIGHT & LICENSE
151 Copyright 2007 Vincent Pit, all rights reserved.
153 This program is free software; you can redistribute it and/or modify it
154 under the same terms as Perl itself.
158 1; # End of Linux::SysInfo