documentation and attribution fixes
[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(
ff4d9e13 5 lines_from_command
f1820b4e 6 transform_exceptions
7);
8
9c3e454c 9has lsof_command => (is => 'ro', default => sub { 'lsof' });
10
8ce5bf49 11sub gather {
12 my ($self) = @_;
f1820b4e 13 return transform_exceptions {
ff4d9e13 14 my @lines = lines_from_command [$self->_lsof_command_call];
f1820b4e 15 my @handles;
ff4d9e13 16 for my $line (@lines) {
f1820b4e 17 chomp $line;
18 my @fields = split m{\0}, $line;
19 push @handles, { map {
20 m{^(.)(.*)$};
21 ($1, $2);
22 } @fields };
23 }
24 return { handles => \@handles };
25 };
8ce5bf49 26}
27
ff4d9e13 28sub _lsof_command_call {
8ce5bf49 29 my ($self) = @_;
ff4d9e13 30 return $self->lsof_command, '-F0';
8ce5bf49 31}
32
331;
535e84b6 34
35__END__
36
37=head1 NAME
38
f24afb0e 39System::Introspector::Probe::FileHandles - Gather opened filehandles
535e84b6 40
41=head1 DESCRIPTION
42
43Uses C<lsof> to build a list of open filehandles.
44
45=head1 SEE ALSO
46
47=over
48
49=item L<System::Introspector>
50
51=back
52
f24afb0e 53=head1 COPYRIGHT
54
55Copyright (c) 2012 the L<System::Introspector>
56L<AUTHOR|System::Introspector/AUTHOR>,
57L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and
58L<SPONSORS|System::Introspector/SPONSORS>.
59
60=head1 LICENSE
535e84b6 61
f24afb0e 62This library is free software and may be distributed under the same terms
63as perl itself.
64
65=cut