]> git.vpit.fr Git - perl/modules/Linux-SysInfo.git/blobdiff - lib/Linux/SysInfo.pm
Enforce the perl dependency in the module file
[perl/modules/Linux-SysInfo.git] / lib / Linux / SysInfo.pm
index 8b7eb0e694414e834ea1aed1a8e1476cbadef2ee..1e3aea2e45abecb715d2715d034878e6e1b663bf 100644 (file)
@@ -1,7 +1,9 @@
 package Linux::SysInfo;
 
-use warnings;
+use 5.006;
+
 use strict;
+use warnings;
 
 =head1 NAME
 
@@ -9,11 +11,14 @@ Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.13
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION;
+BEGIN {
+ $VERSION = '0.13';
+}
 
 =head1 SYNOPSIS
 
@@ -24,93 +29,139 @@ our $VERSION = '0.01';
 
 =head1 DESCRIPTION
 
-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.
-
-=head1 EXPORT
-
-The only function of this module, C<sysinfo>, and the constant C<LS_HAS_EXTENDED> are only exported on request.
+This module is a wrapper around the C<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.
 
-=cut
-
-use base qw/Exporter/;
+=head1 CONSTANTS
 
-our @EXPORT_OK = qw/sysinfo LS_HAS_EXTENDED/;
+=head2 C<LS_HAS_EXTENDED>
 
-our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK ] );
+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.
 
-require XSLoader;
+=head1 FUNCTIONS
 
-XSLoader::load('Linux::SysInfo', $VERSION);
+=cut
 
-=head1 FUNCTIONS
+BEGIN {
+ require XSLoader;
+ XSLoader::load(__PACKAGE__, $VERSION);
+}
 
 =head2 C<sysinfo>
 
-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 :
+This function takes no argument.
+It returns C<undef> on failure or a hash reference whose keys are the members name of the C<struct sysinfo> on success :
 
 =over 4
 
-=item C<uptime>
+=item *
+
+C<uptime>
 
 Seconds elapsed since the system booted.
 
-=item C<load1>, C<load5>, C<load15>
+=item *
+
+C<load1>, C<load5>, C<load15>
 
 1, 5 and 15 minutes load average.
 
-=item C<totalram>
+=item *
+
+C<totalram>
 
 Total usable main memory size.
 
-=item C<freeram>
+=item *
+
+C<freeram>
 
 Available memory size.
 
-=item C<sharedram>
+=item *
+
+C<sharedram>
 
 Amount of shared memory.
 
-=item C<bufferram>
+=item *
+
+C<bufferram>
 
 Memory used by buffers.
 
-=item C<totalswap>
+=item *
+
+C<totalswap>
 
 Total swap space size.
 
-=item C<freeswap>
+=item *
+
+C<freeswap>
+
+Swap space still available.
 
-Swap space stil available.
+=item *
 
-=item C<procs>
+C<procs>
 
 Number of current processes.
 
 =back
 
-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 :
+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 C<mem_unit> bytes :
 
 =over 4
 
-=item C<totalhigh>
+=item *
+
+C<totalhigh>
 
 Total high memory size.
 
-=item C<freehigh>
+=item *
+
+C<freehigh>
 
 Available high memory size.
 
-=item C<mem_unit>
+=item *
+
+C<mem_unit>
 
 Memory unit size in bytes.
 
 =back
 
-=head1 CONSTANTS
+=head1 EXPORT
+
+The only function of this module, C<sysinfo>, and the constant C<LS_HAS_EXTENDED> are only exported on request.
+Functions are also exported by the C<:funcs> tag, and constants by C<:consts>.
 
-=head2 LS_HAS_EXTENDED
+=cut
+
+use base qw/Exporter/;
+
+our @EXPORT         = ();
+our %EXPORT_TAGS    = (
+ 'funcs'  => [ qw/sysinfo/ ],
+ 'consts' => [ qw/LS_HAS_EXTENDED/ ]
+);
+our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
+$EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
+
+=head1 BINARY COMPATIBILITY
 
-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.
+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.
+
+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.
+
+=head1 DEPENDENCIES
+
+L<perl> 5.6.
 
 =head1 SEE ALSO
 
@@ -124,15 +175,14 @@ L<BSD::getloadavg> : Wrapper to the C<getloadavg(3)> BSD system call.
 
 =head1 AUTHOR
 
-Vincent Pit, C<< <perl at profvince.com> >>
+Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
+
+You can contact me by mail or on C<irc.perl.org> (vincent).
 
 =head1 BUGS
 
-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>.
-I will be notified, and then you'll automatically be notified of progress on
-your bug as I make changes.
+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>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
 
 =head1 SUPPORT
 
@@ -140,9 +190,11 @@ You can find documentation for this module with the perldoc command.
 
     perldoc Linux::SysInfo
 
+Tests code coverage report is available at L<http://www.profvince.com/perl/cover/Linux-SysInfo>.
+
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007 Vincent Pit, all rights reserved.
+Copyright 2007,2008,2009,2010 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.