File Coverage

blib/lib/System/Introspector/Probe/DiskUsage.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 26 28 92.8


line stmt bran cond sub pod time code
1             package System::Introspector::Probe::DiskUsage;
2 1     1   42172 use Moo;
  1         17379  
  1         7  
3              
4 1         1106 use System::Introspector::Util qw(
5             lines_from_command
6             transform_exceptions
7 1     1   2863 );
  1         6  
8              
9             sub gather {
10 1     1 0 60 my ($self) = @_;
11             return transform_exceptions {
12 1     1   8 my @lines = lines_from_command ['df', '-aP'];
13 1         11 shift @lines; # header
14 1         2 my @rows;
15 1         6 for my $line (@lines) {
16 18         20 my %row;
17 18         107 @row{qw(
18             filesystem
19             blocks_1024
20             used
21             available
22             capacity
23             mount_point
24             )} = split m{\s+}, $line;
25 18         56 push @rows, \%row;
26             }
27 1     1   17 no warnings 'uninitialized';
  1         3  
  1         348  
28 57 50       161 return { disk_usage => [ sort {
29 1         17 ($a->{filesystem} cmp $b->{filesystem})
30             ||
31             ($a->{mount_point} cmp $b->{mount_point})
32             } @rows ] };
33 1         13 };
34             }
35              
36             1;
37              
38             __END__