blib/lib/Sys/MemInfo.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 25 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
get
1.0
CRAP 1.0
« MemInfo.xs ↑ Summary
1 package Sys::MemInfo;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 require Exporter;
7 1 require DynaLoader;
8  
9 1 our @ISA = qw(Exporter DynaLoader);
10 # Items to export into callers namespace by default. Note: do not export
11 # names by default without a very good reason. Use EXPORT_OK instead.
12 # Do not simply export all your public functions/methods/constants.
13 1 our @EXPORT = qw(
14 );
15 1 our @EXPORT_OK = qw(
16 totalmem
17 freemem
18 totalswap
19 freeswap
20 availkeys
21 get
22 );
23 1 our $VERSION = 0.99;
24 1 bootstrap Sys::MemInfo $VERSION;
25  
26 4 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
27 4 my $field = shift;
28 1 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 4 return &{$field};
30 }
31  
32 =head1 NAME
33  
34 Sys::MemInfo - query the total free and used physical memory
35  
36 =head1 SYNOPSIS
37  
38 use Sys::MemInfo qw(totalmem freemem totalswap);
39  
40 print "total memory: ".(&totalmem / 1024)."\n";
41 print "free memory: ".(&freemem / 1024)."\n";
42  
43 print "total swap: ".(&totalswap / 1024)."\n";
44 print "free swap: ".(Sys::MemInfo::get("freeswap") / 1024)."\n";
45  
46 =head1 DESCRIPTION
47  
48 Sys::MemInfo return the total amount of free and used physical memory in bytes in totalmem and freemem variables.
49  
50 Total amount of free and user swap memory are alse returned in totalswap and freeswap variables.
51  
52 This module has been tested on Linux 3.13.0, UnixWare 7.1.2, AIX5, OpenBSD 3.8,
53 NetBSD 2.0.2, FreBSD 5.4, HPUX11, Solaris 9, Tru64 5.1, Irix 6.5, Mac OS X 10.2 darwin and Windows XP.
54  
55 It should work on FreeBSD 4 and Windows 9X/ME/NT/200X/Vista.
56  
57 =head1 METHODS
58  
59 =over 4
60  
61 =item availkeys
62  
63 Return list of all accessor keys (freemem, totalmem, etc.) This is useful
64 for dumping out all known information from the object by calling get() on
65 all of the returned keys.
66  
67 =item freemem
68  
69 Returns free physical memory in bytes.
70  
71 =item freeswap
72  
73 Returns free swap space in bytes.
74  
75 =item get
76  
77 Returns the value of the passed key.
78  
79 =item totalmem
80  
81 Returns total physical memory size in bytes.
82  
83 =item totalswap
84  
85 Returns total swap space in bytes.
86  
87 =back
88  
89 =head1 AUTHOR
90  
91 Sylvain Cresto E<lt>scresto@gmail.comE<gt>
92  
93 Thanks to Laurent Dufour and Wilson Snyder.
94  
95 =head1 BUGS
96  
97 Please send bug-reports to scresto@gmail.com
98  
99 =head1 LICENCE
100  
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.
103  
104 =head1 COPYRIGHT
105  
106 Copyright (C) 2005, 2006, 2014, 2016 - Sylvain Cresto
107  
108 =cut
109  
110 1 1;
« MemInfo.xs ↑ Summary