Commit | Line | Data |
6580617b |
1 | package System::Introspector::DiskUsage; |
2 | use Moo; |
3 | |
ff3e98f6 |
4 | use System::Introspector::Util qw( |
5 | lines_from_command |
6 | transform_exceptions |
7 | ); |
8 | |
6580617b |
9 | sub gather { |
10 | my ($self) = @_; |
ff3e98f6 |
11 | return transform_exceptions { |
12 | my @lines = lines_from_command ['df', '-aP']; |
13 | shift @lines; # header |
14 | my @rows; |
15 | for my $line (@lines) { |
16 | my %row; |
17 | @row{qw( |
18 | filesystem |
19 | blocks_1024 |
20 | used |
21 | available |
22 | capacity |
23 | mount_point |
24 | )} = split m{\s+}, $line; |
25 | push @rows, \%row; |
26 | } |
27 | return { disk_usage => \@rows }; |
28 | }; |
6580617b |
29 | } |
30 | |
31 | 1; |
535e84b6 |
32 | |
33 | __END__ |
34 | |
35 | =head1 NAME |
36 | |
37 | System::Introspector::DiskUsage - Gather disk space usage data |
38 | |
39 | =head1 DESCRIPTION |
40 | |
41 | Uses C<df> to get data about current disk usage. |
42 | |
43 | =head1 SEE ALSO |
44 | |
45 | =over |
46 | |
47 | =item L<System::Introspector> |
48 | |
49 | =back |
50 | |
51 | =cut |
52 | |