blib/lib/Net/Connection/ncnetstat.pm

filter: Statementstmt 13.9% 31 / 223 Branchbran 0.0% 0 / 90 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 75.0% 9 / 12 Podpod 100% 2 / 2 totaltotal 11.4% 42 / 367 CC 57 SCAR 71.0
CC
57
Cov
9%
run
1892.0
new
110.0
_collector
42.0
CRAP 1216.4
↑ Summary
1 package Net::Connection::ncnetstat;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Net::Connection;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Net::Connection::Match;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Net::Connection::Sort;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Proc::ProcessTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Text::ANSITable;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # the native collection method for the OS in question, if there is one
14 2 my %native_collectors = (
15 linux => [ 'Net::Connection::Linux_ss', 'ss_to_nc_objects' ],
16 freebsd => [ 'Net::Connection::FreeBSD_sockstat', 'sockstat_to_nc_objects' ],
17 );
18  
19 # the collection method to fall back to when there is no usable native one
20 2 my @lsof_collector = ( 'Net::Connection::lsof', 'lsof_to_nc_objects' );
21  
22 # holds the code ref for the collection method chosen by &_collector
23 2 my $collector;
24  
25 =head1 NAME
26  
27 Net::Connection::ncnetstat - The backend for ncnetstat, the colorized and enhanced netstat like tool.
28  
29 =head1 VERSION
30  
31 Version 0.9.1
32  
33 =cut
34  
35 2 our $VERSION = '0.9.1';
36  
37 =head1 SYNOPSIS
38  
39 use Net::Connection::ncnetstat;
40
41 # Net::Connection::Match filters
42 my @filters=(
43 {
44 type=>'States',
45 invert=>1,
46 args=>{
47 states=>['LISTEN']
48 }
49 }
50 );
51
52 my $ncnetstat=Net::Connection::ncnetstat->new(
53 {
54 ptr=>1,
55 command=>1,
56 command_long=>0,
57 wchan=>0,
58 pct_show=>1,
59 sorter=>{
60 invert=>0,
61 type=>'host_lf',
62 },
63 match=>{
64 checks=>\@filters,
65 }
66 }
67 );
68
69 print $ncnetstat->run;
70  
71 =head1 METHODS
72  
73 =head2 new
74  
75 This initiates the object.
76  
77 my $ncnetstat=Net::Connection::ncnetstat->new( \%args );
78  
79 =head3 args hash ref
80  
81 =head4 command
82  
83 If set to true, it will show the command for the PID.
84  
85 =head4 command_long
86  
87 If set to true, the full command is shown.
88  
89 This requires command also being true.
90  
91 =head4 match
92  
93 This is the hash to pass to L<Net::Connection::Match>.
94  
95 By default this is undef and that module won't be used.
96  
97 =head4 no_pid_user
98  
99 Don't show the PID or UID/user colomn.
100  
101 =head4 sorter
102  
103 This is what is to be passed to L<Net::Connection::Sorter>.
104  
105 The default is as below.
106  
107 {
108 type=>'unsorted',
109 invert=>0,
110 }
111  
112 =cut
113  
114 0 ▶sub new {
Subroutine new: not called CC=10 SCAR=47.0
Pod documented
115 0 my %args;
116 0 ▶ if ( defined( $_[1] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
117 0 %args = %{ $_[1] };
118 }
119  
120 0 ▶ if ( !defined( $args{sorter} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"sorter"}) 0 0 0
121 $args{sorter} = {
122 0 type => 'unsorted',
123 invert => 0,
124 };
125 }
126  
127 my $self = {
128 invert => 0,
129 0 sorter => Net::Connection::Sort->new( $args{sorter} ),
130 ptr => 1,
131 command => 0,
132 command_long => 0,
133 wchan => 0,
134 pct => 0,
135 no_pid_user => 0,
136 };
137 0 bless $self;
138  
139 0 ▶ if ( defined( $args{match} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"match"}) 0 0 0
140 0 $self->{match} = Net::Connection::Match->new( $args{match} );
141 }
142  
143 0 ▶ if ( defined( $args{ptr} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"ptr"}) 0 0 0
144 0 $self->{ptr} = $args{ptr};
145 }
146  
147 0 ▶ if ( defined( $args{command} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"command"}) 0 0 0
148 0 $self->{command} = $args{command};
149 }
150  
151 0 ▶ if ( defined( $args{pct} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"pct"}) 0 0 0
152 0 $self->{pct} = $args{pct};
153 }
154  
155 0 ▶ if ( defined( $args{wchan} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"wchan"}) 0 0 0
156 0 $self->{wchan} = $args{wchan};
157 }
158  
159 0 ▶ if ( defined( $args{command_long} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"command_long"}) 0 0 0
160 0 $self->{command_long} = $args{command_long};
161 }
162  
163 0 ▶ if ( defined( $args{no_pid_user} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"no_pid_user"}) 0 0 0
164 0 $self->{no_pid_user} = $args{no_pid_user};
165 }
166  
167 0 return $self;
168 } ## end sub new
169  
170 # Returns the code ref for the collection method to use, loading the module it
171 # lives in as needed.
172 #
173 # The native collection method for the OS in question is preferred, but as it is
174 # entirely possible for that module to not be installed, L<Net::Connection::lsof>
175 # is used as a fallback. This is why the loading is done at runtime instead of
176 # via use, as a missing native module should not render this module unusable.
177 0 ▶sub _collector {
Subroutine _collector: not called CC=6 SCAR=37.4
178 0 ▶ if ( defined($collector) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $collector) 0 0 0
179 0 return $collector;
180 }
181  
182 0 my @to_try;
183 0 ▶ if ( defined( $native_collectors{$^O} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $native_collectors{$^O}) 0 0 0
184 0 push( @to_try, $native_collectors{$^O} );
185 }
186 0 push( @to_try, \@lsof_collector );
187  
188 0 my @failures;
189 0 foreach my $to_try (@to_try) {
190 0 my ( $module, $sub_name ) = @{$to_try};
191  
192 0 my $module_file = $module . '.pm';
193 0 $module_file =~ s/::/\//g;
194  
195 0 ▶ if ( !eval { require $module_file; 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require $module_file; 1 } }) 0 0 0
196 0 push( @failures, $module . ' could not be loaded... ' . $@ );
197 0 next;
198 }
199  
200 0 $collector = $module->can($sub_name);
201 0 ▶ if ( defined($collector) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $collector) 0 0 0
202 0 return $collector;
203 }
204  
205 0 push( @failures, $module . ' does not provide ' . $sub_name );
206 } ## end foreach my $to_try (@to_try)
207  
208 0 die( 'No usable connection collection method found... ' . join( ' ', @failures ) );
209 } ## end sub _collector
210  
211 =head2 run
212  
213 This runs it and returns a string.
214  
215 The collection method used is chosen based on the OS. L<Net::Connection::Linux_ss>
216 is used on Linux and L<Net::Connection::FreeBSD_sockstat> on FreeBSD. Anything
217 else falls back to L<Net::Connection::lsof>, which is also used if the native
218 module for the OS in question is not installed.
219  
220 print $ncnetstat->run;
221  
222 =cut
223  
224 0 ▶sub run {
Subroutine run: not called CC=43 SCAR=75.5
Pod documented
225 0 my $self = $_[0];
226  
227 0 my $collection_method = _collector();
228 0 my @objects = &{$collection_method}();
229  
230 0 my @found;
231 0 ▶ if ( defined( $self->{match} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'match'}) { } 0 0 0
232 0 foreach my $conn (@objects) {
233 0 ▶ if ( $self->{match}->match($conn) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"match"}->match($conn)) 0 0 0
234 0 push( @found, $conn );
235 }
236 }
237 } else {
238 0 @found = @objects;
239 }
240  
241 0 @found = $self->{sorter}->sorter( \@found );
242  
243 0 my $tb = Text::ANSITable->new;
244 0 $tb->border_style('ASCII::None');
245 0 $tb->color_theme('NoColor');
246  
247 0 my @headers;
248 0 my $header_int = 0;
249 0 push( @headers, 'Proto' );
250 0 $tb->set_column_style( $header_int, pad => 0 );
251 0 $header_int++;
252 0 ▶ if ( !$self->{no_pid_user} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"no_pid_user"}) 0 0 0
253 0 push( @headers, 'User' );
254 0 $tb->set_column_style( $header_int, pad => 1 );
255 0 $header_int++;
256 0 push( @headers, 'PID' );
257 0 $tb->set_column_style( $header_int, pad => 0 );
258 0 $header_int++;
259 }
260 0 push( @headers, 'Local Host' );
261 0 $tb->set_column_style( $header_int, pad => 1, formats => [ [ wrap => { ansi => 1, mb => 1 } ] ] );
262 0 $header_int++;
263 0 push( @headers, 'L Port' );
264 0 $tb->set_column_style( $header_int, pad => 0 );
265 0 $header_int++;
266 0 push( @headers, 'Remote Host' );
267 0 $tb->set_column_style( $header_int, pad => 1, formats => [ [ wrap => { ansi => 1, mb => 1 } ] ] );
268 0 $header_int++;
269 0 push( @headers, 'R Port' );
270 0 $tb->set_column_style( $header_int, pad => 0 );
271 0 $header_int++;
272 0 push( @headers, 'State' );
273 0 $tb->set_column_style( $header_int, pad => 1 );
274 0 $header_int++;
275  
276 0 my $padding = 0;
277 0 ▶ if ( $self->{wchan} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"wchan"}) 0 0 0
278 0 ▶ if ( ( $header_int % 2 ) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header_int % 2 != 0) 0 0 0
279 0 $padding = 1;
280 }
281 0 push( @headers, 'WChan' );
282 0 $tb->set_column_style( $header_int, pad => $padding );
283 0 $header_int++;
284 }
285  
286 0 ▶ if ( $self->{pct} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pct"}) 0 0 0
287 0 ▶ if ( ( $header_int % 2 ) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header_int % 2 != 0) { } 0 0 0
288 0 $padding = 1;
289 } else {
290 0 $padding = 0;
291 }
292 0 push( @headers, 'CPU%' );
293 0 $tb->set_column_style( $header_int, pad => $padding );
294 0 $header_int++;
295 0 ▶ if ( ( $header_int % 2 ) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header_int % 2 != 0) { } 0 0 0
296 0 $padding = 1;
297 } else {
298 0 $padding = 0;
299 }
300 0 push( @headers, 'Mem%' );
301 0 $tb->set_column_style( $header_int, pad => $padding );
302 0 $header_int++;
303 } ## end if ( $self->{pct} )
304  
305 0 ▶ if ( $self->{command} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"command"}) 0 0 0
306 0 ▶ if ( ( $header_int % 2 ) != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header_int % 2 != 0) { } 0 0 0
307 0 $padding = 1;
308 } else {
309 0 $padding = 0;
310 }
311 0 push( @headers, 'Command' );
312 0 $tb->set_column_style( $header_int, pad => $padding, formats => [ [ wrap => { ansi => 1, mb => 1 } ] ] );
313 0 $header_int++;
314 } ## end if ( $self->{command} )
315  
316 0 $tb->set_column_style( 4, pad => 0 );
317 0 $tb->set_column_style( 5, pad => 1, formats => [ [ wrap => { ansi => 1, mb => 1 } ] ] );
318 0 $tb->set_column_style( 6, pad => 0 );
319 0 $tb->set_column_style( 7, pad => 1 );
320 0 $tb->set_column_style( 8, pad => 0 );
321 0 $tb->set_column_style( 9, pad => 1 );
322 0 $tb->set_column_style( 10, pad => 0 );
323 0 $tb->set_column_style( 11, pad => 1, formats => [ [ wrap => { ansi => 1, mb => 1 } ] ] );
324 0 $tb->set_column_style( 12, pad => 0 );
325 0 $tb->set_column_style( 13, pad => 1 );
326  
327 0 $tb->columns( \@headers );
328  
329 # process table stuff if needed
330 0 my $ppt;
331 my $proctable;
332 0 my %cmd_cache;
333 0 ▶ if ( $self->{command} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"command"}) 0 0 0
334 0 $ppt = Proc::ProcessTable->new;
335 0 $proctable = $ppt->table;
336 }
337  
338 0 my @td;
339 0 foreach my $conn (@found) {
340 0 my @new_line = ( color('bright_yellow') . $conn->proto . color('reset'), );
341  
342 # don't add the PID or user if requested to
343 0 ▶ if ( !$self->{no_pid_user} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"no_pid_user"}) 0 0 0
344  
345 # handle adding the username or UID if we have one
346 0 ▶ if ( defined( $conn->username ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->username) { } 0 0 0
347 0 push( @new_line, color('bright_cyan') . $conn->username . color('reset') );
348 } else {
349 0 ▶ if ( defined( $conn->uid ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->uid) { } 0 0 0
350 0 push( @new_line, color('bright_cyan') . $conn->uid . color('reset') );
351 } else {
352 0 push( @new_line, '' );
353 }
354 }
355  
356 # handle adding the PID if we have one
357 0 ▶ if ( defined( $conn->pid ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->pid) { } 0 0 0
358 0 push( @new_line, color('bright_red') . $conn->pid . color('reset') );
359 0 $conn->pid;
360 } else {
361 0 push( @new_line, '' );
362 }
363 } ## end if ( !$self->{no_pid_user} )
364  
365 # Figure out what we are using for the local host
366 0 my $local;
367 0 ▶ if ( defined( $conn->local_ptr ) && $self->{ptr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->local_ptr and $self->{'ptr'}) { } 0 0 0
Condition0%0/3
defined $conn->local_ptr and $self->{"ptr"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conn->local_ptr and $self->{"ptr"}
defined $conn->local_ptr $self->{"ptr"}
Truth table0%0/3
A and B
A= defined $conn->local_ptrB= $self->{"ptr"}
ABresult
0X0
100
111
368 0 $local = $conn->local_ptr;
369 } else {
370 0 $local = $conn->local_host;
371 }
372  
373 # Figure out what we are using for the foriegn host
374 0 my $foreign;
375 0 ▶ if ( defined( $conn->foreign_ptr ) && $self->{ptr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->foreign_ptr and $self->{'ptr'}) { } 0 0 0
Condition0%0/3
defined $conn->foreign_ptr and $self->{"ptr"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conn->foreign_ptr and $self->{"ptr"}
defined $conn->foreign_ptr $self->{"ptr"}
Truth table0%0/3
A and B
A= defined $conn->foreign_ptrB= $self->{"ptr"}
ABresult
0X0
100
111
376 0 $foreign = $conn->foreign_ptr;
377 } else {
378 0 $foreign = $conn->foreign_host;
379 }
380  
381 # Figure out what we are using for the local port
382 0 my $lport;
383 0 ▶ if ( defined( $conn->local_port_name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->local_port_name) { } 0 0 0
384 0 $lport = $conn->local_port_name;
385 } else {
386 0 $lport = $conn->local_port;
387 }
388  
389 # Figure out what we are using for the foreign port
390 0 my $fport;
391 0 ▶ if ( defined( $conn->foreign_port_name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conn->foreign_port_name) { } 0 0 0
392 0 $fport = $conn->foreign_port_name;
393 } else {
394 0 $fport = $conn->foreign_port;
395 }
396  
397 0 push( @new_line,
398 color('bright_green') . $local . color('reset'),
399 color('green') . $lport . color('reset'),
400 color('bright_magenta') . $foreign . color('reset'),
401 color('magenta') . $fport . color('reset'),
402 color('bright_blue') . $conn->state . color('reset'),
403 );
404  
405 # handle the wchan bit if needed
406 0 ▶ if ( $self->{wchan}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"wchan"} and defined $conn->wchan) 0 0 0
Condition0%0/3
$self->{"wchan"} and defined $conn->wchan
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"wchan"} and defined $conn->wchan
$self->{"wchan"} defined $conn->wchan
Truth table0%0/3
A and B
A= $self->{"wchan"}B= defined $conn->wchan
ABresult
0X0
100
111
407 && defined( $conn->wchan ) )
408 {
409 0 push( @new_line, color('bright_yellow') . $conn->wchan . color('reset') );
410 }
411  
412 # handle the percent stuff if needed
413 0 ▶ if ( $self->{pct}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pct"} and defined $conn->pctcpu) 0 0 0
Condition0%0/3
$self->{"pct"} and defined $conn->pctcpu
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pct"} and defined $conn->pctcpu
$self->{"pct"} defined $conn->pctcpu
Truth table0%0/3
A and B
A= $self->{"pct"}B= defined $conn->pctcpu
ABresult
0X0
100
111
414 && defined( $conn->pctcpu ) )
415 {
416 0 push( @new_line, color('bright_cyan') . sprintf( '%.2f', $conn->pctcpu ) . color('reset') );
417 }
418  
419 # handle the percent stuff if needed
420 0 ▶ if ( $self->{pct}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pct"} and defined $conn->pctmem) 0 0 0
Condition0%0/3
$self->{"pct"} and defined $conn->pctmem
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pct"} and defined $conn->pctmem
$self->{"pct"} defined $conn->pctmem
Truth table0%0/3
A and B
A= $self->{"pct"}B= defined $conn->pctmem
ABresult
0X0
100
111
421 && defined( $conn->pctmem ) )
422 {
423 0 push( @new_line, color('bright_green') . sprintf( '%.2f', $conn->pctmem ) . color('reset') );
424 }
425  
426 # handle the command portion if needed
427 0 ▶ if ( defined( $conn->pid )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $conn->pid and $self->{'command'}) { } 0 0 0
elsif (not defined $conn->pid and $self->{'command'}) { } 0 0 0
Condition0%0/3
defined $conn->pid and $self->{"command"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conn->pid and $self->{"command"}
defined $conn->pid $self->{"command"}
Truth table0%0/3
A and B
A= defined $conn->pidB= $self->{"command"}
ABresult
0X0
100
111
428 && $self->{command} )
429 {
430  
431 0 my $loop = 1;
432 0 my $proc = 0;
433 0 ▶ while ( defined( $proctable->[$proc] )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proctable->[$proc] and $loop) 0 0 0
Condition0%0/3
defined $proctable->[$proc] and $loop
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proctable->[$proc] and $loop
defined $proctable->[$proc] $loop
Truth table0%0/3
A and B
A= defined $proctable->[$proc]B= $loop
ABresult
0X0
100
111
434 && $loop )
435 {
436 0 my $command;
437 0 ▶ if ( defined( $cmd_cache{ $conn->pid } ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $cmd_cache{$conn->pid}) { } 0 0 0
elsif (defined $conn->proc) { } 0 0 0
elsif ($proctable->[$proc]->pid eq $conn->pid) { } 0 0 0
438 0 push( @new_line, color('bright_red') . $cmd_cache{ $conn->pid } . color('reset') );
439 0 $loop = 0;
440 } elsif ( defined( $conn->proc ) ) {
441 0 my $command = $conn->proc;
442 0 ▶ if ( !$self->{command_long} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"command_long"}) 0 0 0
443 0 $command =~ s/\ .*//;
444 }
445 0 $cmd_cache{ $conn->pid } = $command;
446 0 push( @new_line, color('bright_red') . $cmd_cache{ $conn->pid } . color('reset') );
447 0 $loop = 0,;
448 } elsif ( $proctable->[$proc]->pid eq $conn->pid ) {
449 0 ▶ if ( $proctable->[$proc]->{'cmndline'} =~ /^$/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($proctable->[$proc]{'cmndline'} =~ /^$/) { } 0 0 0
elsif ($self->{'command_long'}) { } 0 0 0
elsif ($proctable->[$proc]{'cmndline'} =~ m[^/]) { } 0 0 0
450  
451 #kernel process
452 $cmd_cache{ $conn->pid }
453 0 = color('bright_red') . '[' . $proctable->[$proc]->{'fname'} . ']' . color('reset');
454 } elsif ( $self->{command_long} ) {
455 $cmd_cache{ $conn->pid }
456 0 = color('bright_red') . $proctable->[$proc]->{'cmndline'} . color('reset');
457 } elsif ( $proctable->[$proc]->{'cmndline'} =~ /^\// ) {
458  
459 # something ran with a complete path
460 $cmd_cache{ $conn->pid }
461 0 = color('bright_red') . $proctable->[$proc]->{'fname'} . color('reset');
462 } else {
463 # likely a thread or the like... such as dovecot/auth
464 # just trunkcat everything after the space
465 0 my $cmd = $proctable->[$proc]->{'cmndline'};
466 0 $cmd =~ s/\ +.*//g;
467 0 $cmd_cache{ $conn->pid } = color('bright_red') . $cmd . color('reset');
468 }
469  
470 0 push( @new_line, $cmd_cache{ $conn->pid } );
471 0 $loop = 0;
472 } ## end elsif ( $proctable->[$proc]->pid eq $conn->pid)
473  
474 0 $proc++;
475 } ## end while ( defined( $proctable->[$proc] ) && $loop)
476  
477 ▶ } elsif ( ( !defined( $conn->pid ) )
Condition0%0/3
not defined $conn->pid and $self->{"command"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $conn->pid and $self->{"command"}
not defined $conn->pid $self->{"command"}
Truth table0%0/3
not(A) and B
A= not defined $conn->pidB= $self->{"command"}
ABresult
0X0
100
111
478 && $self->{command} )
479 {
480 0 push( @new_line, '' );
481 }
482  
483 0 $tb->add_row( \@new_line );
484 } ## end foreach my $conn (@found)
485  
486 0 return $tb->draw;
487 } ## end sub run
488  
489 =head1 TODO
490  
491 * Add support for more collection methods.
492  
493 * Support color selection and column ordering.
494  
495 =head1 AUTHOR
496  
497 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
498  
499 =head1 BUGS
500  
501 Please report any bugs or feature requests to C<bug-net-connection-ncnetstat at rt.cpan.org>, or through
502 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Connection-ncnetstat>. I will be notified, and then you'll
503 automatically be notified of progress on your bug as I make changes.
504  
505  
506  
507  
508 =head1 SUPPORT
509  
510 You can find documentation for this module with the perldoc command.
511  
512 perldoc Net::Connection::ncnetstat
513  
514  
515 You can also look for information at:
516  
517 =over 4
518  
519 =item * RT: CPAN's request tracker (report bugs here)
520  
521 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Connection-ncnetstat>
522  
523 =item * Search CPAN
524  
525 L<https://metacpan.org/release/Net-Connection-ncnetstat>
526  
527 =item * Repository
528  
529 L<https://github.com/VVelox/Net-Connection-ncnetstat>
530  
531 =back
532  
533  
534 =head1 ACKNOWLEDGEMENTS
535  
536  
537 =head1 LICENSE AND COPYRIGHT
538  
539 This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.
540  
541 This is free software, licensed under:
542  
543 The Artistic License 2.0 (GPL Compatible)
544  
545  
546 =cut
547  
548 2 1; # End of Net::Connection::ncnetstat
↑ Summary