Commit | Line | Data |
---|---|---|
afd7c030 | 1 | package System::Introspector::Probe::FileHandles; |
8ce5bf49 | 2 | use Moo; |
3 | ||
f1820b4e | 4 | use System::Introspector::Util qw( |
ff4d9e13 | 5 | lines_from_command |
f1820b4e | 6 | transform_exceptions |
7 | ); | |
8 | ||
9c3e454c | 9 | has lsof_command => (is => 'ro', default => sub { 'lsof' }); |
10 | ||
8ce5bf49 | 11 | sub 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 | 28 | sub _lsof_command_call { |
8ce5bf49 | 29 | my ($self) = @_; |
ff4d9e13 | 30 | return $self->lsof_command, '-F0'; |
8ce5bf49 | 31 | } |
32 | ||
33 | 1; | |
535e84b6 | 34 | |
35 | __END__ | |
36 | ||
37 | =head1 NAME | |
38 | ||
f24afb0e | 39 | System::Introspector::Probe::FileHandles - Gather opened filehandles |
535e84b6 | 40 | |
41 | =head1 DESCRIPTION | |
42 | ||
43 | Uses 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 | ||
55 | Copyright (c) 2012 the L<System::Introspector> | |
56 | L<AUTHOR|System::Introspector/AUTHOR>, | |
57 | L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and | |
58 | L<SPONSORS|System::Introspector/SPONSORS>. | |
59 | ||
60 | =head1 LICENSE | |
535e84b6 | 61 | |
f24afb0e | 62 | This library is free software and may be distributed under the same terms |
63 | as perl itself. | |
64 | ||
65 | =cut |