Commit | Line | Data |
afd7c030 |
1 | package System::Introspector::Probe::FileHandles; |
8ce5bf49 |
2 | use Moo; |
3 | |
f1820b4e |
4 | use System::Introspector::Util qw( |
5 | handle_from_command |
6 | transform_exceptions |
7 | ); |
8 | |
8ce5bf49 |
9 | sub gather { |
10 | my ($self) = @_; |
f1820b4e |
11 | return transform_exceptions { |
12 | my $pipe = $self->_open_lsof_pipe; |
13 | my @handles; |
14 | while (defined( my $line = <$pipe> )) { |
15 | chomp $line; |
16 | my @fields = split m{\0}, $line; |
17 | push @handles, { map { |
18 | m{^(.)(.*)$}; |
19 | ($1, $2); |
20 | } @fields }; |
21 | } |
22 | return { handles => \@handles }; |
23 | }; |
8ce5bf49 |
24 | } |
25 | |
26 | sub _open_lsof_pipe { |
27 | my ($self) = @_; |
f1820b4e |
28 | return handle_from_command 'lsof -F0'; |
8ce5bf49 |
29 | } |
30 | |
31 | 1; |
535e84b6 |
32 | |
33 | __END__ |
34 | |
35 | =head1 NAME |
36 | |
37 | System::Introspector::FileHandles - Gather opened filehandles |
38 | |
39 | =head1 DESCRIPTION |
40 | |
41 | Uses C<lsof> to build a list of open filehandles. |
42 | |
43 | =head1 SEE ALSO |
44 | |
45 | =over |
46 | |
47 | =item L<System::Introspector> |
48 | |
49 | =back |
50 | |
51 | =cut |
52 | |