Commit | Line | Data |
afd7c030 |
1 | package System::Introspector::Probe::DiskUsage; |
6580617b |
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 | } |
f5dff4ce |
27 | no warnings 'uninitialized'; |
28 | return { disk_usage => [ sort { |
29 | ($a->{filesystem} cmp $b->{filesystem}) |
30 | || |
31 | ($a->{mount_point} cmp $b->{mount_point}) |
32 | } @rows ] }; |
ff3e98f6 |
33 | }; |
6580617b |
34 | } |
35 | |
36 | 1; |
535e84b6 |
37 | |
38 | __END__ |
39 | |
40 | =head1 NAME |
41 | |
42 | System::Introspector::DiskUsage - Gather disk space usage data |
43 | |
44 | =head1 DESCRIPTION |
45 | |
46 | Uses C<df> to get data about current disk usage. |
47 | |
48 | =head1 SEE ALSO |
49 | |
50 | =over |
51 | |
52 | =item L<System::Introspector> |
53 | |
54 | =back |
55 | |
56 | =cut |
57 | |