blib/lib/Linux/MemInfo.pm

filter: Statementstmt 47.5% 19 / 40 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 42.5% 23 / 54 CC 6 SCAR 32.4
CC
6
Cov
40%
get_mem_info
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 25.6
↑ Summary
1 package Linux::MemInfo;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8 1 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @ISA = qw(Exporter);
11  
12 # Items to export into callers namespace by default. Note: do not export
13 # names by default without a very good reason. Use EXPORT_OK instead.
14 # Do not simply export all your public functions/methods/constants.
15  
16 # This allows declaration use Linux::MemInfo ':all';
17 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18 # will save memory.
19 1 our %EXPORT_TAGS = ( 'all' => [ qw( get_mem_info
20 ) ] );
21  
22 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
23  
24 1 our @EXPORT = qw( get_mem_info
25 );
26  
27 1 our $VERSION = '0.03';
28  
29  
30 # Preloaded methods go here.
31  
32 # Autoload methods go after =cut, and are processed by the autosplit program.
33  
34 0 ▶sub get_mem_info() {
Subroutine get_mem_info: not called CC=6 SCAR=37.4
Pod undocumented
35 0 my %mem;
36 0 ▶ open(INFIL,"/proc/meminfo") || die("Unable To Open /proc/meminfo\n");
Branch: 1 branch
BranchTrueFalseTotal
open INFIL, "/proc/meminfo" or die "Unable To Open /proc/meminfo\n" 0 0 0
37 0 NXTMI: foreach(<INFIL>) {
38 0 ▶ if( m/^Mem:\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^Mem:\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { } 0 0 0
elsif (/^Swap:\s+(\S+)\s+(\S+)\s+(\S+)/) { } 0 0 0
elsif (/^(\S+):\s+(\S+) (\S+)/) { } 0 0 0
39 0 $mem{mem_total} = $1;
40 0 $mem{mem_used} = $2;
41 0 $mem{mem_free} = $3;
42 0 $mem{mem_shared} = $4;
43 0 $mem{mem_buffers} = $5;
44 0 $mem{mem_cached} = $6;
45 0 next NXTMI;
46 }
47 elsif( m/^Swap:\s+(\S+)\s+(\S+)\s+(\S+)/ ) {
48 0 $mem{swap_total} = $1;
49 0 $mem{swap_used} = $2;
50 0 $mem{swap_free} = $3;
51 0 next NXTMI;
52 }
53 elsif( m/^(\S+):\s+(\S+) (\S+)/ ) {
54 0 my $unit = $1 . "Unit";
55 0 $mem{$1} = $2;
56 0 $mem{$unit} = $3;
57 0 next NXTMI;
58 }
59 }
60 0 close(INFIL);
61 0 return %mem
62 }
63  
64  
65 1 1;
66 __END__
↑ Summary