moved probe classes to ::Probe:: namespace
[scpubgit/System-Introspector.git] / lib / System / Introspector / Probe / FileHandles.pm
CommitLineData
afd7c030 1package System::Introspector::Probe::FileHandles;
8ce5bf49 2use Moo;
3
f1820b4e 4use System::Introspector::Util qw(
5 handle_from_command
6 transform_exceptions
7);
8
8ce5bf49 9sub 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
26sub _open_lsof_pipe {
27 my ($self) = @_;
f1820b4e 28 return handle_from_command 'lsof -F0';
8ce5bf49 29}
30
311;
535e84b6 32
33__END__
34
35=head1 NAME
36
37System::Introspector::FileHandles - Gather opened filehandles
38
39=head1 DESCRIPTION
40
41Uses 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