| 1 | package System::Introspector::Probe::Processes; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 1 | ▶ | use System::Introspector::Util qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | handle_from_command | ||||||||||||||||||||
| 6 | transform_exceptions | ||||||||||||||||||||
| 7 | 1 | ); | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # args is automatically included, since it has to be last | ||||||||||||||||||||
| 10 | 1 | my @Included = qw( | |||||||||||||||||||
| 11 | blocked | ||||||||||||||||||||
| 12 | c | ||||||||||||||||||||
| 13 | class | ||||||||||||||||||||
| 14 | cputime | ||||||||||||||||||||
| 15 | egid egroup | ||||||||||||||||||||
| 16 | etime | ||||||||||||||||||||
| 17 | euid euser | ||||||||||||||||||||
| 18 | fgid fgroup | ||||||||||||||||||||
| 19 | flags | ||||||||||||||||||||
| 20 | fuid fuser | ||||||||||||||||||||
| 21 | ignored | ||||||||||||||||||||
| 22 | lwp | ||||||||||||||||||||
| 23 | nice | ||||||||||||||||||||
| 24 | nlwp | ||||||||||||||||||||
| 25 | pgid pgrp | ||||||||||||||||||||
| 26 | pid ppid | ||||||||||||||||||||
| 27 | pri | ||||||||||||||||||||
| 28 | psr | ||||||||||||||||||||
| 29 | rgid rgroup | ||||||||||||||||||||
| 30 | rss | ||||||||||||||||||||
| 31 | ruid ruser | ||||||||||||||||||||
| 32 | sgid sgroup | ||||||||||||||||||||
| 33 | sid | ||||||||||||||||||||
| 34 | size | ||||||||||||||||||||
| 35 | start_time | ||||||||||||||||||||
| 36 | stat | ||||||||||||||||||||
| 37 | suid suser | ||||||||||||||||||||
| 38 | tid | ||||||||||||||||||||
| 39 | time | ||||||||||||||||||||
| 40 | tname | ||||||||||||||||||||
| 41 | wchan | ||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 1 | ▶ | sub gather { | ||||||||||||||||||
|
Subroutine
gather: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 45 | 1 | my ($self) = @_; | |||||||||||||||||||
| 46 | 1 | my @names = (@Included, 'args'); | |||||||||||||||||||
| 47 | 1 | ▶ | return transform_exceptions { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 48 | 1 | my $pipe = $self->_open_ps_pipe; | |||||||||||||||||||
| 49 | 1 | my $spec = <$pipe>; | |||||||||||||||||||
| 50 | 1 | $spec =~ s{(?:^\s+|\s+$)}{}g; | |||||||||||||||||||
| 51 | 1 | my @fields = map lc, split m{\s+}, $spec; | |||||||||||||||||||
| 52 | 1 | my @rows; | |||||||||||||||||||
| 53 | 1 | ▶ | while (defined( my $line = <$pipe> )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 10 | chomp $line; | |||||||||||||||||||
| 55 | 10 | $line =~ s{(?:^\s+|\s+$)}{}g; | |||||||||||||||||||
| 56 | 10 | my @values = split m{\s+}, $line, scalar @fields; | |||||||||||||||||||
| 57 | 10 | my %row; | |||||||||||||||||||
| 58 | 10 | @row{ @names } = @values; | |||||||||||||||||||
| 59 | 10 | push @rows, \%row; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | return { processes => [ sort { | ||||||||||||||||||||
| 62 | 1 | ($a->{args} cmp $b->{args}) | |||||||||||||||||||
| 63 | || | ||||||||||||||||||||
| 64 | ($a->{pid} <=> $b->{pid}) | ||||||||||||||||||||
| 65 | 25 | ▶ | } @rows ] }; | ||||||||||||||||||
|
Condition66%2/3
$System::Introspector::Probe::Processes::a->{'args'} cmp $System::Introspector::Probe::Processes::b->{'args'} || $System::Introspector::Probe::Processes::a->{'pid'} <=> $System::Introspector::Probe::Processes::b->{'pid'}
MC/DC0%0/2
$System::Introspector::Probe::Processes::a->{'args'} cmp $System::Introspector::Probe::Processes::b->{'args'} || $System::Introspector::Probe::Processes::a->{'pid'} <=> $System::Introspector::Probe::Processes::b->{'pid'}
$System::Introspector::Probe::Processes::a->{'args'} cmp $System::Introspector::Probe::Processes::b->{'args'}
$System::Introspector::Probe::Processes::a->{'pid'} <=> $System::Introspector::Probe::Processes::b->{'pid'}
Truth table66%2/3
A || B
A= $System::Introspector::Probe::Processes::a->{'args'} cmp $System::Introspector::Probe::Processes::b->{'args'}B= $System::Introspector::Probe::Processes::a->{'pid'} <=> $System::Introspector::Probe::Processes::b->{'pid'}
| |||||||||||||||||||||
| 66 | 1 | }; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 1 | ▶ | sub _open_ps_pipe { | ||||||||||||||||||
|
Subroutine
_open_ps_pipe: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 70 | 1 | my ($self) = @_; | |||||||||||||||||||
| 71 | 1 | return handle_from_command sprintf | |||||||||||||||||||
| 72 | 'ps -eo %s', | ||||||||||||||||||||
| 73 | join(',', @Included, 'args'); | ||||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||