blib/lib/Proc/ProcessTable/Colorizer.pm

filter: Statementstmt 4.5% 25 / 552 Branchbran 0.0% 0 / 258 Conditioncond 0.0% 0 / 219 MC/DCmcdc 0.0% 0 / 110 Subroutinesub 21.6% 8 / 37 Podpod 89.6% 26 / 29 totaltotal 4.9% 59 / 1205 CC 209 SCAR 95.6
CC
209
Cov
2%
colorize
22952.0
pctcpuSearchSetString
240.0
pctmemSearchSetString
240.0
CRAP 14192.5
↑ Summary
1 package Proc::ProcessTable::Colorizer;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base 'Error::Helper';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Proc::ProcessTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Text::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Term::Size;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 Proc::ProcessTable::Colorizer - Like ps, but with colored columns and enhnaced functions for searching.
15  
16 =head1 VERSION
17  
18 Version 0.4.0
19  
20 =cut
21  
22 1 our $VERSION = '0.4.0';
23  
24  
25 =head1 SYNOPSIS
26  
27 use Proc::ProcessTable::Colorizer;
28  
29 my $cps = Proc::ProcessTable::Colorizer->new;
30 print $cps->colorize;
31  
32 This module uses L<Error::Helper> for error reporting.
33  
34 As of right now this module is not really user friend and will likely be going through lots of changes as it grows.
35  
36 =head1 METHODS
37  
38 =head2 new
39  
40 Creates a new object. This method will never error.
41  
42 my $cps=Proc::ProcessTable::Colorizer->new;
43  
44 =cut
45  
46 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
47 0 my $self={
48 perror=>undef,
49 error=>undef,
50 errorString=>'',
51 errorExtra=>{
52 1=>'badTimeString',
53 2=>'badPctcpuString',
54 },
55 colors=>[
56 'BRIGHT_YELLOW',
57 'BRIGHT_CYAN',
58 'BRIGHT_MAGENTA',
59 'BRIGHT_BLUE'
60 ],
61 timeColors=>[
62 'GREEN',
63 'BRIGHT_GREEN',
64 'RED',
65 'BRIGHT_RED'
66 ],
67 processColor=>'WHITE',
68 fields=>[
69 'pid',
70 'uid',
71 'pctcpu',
72 'pctmem',
73 'size',
74 'rss',
75 'info',
76 'nice',
77 'start',
78 'time',
79 'proc',
80 ],
81 header=>1,
82 search=>undef,
83 resolveUser=>1,
84 nextColor=>0,
85 showIdle=>0,
86 proc_search=>undef,
87 user_search=>[],
88 wait_search=>[],
89 self_ignore=>2,
90 zombie_search=>0,
91 swapped_out_search=>0,
92 time_search=>[],
93 pctcpu_search=>[],
94 };
95 0 bless $self;
96  
97 # Proc::ProcessTable does not return a nice value for Linux
98 0 ▶ if ($^O =~ /linux/){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /linux/) 0 0 0
99 $self->{fields}=[
100 0 'pid',
101 'uid',
102 'pctcpu',
103 'pctmem',
104 'size',
105 'rss',
106 'info',
107 'start',
108 'time',
109 'proc',
110 ];
111 }
112  
113 0 ▶ if ($^O =~ /bsd/){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /bsd/) 0 0 0
114 0 $self->{physmem}=`/sbin/sysctl -a hw.physmem`;
115 0 chomp($self->{physmem});
116 0 $self->{physmem}=~s/^.*\: //;
117 }
118  
119 0 return $self;
120 }
121  
122 =head2 colorize
123  
124 This colorizes it and returns a setup Text::Table object with everything already setup.
125  
126 use Proc::ProcessTable::Colorizer;
127 my $cps = Proc::ProcessTable::Colorizer->new;
128 print $cps->colorize;
129  
130 =cut
131  
132 0 ▶sub colorize{
Subroutine colorize: not called CC=151 SCAR=100.4
Pod documented
133 0 my $self=$_[0];
134 0 $self->errorblank;
135  
136 #the feilds to use
137 0 my $fields=$self->fieldsGet;
138  
139 #array of colored items
140 0 my @colored;
141  
142 #
143 0 my $fieldInt=0;
144 0 my $header;
145 0 ▶ if ( $self->{header} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"header"}) 0 0 0
146 0 my @header;
147 0 ▶ while ( defined( $fields->[$fieldInt] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->[$fieldInt]) 0 0 0
148 0 my $field=color('underline white');
149  
150 0 ▶ if ( $fields->[$fieldInt] eq 'pid' ){
Branch: 7 branches
BranchTrueFalseTotal
if ($fields->[$fieldInt] eq 'pid') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'uid') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'pctcpu') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'pctmem') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'size') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'rss') { } 0 0 0
elsif ($fields->[$fieldInt] eq 'proc') { } 0 0 0
151 0 $field=$field.'PID';
152 }elsif( $fields->[$fieldInt] eq 'uid' ){
153 0 $field=$field.'User';
154 }elsif( $fields->[$fieldInt] eq 'pctcpu' ){
155 0 $field=$field.'CPU%';
156 }elsif( $fields->[$fieldInt] eq 'pctmem' ){
157 0 $field=$field.'Mem%';
158 }elsif( $fields->[$fieldInt] eq 'size' ){
159 0 $field=$field.'VM Size';
160 }elsif( $fields->[$fieldInt] eq 'rss' ){
161 0 $field=$field.'RSS';
162 }elsif( $fields->[$fieldInt] eq 'proc' ){
163 0 $field=$field.'Command';
164 }else{
165 0 $field=$field.ucfirst($fields->[$fieldInt]);
166 }
167  
168 0 push( @header, $field.color('reset') );
169  
170 0 $fieldInt++;
171 }
172  
173 0 push( @colored, \@header );
174 }
175  
176 #get the process table
177 0 my $pt=Proc::ProcessTable->new;
178  
179 #an array of procs
180 0 my @procs;
181  
182 #goes through it all and gathers the information
183 0 foreach my $proc ( @{$pt->table} ){
184  
185 #process the requested fields
186 0 $fieldInt=0;
187 0 my %values;
188 0 ▶ while ( defined( $fields->[$fieldInt] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->[$fieldInt]) 0 0 0
189 0 my $field=$fields->[$fieldInt];
190  
191 0 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($^O =~ /bsd/ and $field =~ /pctmem/) { } 0 0 0
elsif ($^O =~ /bsd/ and $field =~ /rss/) { } 0 0 0
elsif ($field eq 'proc') { } 0 0 0
elsif ($field eq 'info') { } 0 0 0
Condition0%0/3
$^O =~ /bsd/ and $field =~ /pctmem/
!ll&&!rl&&r
000
MC/DC0%0/2
$^O =~ /bsd/ and $field =~ /pctmem/
$^O =~ /bsd/ $field =~ /pctmem/
Truth table0%0/3
A and B
A= $^O =~ /bsd/B= $field =~ /pctmem/
ABresult
0X0
100
111
192 ($^O =~ /bsd/) &&
193 ( $field =~ /pctmem/ )
194 ){
195 0 my $rss=$proc->{rssize};
196 0 ▶ if ( defined( $rss ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rss) { } 0 0 0
197 0 $rss=$rss*1024*4;
198 0 $values{pctmem}=($rss / $self->{physmem})*100;
199 }else{
200 0 $values{pctmem}=0;
201 }
202 ▶ }elsif(
Condition0%0/3
$^O =~ /bsd/ and $field =~ /rss/
!ll&&!rl&&r
000
MC/DC0%0/2
$^O =~ /bsd/ and $field =~ /rss/
$^O =~ /bsd/ $field =~ /rss/
Truth table0%0/3
A and B
A= $^O =~ /bsd/B= $field =~ /rss/
ABresult
0X0
100
111
203 ($^O =~ /bsd/) &&
204 ( $field =~ /rss/ )
205 ){
206 0 $values{rss}=$proc->{rssize};
207 0 ▶ if (!defined $values{rss} ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $values{'rss'}) { } 0 0 0
208 0 $values{rss}=0;
209 }else{
210 #not sure why this needs done :/
211 0 $values{rss}=$values{rss}*4;
212 }
213 }elsif(
214 $field eq 'proc'
215 ){
216 0 my $fname=$proc->fname;
217 0 my $cmndline=$proc->cmndline;
218  
219 #save it for possible future use
220 0 $values{fname}=$fname;
221 0 $values{cmndline}=$cmndline;
222  
223 #set the proc value
224 0 ▶ if ( $cmndline =~ /^$/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cmndline =~ /^$/) { } 0 0 0
225 0 my $kernel_proc=1; #just assuming yet, unless it is otherwise
226  
227 #may possible be a zombie, run checks for on FreeBSD
228 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /bsd/ and hex $proc->flags & 2097152) 0 0 0
Condition0%0/3
$^O =~ /bsd/ and hex $proc->flags & 2097152
!ll&&!rl&&r
000
MC/DC0%0/2
$^O =~ /bsd/ and hex $proc->flags & 2097152
$^O =~ /bsd/ hex $proc->flags & 2097152
Truth table0%0/3
A and B
A= $^O =~ /bsd/B= hex $proc->flags & 2097152
ABresult
0X0
100
111
229 ($^O =~ /bsd/) &&
230 ( hex($proc->flags) & 0x00200000 )
231 ){
232 0 $kernel_proc=1;
233 }
234  
235 #need to find something similar as above for Linux
236  
237 #
238 0 ▶ if ( $kernel_proc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($kernel_proc) { } 0 0 0
239 0 $values{'proc'}='['.$fname.']';
240 0 ▶ if ( $fname eq 'idle' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($fname eq "idle") 0 0 0
241 0 $values{'idle'}=1;
242 }
243 }else{
244 #most likely a zombie
245 0 $values{'proc'}=$fname;
246 }
247 }else{
248 0 ▶ if ( $cmndline =~ /^su *$/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cmndline =~ /^su *$/) { } 0 0 0
249 0 $values{'proc'}=$cmndline.'('.$fname.')';
250 }else{
251 0 $values{'proc'}=$cmndline;
252 }
253 }
254 }elsif(
255 $field eq 'info'
256 ){
257 0 $values{wchan}=$proc->wchan;
258 0 $values{state}=$proc->state;
259  
260 0 ▶ if ($^O =~ /bsd/){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /bsd/) 0 0 0
261 0 $values{is_session_leader}=0;
262 0 $values{is_being_forked}=0;
263 0 $values{working_on_exiting}=0;
264 0 $values{has_controlling_terminal}=0;
265 0 $values{is_locked}=0;
266 0 $values{traced_by_debugger}=0;
267 #$values{is_stopped}=0;
268 0 $values{posix_advisory_lock}=0;
269  
270 0 ▶ if ( hex($proc->flags) & 0x00002 ){ $values{controlling_tty_active}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 2) 0 0 0
271 0 ▶ if ( hex($proc->flags) & 0x00000002 ){$values{is_session_leader}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 2) 0 0 0
272 #if ( hex($proc->flags) & ){$values{is_being_forked}=1; }
273 0 ▶ if ( hex($proc->flags) & 0x02000 ){$values{working_on_exiting}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 8192) 0 0 0
274 0 ▶ if ( hex($proc->flags) & 0x00002 ){$values{has_controlling_terminal}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 2) 0 0 0
275 0 ▶ if ( hex($proc->flags) & 0x00000004 ){$values{is_locked}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 4) 0 0 0
276 0 ▶ if ( hex($proc->flags) & 0x00800 ){$values{traced_by_debugger}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 2048) 0 0 0
277 0 ▶ if ( hex($proc->flags) & 0x00001 ){$values{posix_advisory_lock}=1; }
Branch: 1 branch
BranchTrueFalseTotal
if (hex $proc->flags & 1) 0 0 0
278 }
279  
280 }else{
281 0 $values{$field}=$proc->$field;
282 }
283  
284  
285 0 $fieldInt++;
286 }
287  
288 0 ▶ if ( ! defined( $values{pctmem} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $values{"pctmem"}) 0 0 0
289 0 $values{pctmem} = 0;
290 }
291 0 ▶ if ( ! defined( $values{pctcpu} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $values{"pctcpu"}) 0 0 0
292 0 $values{pctcpu} = 0;
293 }
294  
295 0 ▶ if ( ! defined( $values{size} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $values{"size"}) 0 0 0
296 0 $values{size} = 0;
297 }
298  
299 0 $values{pctmem}=sprintf('%.2f', $values{pctmem});
300 0 $values{pctcpu}=sprintf('%.2f', $values{pctcpu});
301  
302 0 $values{size}=$values{size}/1024;
303  
304 0 push( @procs, \%values );
305  
306 }
307  
308 #sort by CPU percent and then RAM
309 @procs=sort {
310 0 $a->{pctcpu} <=> $b->{pctcpu} or
311 $a->{pctmem} <=> $b->{pctmem} or
312 $a->{rss} <=> $b->{rss} or
313 $a->{size} <=> $b->{size} or
314 $a->{time} <=> $b->{time}
315 0 ▶ } @procs;
Condition0%0/12
$Proc::ProcessTable::Colorizer::a->{'pctcpu'} <=> $Proc::ProcessTable::Colorizer::b->{'pctcpu'} || $Proc::ProcessTable::Colorizer::a->{'pctmem'} <=> $Proc::ProcessTable::Colorizer::b->{'pctmem'} || $Proc::ProcessTable::Colorizer::a->{'rss'} <=> $Proc::ProcessTable::Colorizer::b->{'rss'} || $Proc::ProcessTable::Colorizer::a->{'size'} <=> $Proc::ProcessTable::Colorizer::b->{'size'} || $Proc::ProcessTable::Colorizer::a->{'time'} <=> $Proc::ProcessTable::Colorizer::b->{'time'}
l!l&&r!l&&!r
000
$Proc::ProcessTable::Colorizer::a->{"pctcpu"} <=> $Proc::ProcessTable::Colorizer::b->{"pctcpu"} or $Proc::ProcessTable::Colorizer::a->{"pctmem"} <=> $Proc::ProcessTable::Colorizer::b->{"pctmem"} or $Proc::ProcessTable::Colorizer::a->{"rss"} <=> $Proc::ProcessTable::Colorizer::b->{"rss"} or $Proc::ProcessTable::Colorizer::a->{"size"} <=> $Proc::ProcessTable::Colorizer::b->{"size"}
l!l&&r!l&&!r
000
$Proc::ProcessTable::Colorizer::a->{"pctcpu"} <=> $Proc::ProcessTable::Colorizer::b->{"pctcpu"} or $Proc::ProcessTable::Colorizer::a->{"pctmem"} <=> $Proc::ProcessTable::Colorizer::b->{"pctmem"} or $Proc::ProcessTable::Colorizer::a->{"rss"} <=> $Proc::ProcessTable::Colorizer::b->{"rss"}
l!l&&r!l&&!r
000
$Proc::ProcessTable::Colorizer::a->{"pctcpu"} <=> $Proc::ProcessTable::Colorizer::b->{"pctcpu"} or $Proc::ProcessTable::Colorizer::a->{"pctmem"} <=> $Proc::ProcessTable::Colorizer::b->{"pctmem"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$Proc::ProcessTable::Colorizer::a->{'pctcpu'} <=> $Proc::ProcessTable::Colorizer::b->{'pctcpu'} || $Proc::ProcessTable::Colorizer::a->{'pctmem'} <=> $Proc::ProcessTable::Colorizer::b->{'pctmem'} || $Proc::ProcessTable::Colorizer::a->{'rss'} <=> $Proc::ProcessTable::Colorizer::b->{'rss'} || $Proc::ProcessTable::Colorizer::a->{'size'} <=> $Proc::ProcessTable::Colorizer::b->{'size'} || $Proc::ProcessTable::Colorizer::a->{'time'} <=> $Proc::ProcessTable::Colorizer::b->{'time'}
$Proc::ProcessTable::Colorizer::a->{"pctcpu"} <=> $Proc::ProcessTable::Colorizer::b->{"pctcpu"} $Proc::ProcessTable::Colorizer::a->{"pctmem"} <=> $Proc::ProcessTable::Colorizer::b->{"pctmem"} $Proc::ProcessTable::Colorizer::a->{"rss"} <=> $Proc::ProcessTable::Colorizer::b->{"rss"} $Proc::ProcessTable::Colorizer::a->{"size"} <=> $Proc::ProcessTable::Colorizer::b->{"size"} $Proc::ProcessTable::Colorizer::a->{'time'} <=> $Proc::ProcessTable::Colorizer::b->{'time'}
Truth table0%0/6
A or B or C or D || E
A= $Proc::ProcessTable::Colorizer::a->{"pctcpu"} <=> $Proc::ProcessTable::Colorizer::b->{"pctcpu"}B= $Proc::ProcessTable::Colorizer::a->{"pctmem"} <=> $Proc::ProcessTable::Colorizer::b->{"pctmem"}C= $Proc::ProcessTable::Colorizer::a->{"rss"} <=> $Proc::ProcessTable::Colorizer::b->{"rss"}D= $Proc::ProcessTable::Colorizer::a->{"size"} <=> $Proc::ProcessTable::Colorizer::b->{"size"}E= $Proc::ProcessTable::Colorizer::a->{'time'} <=> $Proc::ProcessTable::Colorizer::b->{'time'}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
316 0 @procs=reverse(@procs);
317  
318 #put together the colored colums, minus the proc column which will be done later
319 0 my @proc_column;
320 0 foreach my $proc (@procs){
321 0 my @line;
322 0 $self->nextColorReset;
323  
324 0 my $show=0;
325  
326 #checks if it is the idle proc and if it should show it
327 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{'idle'} and not $self->{'showIdle'}) { } 0 0 0
Condition0%0/3
defined $proc->{"idle"} and not $self->{"showIdle"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"idle"} and not $self->{"showIdle"}
defined $proc->{"idle"} not $self->{"showIdle"}
Truth table0%0/3
A and not(B)
A= defined $proc->{"idle"}B= not $self->{"showIdle"}
ABresult
0X0
100
111
328 defined ( $proc->{idle} ) &&
329 ( ! $self->{showIdle} )
330 ){
331 0 $show = 0;
332 }else{
333 0 my $required_hits=0; #number of hits required to print it
334 0 my $hits=0; #default to zero so we print it unless we increment this for a search item
335  
336 #checks if we need to do a proc search
337 0 my $proc_search=$self->{proc_search};
338 0 ▶ if ( defined( $proc_search ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc_search) 0 0 0
339 0 $required_hits++;
340 #cehck if the cmndline or fname matches
341 0 ▶ if ( $proc->{proc} =~ /$proc_search/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($proc->{"proc"} =~ /$proc_search/) 0 0 0
342 0 $hits++;
343 }
344 }
345  
346 #check to see if it needs to search for users
347 0 my $user_search_array=$self->userSearchGet;
348 0 ▶ if ( defined( $user_search_array->[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $user_search_array->[0]) 0 0 0
349 0 my $user=getpwuid($proc->{uid});
350 0 $required_hits++;
351 0 my $user_search_int=0;
352 0 my $matched=0;
353 #search while we have a user defined and it has not already been matched
354 0 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $user_search_array->[$user_search_int] and $matched == 0) 0 0 0
Condition0%0/3
defined $user_search_array->[$user_search_int] and $matched == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $user_search_array->[$user_search_int] and $matched == 0
defined $user_search_array->[$user_search_int] $matched == 0
Truth table0%0/3
A and B
A= defined $user_search_array->[$user_search_int]B= $matched == 0
ABresult
0X0
100
111
355 defined( $user_search_array->[ $user_search_int ] ) &&
356 ( $matched == 0 )
357 ){
358 0 my $to_match=$user_search_array->[ $user_search_int ];
359 0 my $to_invert=0;
360 0 ▶ if ( $to_match=~ /^\!/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\!/) 0 0 0
361 0 $to_invert=1;
362 0 $to_match=~s/^\!//;
363 }
364  
365 #check if it matches
366 0 ▶ if ( $to_invert ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_invert) { } 0 0 0
367 0 ▶ if ( $to_match ne $user ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match ne $user) 0 0 0
368 0 $hits++;
369 0 $matched=1;
370 }
371 }else{
372 0 ▶ if ( $to_match eq $user ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match eq $user) 0 0 0
373 0 $hits++;
374 0 $matched=1;
375 }
376 }
377  
378 0 $user_search_int++;
379 }
380 }
381  
382 #check to see if it needs to search for wait channels
383 0 my $wait_search_array=$self->waitSearchGet;
384 0 ▶ if ( defined( $wait_search_array->[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wait_search_array->[0]) 0 0 0
385 0 $required_hits++;
386 0 my $wait_search_int=0;
387 0 my $matched=0;
388 #search while we have a wait channel defined and it has not already been matched
389 0 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wait_search_array->[$wait_search_int] and $matched == 0) 0 0 0
Condition0%0/3
defined $wait_search_array->[$wait_search_int] and $matched == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wait_search_array->[$wait_search_int] and $matched == 0
defined $wait_search_array->[$wait_search_int] $matched == 0
Truth table0%0/3
A and B
A= defined $wait_search_array->[$wait_search_int]B= $matched == 0
ABresult
0X0
100
111
390 defined( $wait_search_array->[ $wait_search_int ] ) &&
391 ( $matched == 0 )
392 ){
393 0 my $to_match=$wait_search_array->[ $wait_search_int ];
394 0 my $to_invert=0;
395 0 ▶ if ( $to_match=~ /^\!/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\!/) 0 0 0
396 0 $to_invert=1;
397 0 $to_match=~s/^\!//;
398 }
399  
400 #check if it matches
401 0 ▶ if ( $to_invert ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_invert) { } 0 0 0
402 0 ▶ if ( $to_match ne $proc->{wchan} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match ne $proc->{"wchan"}) 0 0 0
403 0 $hits++;
404 0 $matched=1;
405 }
406 }else{
407 0 ▶ if ( $to_match eq $proc->{wchan} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match eq $proc->{"wchan"}) 0 0 0
408 0 $hits++;
409 0 $matched=1;
410 }
411 }
412  
413 0 $wait_search_int++;
414 }
415  
416 }
417  
418 #check to see if it needs to search for CPU time usage
419 0 my $time_search_array=$self->timeSearchGet;
420 0 ▶ if ( defined( $time_search_array->[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $time_search_array->[0]) 0 0 0
421 0 $required_hits++;
422 0 my $time_search_int=0;
423 0 my $matched=0;
424 #search while we have a CPU time defined and it has not already been matched
425 0 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $time_search_array->[$time_search_int] and $matched == 0) 0 0 0
Condition0%0/3
defined $time_search_array->[$time_search_int] and $matched == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $time_search_array->[$time_search_int] and $matched == 0
defined $time_search_array->[$time_search_int] $matched == 0
Truth table0%0/3
A and B
A= defined $time_search_array->[$time_search_int]B= $matched == 0
ABresult
0X0
100
111
426 defined( $time_search_array->[ $time_search_int ] ) &&
427 ( $matched == 0 )
428 ){
429 0 my $checked=0;
430 0 my $to_match=$time_search_array->[ $time_search_int ];
431 0 my $time=$proc->{time};
432 #checks for less than or equal
433 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\<\=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\<\=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\<\=/ and $checked == 0
$to_match =~ /^\<\=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\<\=/B= $checked == 0
ABresult
0X0
100
111
434 ( $to_match =~ /^\<\=/ ) &&
435 ( $checked == 0 )
436 ){
437 0 $checked++;
438 0 $to_match =~ s/^\<\=//;
439 0 ▶ if ( $time <= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time <= $to_match) 0 0 0
440 0 $hits++;
441 0 $matched++;
442 }
443 }
444  
445 #checks for less than
446 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\</ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\</ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\</ and $checked == 0
$to_match =~ /^\</ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\</B= $checked == 0
ABresult
0X0
100
111
447 ( $to_match =~ /^\</ ) &&
448 ( $checked == 0 )
449 ){
450 0 $checked++;
451 0 $to_match =~ s/^\<//;
452 0 ▶ if ( $time < $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time < $to_match) 0 0 0
453 0 $hits++;
454 0 $matched++;
455 }
456 }
457  
458 #checks for greater than or equal
459 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>=/ and $checked == 0
$to_match =~ /^\>=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>=/B= $checked == 0
ABresult
0X0
100
111
460 ( $to_match =~ /^\>=/ ) &&
461 ( $checked == 0 )
462 ){
463 0 $checked++;
464 0 $to_match =~ s/^\>\=//;
465 0 ▶ if ( $time >= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time >= $to_match) 0 0 0
466 0 $hits++;
467 0 $matched++;
468 }
469 }
470  
471 #checks for greater than
472 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>/ and $checked == 0
$to_match =~ /^\>/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>/B= $checked == 0
ABresult
0X0
100
111
473 ( $to_match =~ /^\>/ ) &&
474 ( $checked == 0 )
475 ){
476 0 $checked++;
477 0 $to_match =~ s/^\>//;
478 0 ▶ if ( $time > $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time > $to_match) 0 0 0
479 0 $hits++;
480 0 $matched++;
481 }
482 }
483 0 $time_search_int++;
484 }
485 }
486  
487 #check to see if it needs to search for CPU percent
488 0 my $pctcpu_search_array=$self->pctcpuSearchGet;
489 0 ▶ if ( defined( $pctcpu_search_array->[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pctcpu_search_array->[0]) 0 0 0
490 0 $required_hits++;
491 0 my $pctcpu_search_int=0;
492 0 my $matched=0;
493 #search while we have a CPU usage defined and it has not already been matched
494 0 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pctcpu_search_array->[$pctcpu_search_int] and $matched == 0) 0 0 0
Condition0%0/3
defined $pctcpu_search_array->[$pctcpu_search_int] and $matched == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pctcpu_search_array->[$pctcpu_search_int] and $matched == 0
defined $pctcpu_search_array->[$pctcpu_search_int] $matched == 0
Truth table0%0/3
A and B
A= defined $pctcpu_search_array->[$pctcpu_search_int]B= $matched == 0
ABresult
0X0
100
111
495 defined( $pctcpu_search_array->[ $pctcpu_search_int ] ) &&
496 ( $matched == 0 )
497 ){
498 0 my $checked=0;
499 0 my $to_match=$pctcpu_search_array->[ $pctcpu_search_int ];
500 0 my $time=$proc->{pctcpu};
501 #checks for less than or equal
502 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\<\=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\<\=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\<\=/ and $checked == 0
$to_match =~ /^\<\=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\<\=/B= $checked == 0
ABresult
0X0
100
111
503 ( $to_match =~ /^\<\=/ ) &&
504 ( $checked == 0 )
505 ){
506 0 $checked++;
507 0 $to_match =~ s/^\<\=//;
508 0 ▶ if ( $time <= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time <= $to_match) 0 0 0
509 0 $hits++;
510 0 $matched++;
511 }
512 }
513  
514 #checks for less than
515 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\</ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\</ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\</ and $checked == 0
$to_match =~ /^\</ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\</B= $checked == 0
ABresult
0X0
100
111
516 ( $to_match =~ /^\</ ) &&
517 ( $checked == 0 )
518 ){
519 0 $checked++;
520 0 $to_match =~ s/^\<//;
521 0 ▶ if ( $time < $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time < $to_match) 0 0 0
522 0 $hits++;
523 0 $matched++;
524 }
525 }
526  
527 #checks for greater than or equal
528 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>=/ and $checked == 0
$to_match =~ /^\>=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>=/B= $checked == 0
ABresult
0X0
100
111
529 ( $to_match =~ /^\>=/ ) &&
530 ( $checked == 0 )
531 ){
532 0 $checked++;
533 0 $to_match =~ s/^\>\=//;
534 0 ▶ if ( $time >= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time >= $to_match) 0 0 0
535 0 $hits++;
536 0 $matched++;
537 }
538 }
539  
540 #checks for greater than
541 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>/ and $checked == 0
$to_match =~ /^\>/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>/B= $checked == 0
ABresult
0X0
100
111
542 ( $to_match =~ /^\>/ ) &&
543 ( $checked == 0 )
544 ){
545 0 $checked++;
546 0 $to_match =~ s/^\>//;
547 0 ▶ if ( $time > $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time > $to_match) 0 0 0
548 0 $hits++;
549 0 $matched++;
550 }
551 }
552  
553 0 $pctcpu_search_int++;
554 }
555 }
556  
557 #check to see if it needs to search for memory percent
558 0 my $pctmem_search_array=$self->pctmemSearchGet;
559 0 ▶ if ( defined( $pctmem_search_array->[0] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pctmem_search_array->[0]) 0 0 0
560 0 $required_hits++;
561 0 my $pctmem_search_int=0;
562 0 my $matched=0;
563 #search while we have a memory usage defined and it has not already been matched
564 0 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pctmem_search_array->[$pctmem_search_int] and $matched == 0) 0 0 0
Condition0%0/3
defined $pctmem_search_array->[$pctmem_search_int] and $matched == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pctmem_search_array->[$pctmem_search_int] and $matched == 0
defined $pctmem_search_array->[$pctmem_search_int] $matched == 0
Truth table0%0/3
A and B
A= defined $pctmem_search_array->[$pctmem_search_int]B= $matched == 0
ABresult
0X0
100
111
565 defined( $pctmem_search_array->[ $pctmem_search_int ] ) &&
566 ( $matched == 0 )
567 ){
568 0 my $checked=0;
569 0 my $to_match=$pctmem_search_array->[ $pctmem_search_int ];
570 0 my $pctmem=$proc->{pctmem};
571 #checks for less than or equal
572 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\<\=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\<\=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\<\=/ and $checked == 0
$to_match =~ /^\<\=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\<\=/B= $checked == 0
ABresult
0X0
100
111
573 ( $to_match =~ /^\<\=/ ) &&
574 ( $checked == 0 )
575 ){
576 0 $checked++;
577 0 $to_match =~ s/^\<\=//;
578 0 ▶ if ( $pctmem <= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($pctmem <= $to_match) 0 0 0
579 0 $hits++;
580 0 $matched++;
581 }
582 }
583  
584 #checks for less than
585 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\</ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\</ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\</ and $checked == 0
$to_match =~ /^\</ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\</B= $checked == 0
ABresult
0X0
100
111
586 ( $to_match =~ /^\</ ) &&
587 ( $checked == 0 )
588 ){
589 0 $checked++;
590 0 $to_match =~ s/^\<//;
591 0 ▶ if ( $pctmem < $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($pctmem < $to_match) 0 0 0
592 0 $hits++;
593 0 $matched++;
594 }
595 }
596  
597 #checks for greater than or equal
598 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>=/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>=/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>=/ and $checked == 0
$to_match =~ /^\>=/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>=/B= $checked == 0
ABresult
0X0
100
111
599 ( $to_match =~ /^\>=/ ) &&
600 ( $checked == 0 )
601 ){
602 0 $checked++;
603 0 $to_match =~ s/^\>\=//;
604 0 ▶ if ( $pctmem >= $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($pctmem >= $to_match) 0 0 0
605 0 $hits++;
606 0 $matched++;
607 }
608 }
609  
610 #checks for greater than
611 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match =~ /^\>/ and $checked == 0) 0 0 0
Condition0%0/3
$to_match =~ /^\>/ and $checked == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$to_match =~ /^\>/ and $checked == 0
$to_match =~ /^\>/ $checked == 0
Truth table0%0/3
A and B
A= $to_match =~ /^\>/B= $checked == 0
ABresult
0X0
100
111
612 ( $to_match =~ /^\>/ ) &&
613 ( $checked == 0 )
614 ){
615 0 $checked++;
616 0 $to_match =~ s/^\>//;
617 0 ▶ if ( $pctmem > $to_match ){
Branch: 1 branch
BranchTrueFalseTotal
if ($pctmem > $to_match) 0 0 0
618 0 $hits++;
619 0 $matched++;
620 }
621 }
622
623 0 $pctmem_search_int++;
624 }
625 }
626
627 #show zombie procs
628 0 ▶ if ( $self->{zombie_search} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"zombie_search"}) 0 0 0
629 0 $required_hits++;
630 0 ▶ if ( $proc->{state} eq 'zombie' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($proc->{"state"} eq "zombie") 0 0 0
631 0 $hits++;
632 }
633 }
634  
635 #show swapped out procs
636 0 ▶ if ( $self->{swapped_out_search} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"swapped_out_search"}) 0 0 0
637 0 $required_hits++;
638 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($proc->{"state"} ne "zombie" and $proc->{"rss"} == 0) 0 0 0
Condition0%0/3
$proc->{"state"} ne "zombie" and $proc->{"rss"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$proc->{"state"} ne "zombie" and $proc->{"rss"} == 0
$proc->{"state"} ne "zombie" $proc->{"rss"} == 0
Truth table0%0/3
A and B
A= $proc->{"state"} ne "zombie"B= $proc->{"rss"} == 0
ABresult
0X0
100
111
639 ( $proc->{state} ne 'zombie' ) &&
640 ( $proc->{rss} == '0' )
641 ){
642 0 $hits++;
643 }
644 }
645  
646 #checks to see if it should ignore its self
647 0 my $self_ignore=$self->{self_ignore};
648 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($self_ignore == 1 and $proc->{'pid'} == $$) { } 0 0 0
elsif ($required_hits > 0 and $self_ignore == 2 and $proc->{'pid'} == $$) { } 0 0 0
Condition0%0/3
$self_ignore == 1 and $proc->{"pid"} == $$
!ll&&!rl&&r
000
MC/DC0%0/2
$self_ignore == 1 and $proc->{"pid"} == $$
$self_ignore == 1 $proc->{"pid"} == $$
Truth table0%0/3
A and B
A= $self_ignore == 1B= $proc->{"pid"} == $$
ABresult
0X0
100
111
649 #if it is set to 1
650 ( $self_ignore == 1 ) &&
651 ( $proc->{pid} == $$ )
652 ){
653 0 $required_hits++;
654 ▶ }elsif(
Condition0%0/6
$required_hits > 0 and $self_ignore == 2 and $proc->{"pid"} == $$
!ll&&!rl&&r
000
$required_hits > 0 and $self_ignore == 2
!ll&&!rl&&r
000
MC/DC0%0/3
$required_hits > 0 and $self_ignore == 2 and $proc->{"pid"} == $$
$required_hits > 0 $self_ignore == 2 $proc->{"pid"} == $$
Truth table0%0/4
A and B and C
A= $required_hits > 0B= $self_ignore == 2C= $proc->{"pid"} == $$
ABCresult
0XX0
10X0
1100
1111
655 #if it is set to 2... we only care if we are doing a search...
656 #meaning required hits are greater than zero
657 ( $required_hits > 0 ) &&
658 ( $self_ignore == 2 ) &&
659 ( $proc->{pid} == $$ )
660 ){
661 #increment this so it will always be off by one for this proc, meaning it is ignored
662 0 $required_hits++;
663 }
664  
665 0 ▶ if ( $required_hits == $hits ){
Branch: 1 branch
BranchTrueFalseTotal
if ($required_hits == $hits) 0 0 0
666 0 $show=1;
667 }
668 }
669  
670 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($show) 0 0 0
671 ( $show )
672 ){
673  
674 0 foreach my $field ( @{$fields} ){
675 0 my $item='';
676 0 ▶ if ( defined( $proc->{$field} ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{$field}) 0 0 0
677 0 $item=$proc->{$field};
678 }
679 #we will add proc later once we know the size of the table
680 0 ▶ if ($field ne 'proc'){
Branch: 1 branch
BranchTrueFalseTotal
if ($field ne 'proc') { } 0 0 0
681 0 ▶ if ( $field eq 'start' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($field eq "start") 0 0 0
682 0 $item=$self->startString($item);
683 }
684  
685 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($field eq "uid" and $self->{"resolveUser"}) 0 0 0
Condition0%0/3
$field eq "uid" and $self->{"resolveUser"}
!ll&&!rl&&r
000
MC/DC0%0/2
$field eq "uid" and $self->{"resolveUser"}
$field eq "uid" $self->{"resolveUser"}
Truth table0%0/3
A and B
A= $field eq "uid"B= $self->{"resolveUser"}
ABresult
0X0
100
111
686 ( $field eq 'uid' ) &&
687 $self->{resolveUser}
688 ){
689 0 $item=getpwuid($item);
690 }
691  
692 #colorizes it
693 0 ▶ if ( $field eq 'time' ){
Branch: 3 branches
BranchTrueFalseTotal
if ($field eq 'time') { } 0 0 0
elsif ($field eq 'proc') { } 0 0 0
elsif ($field eq 'info') { } 0 0 0
694 0 ▶ if ( $^O =~ 'linux' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /linux/) 0 0 0
695 0 $item=$item/1000000;
696 }
697 0 $item=$self->timeString($item);
698 }elsif( $field eq 'proc' ){
699 0 $item=color($self->processColorGet).$item;
700 }elsif( $field eq 'info'){
701 0 my $left=$proc->{state};
702 0 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($left eq 'sleep') { } 0 0 0
elsif ($left eq 'zombie') { } 0 0 0
elsif ($left eq 'wait') { } 0 0 0
elsif ($left eq 'run') { } 0 0 0
703 $left eq 'sleep'
704 ){
705 0 $left='S';
706 }elsif(
707 $left eq 'zombie'
708 ){
709 0 $left='Z';
710 }elsif(
711 $left eq 'wait'
712 ){
713 0 $left='W';
714 }elsif(
715 $left eq 'run'
716 ){
717 0 $left='R';
718 }
719  
720 #checks if it is swapped out
721 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($proc->{"state"} ne "zombie" and $proc->{"rss"} == 0) 0 0 0
Condition0%0/3
$proc->{"state"} ne "zombie" and $proc->{"rss"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$proc->{"state"} ne "zombie" and $proc->{"rss"} == 0
$proc->{"state"} ne "zombie" $proc->{"rss"} == 0
Truth table0%0/3
A and B
A= $proc->{"state"} ne "zombie"B= $proc->{"rss"} == 0
ABresult
0X0
100
111
722 ( $proc->{state} ne 'zombie' ) &&
723 ( $proc->{rss} == '0' )
724 ){
725 0 $left=$left.'O';
726 }
727  
728 #waiting to exit
729 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"working_on_exiting"} and $proc->{"working_on_exiting"}) 0 0 0
Condition0%0/3
defined $proc->{"working_on_exiting"} and $proc->{"working_on_exiting"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"working_on_exiting"} and $proc->{"working_on_exiting"}
defined $proc->{"working_on_exiting"} $proc->{"working_on_exiting"}
Truth table0%0/3
A and B
A= defined $proc->{"working_on_exiting"}B= $proc->{"working_on_exiting"}
ABresult
0X0
100
111
730 ( defined( $proc->{working_on_exiting} ) ) &&
731 $proc->{working_on_exiting}
732 ){
733 0 $left=$left.'E';
734 }
735  
736 #session leader
737 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"is_session_leader"} and $proc->{"is_session_leader"}) 0 0 0
Condition0%0/3
defined $proc->{"is_session_leader"} and $proc->{"is_session_leader"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"is_session_leader"} and $proc->{"is_session_leader"}
defined $proc->{"is_session_leader"} $proc->{"is_session_leader"}
Truth table0%0/3
A and B
A= defined $proc->{"is_session_leader"}B= $proc->{"is_session_leader"}
ABresult
0X0
100
111
738 ( defined( $proc->{is_session_leader} ) ) &&
739 $proc->{is_session_leader}
740 ){
741 0 $left=$left.'s';
742 }
743  
744 #checks to see if any sort of locks are present
745 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"is_locked"} || defined $proc->{"posix_advisory_lock"} and $proc->{"is_locked"} || $proc->{"posix_advisory_lock"}) 0 0 0
Condition0%0/9
defined $proc->{"is_locked"} || defined $proc->{"posix_advisory_lock"} and $proc->{"is_locked"} || $proc->{"posix_advisory_lock"}
!ll&&!rl&&r
000
defined $proc->{"is_locked"} or defined $proc->{"posix_advisory_lock"}
l!l&&r!l&&!r
000
$proc->{"is_locked"} or $proc->{"posix_advisory_lock"}
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $proc->{"is_locked"} || defined $proc->{"posix_advisory_lock"} and $proc->{"is_locked"} || $proc->{"posix_advisory_lock"}
defined $proc->{"is_locked"} defined $proc->{"posix_advisory_lock"} $proc->{"is_locked"} $proc->{"posix_advisory_lock"}
Truth table0%0/7
A or B and C or D
A= defined $proc->{"is_locked"}B= defined $proc->{"posix_advisory_lock"}C= $proc->{"is_locked"}D= $proc->{"posix_advisory_lock"}
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
746 ( defined( $proc->{is_locked} ) || defined( $proc->{posix_advisory_lock} ) )&&
747 ( $proc->{is_locked} || $proc->{posix_advisory_lock} )
748 ){
749 0 $left=$left.'L';
750 }
751  
752 #checks to see if has a controlling terminal
753 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"has_controlling_terminal"} and $proc->{"has_controlling_terminal"}) 0 0 0
Condition0%0/3
defined $proc->{"has_controlling_terminal"} and $proc->{"has_controlling_terminal"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"has_controlling_terminal"} and $proc->{"has_controlling_terminal"}
defined $proc->{"has_controlling_terminal"} $proc->{"has_controlling_terminal"}
Truth table0%0/3
A and B
A= defined $proc->{"has_controlling_terminal"}B= $proc->{"has_controlling_terminal"}
ABresult
0X0
100
111
754 ( defined( $proc->{has_controlling_terminal} ) ) &&
755 $proc->{has_controlling_terminal}
756 ){
757 0 $left=$left.'+';
758 }
759  
760 #if it is being forked
761 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"is_being_forked"} and $proc->{"is_being_forked"}) 0 0 0
Condition0%0/3
defined $proc->{"is_being_forked"} and $proc->{"is_being_forked"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"is_being_forked"} and $proc->{"is_being_forked"}
defined $proc->{"is_being_forked"} $proc->{"is_being_forked"}
Truth table0%0/3
A and B
A= defined $proc->{"is_being_forked"}B= $proc->{"is_being_forked"}
ABresult
0X0
100
111
762 ( defined( $proc->{is_being_forked} ) ) &&
763 $proc->{is_being_forked}
764 ){
765 0 $left=$left.'F';
766 }
767  
768 #checks if it knows it is being traced
769 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proc->{"traced_by_debugger"} and $proc->{"traced_by_debugger"}) 0 0 0
Condition0%0/3
defined $proc->{"traced_by_debugger"} and $proc->{"traced_by_debugger"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $proc->{"traced_by_debugger"} and $proc->{"traced_by_debugger"}
defined $proc->{"traced_by_debugger"} $proc->{"traced_by_debugger"}
Truth table0%0/3
A and B
A= defined $proc->{"traced_by_debugger"}B= $proc->{"traced_by_debugger"}
ABresult
0X0
100
111
770 ( defined( $proc->{traced_by_debugger} ) ) &&
771 $proc->{traced_by_debugger}
772 ){
773 0 $left=$left.'X';
774 }
775  
776 0 ▶ if ( $^O =~ 'linux' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /linux/) { } 0 0 0
777 0 my $wchan='';
778 0 ▶ if ( -e '/proc/'.$proc->{pid}.'/wchan'){
Branch: 1 branch
BranchTrueFalseTotal
if (-e '/proc/' . $proc->{"pid"} . '/wchan') 0 0 0
779 0 open( my $wchan_fh, '<', '/proc/'.$proc->{pid}.'/wchan' );
780 0 $wchan=readline( $wchan_fh );
781 0 close( $wchan_fh );
782 }
783 0 $item=color($self->nextColor).$left.' '.color($self->nextColor).$wchan;
784 }else{
785 0 $item=color($self->nextColor).$left.' '.color($self->nextColor).$proc->{wchan};
786 }
787  
788 }else{
789 0 $item=color($self->nextColor).$item;
790 }
791  
792 0 push( @line, $item.color('reset') );
793 }else{
794 0 push( @proc_column, $item );
795 }
796 }
797  
798 0 push( @colored, \@line );
799 }
800 }
801  
802 #get table width info
803 0 my $tb = Text::Table->new;
804 0 $tb->load( @colored );
805 0 my $width=$tb->width;
806 0 my ($columns, $rows) = Term::Size::chars *STDOUT{IO};
807 0 $tb->clear;
808  
809 #add 120 as Text::Table appears to be off by that much
810 0 $columns=$columns+128;
811  
812 0 ▶ if ( $^O =~ 'linux' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /linux/) 0 0 0
813 0 $columns=$columns-12;
814 }
815  
816 #this is
817 0 my $procwidth=$columns-$width;
818  
819 #process each colored item and shove the proc info in
820 0 my $colored_int=1;
821 0 my $proc_column_int=0;
822 0 ▶ while ( defined( $colored[$colored_int] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $colored[$colored_int]) 0 0 0
823 0 my $item=$proc_column[$proc_column_int];
824 #remove all the newlines
825 0 $item=~s/\n//g;
826  
827 0 $item=substr( $item, 0, $procwidth);
828  
829 0 push( @{$colored[$colored_int]}, $item );
830  
831 0 $proc_column_int++;
832 0 $colored_int++;
833 }
834  
835 0 return $tb->load( @colored );
836 }
837  
838 =head2 fields
839  
840 Gets a hash of possible fields from Proc::ProcessTable as an hash.
841  
842 This is really meant as a internal function.
843  
844 =cut
845  
846 0 ▶sub fields{
Subroutine fields: not called CC=2 SCAR=17.9
Pod documented
847 0 my $self=$_[0];
848 0 $self->errorblank;
849  
850 0 my $p=Proc::ProcessTable->new;
851 0 my @fields=$p->fields;
852  
853 0 my $int=0;
854 0 my %toReturn;
855 0 ▶ while( defined($fields[$int]) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields[$int]) 0 0 0
856 0 $toReturn{$fields[$int]}=1;
857  
858 0 $int++;
859 }
860  
861 0 return %toReturn;
862 }
863  
864 =head2 fieldsGet
865  
866 Gets the currently set fields.
867  
868 Returns a array ref of current fields to be printed.
869  
870 my $fields=$cps->fieldsGet;
871  
872 =cut
873  
874 0 ▶sub fieldsGet{
Subroutine fieldsGet: not called CC=1 SCAR=6.9
Pod documented
875 0 my $self=$_[0];
876 0 $self->errorblank;
877  
878 0 return $self->{fields};
879 }
880  
881 =head2 nextColor
882  
883 Returns the next color.
884  
885 my $nextColor=$cps->nextColor;
886  
887 =cut
888  
889 0 ▶sub nextColor{
Subroutine nextColor: not called CC=2 SCAR=17.9
Pod documented
890 0 my $self=$_[0];
891 0 $self->errorblank;
892  
893 0 my $color;
894  
895 0 ▶ if( defined( $self->{colors}[ $self->{nextColor} ] ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'colors'}[$self->{'nextColor'}]) { } 0 0 0
896 0 $color=$self->{colors}[ $self->{nextColor} ];
897 0 $self->{nextColor}++;
898 }else{
899 0 $self->{nextColor}=0;
900 0 $color=$self->{colors}[ $self->{nextColor} ];
901 0 $self->{nextColor}++;
902 }
903  
904 0 return $color;
905 }
906  
907 =head2 nextColor
908  
909 Resets the next color to the first one.
910  
911 my $nextColor=$cps->nextColor;
912  
913 =cut
914  
915 0 ▶sub nextColorReset{
Subroutine nextColorReset: not called CC=1 SCAR=6.9
Pod undocumented
916 0 my $self=$_[0];
917 0 $self->errorblank;
918  
919 0 $self->{nextColor}=0;
920  
921 0 return 1;
922 }
923  
924 =head2 fieldsSet
925  
926 Gets the currently set fields.
927  
928 Returns a list of current fields to be printed.
929  
930 my @fields=$cps->fieldsGet;
931  
932 =cut
933  
934 0 ▶sub fieldsSet{
Subroutine fieldsSet: not called CC=1 SCAR=6.9
Pod documented
935 0 my $self=$_[0];
936 0 $self->errorblank;
937  
938  
939 }
940  
941 =head2 pctcpuSearchGet
942  
943 Returns the current value for the PCT CPU search.
944  
945 The return is a array ref.
946  
947 my $pctcpu_search=$cps->pctcpuSearchGet;
948  
949 =cut
950  
951 0 ▶sub pctcpuSearchGet{
Subroutine pctcpuSearchGet: not called CC=1 SCAR=6.9
Pod documented
952 0 my $self=$_[0];
953 0 $self->errorblank;
954  
955 0 return $self->{pctcpu_search};
956 }
957  
958 =head2 pctcpuSearchSetString
959  
960 Search for procs based on the CPU usage.
961  
962 The following equalities are understood.
963  
964 <=
965 <
966 >
967 >=
968  
969 The string may contain multiple values seperated by a comma. Checking will stop after the first hit.
970  
971 If the string is undef, all procs will be shown.
972  
973 #search for procs with less than 60% of CPU usage
974 $cps->pctcpuSearchSetString('<60');
975 #shows procs with greater than 60% of CPU usage
976 $cps->pctcpuSearchSetString('>60');
977  
978 =cut
979  
980 0 ▶sub pctcpuSearchSetString{
Subroutine pctcpuSearchSetString: not called CC=15 SCAR=54.8
Pod documented
981 0 my $self=$_[0];
982 0 my $pctcpu_search_string=$_[1];
983 0 $self->errorblank;
984  
985 0 my @pctcpu_search_array;
986 0 ▶ if ( ! defined( $pctcpu_search_string ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $pctcpu_search_string) { } 0 0 0
987 0 $self->{pctcpu_search}=\@pctcpu_search_array;
988 }else{
989 0 @pctcpu_search_array=split(/\,/, $pctcpu_search_string);
990  
991 0 foreach my $item ( @pctcpu_search_array ){
992 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<\=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/) 0 0 0
Condition0%0/33
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<\=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<\=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<\=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
MC/DC0%0/12
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<\=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
$item =~ /^\>[0123456789]*$/ $item =~ /^\>[0123456789]*\.[0123456789]*$/ $item =~ /^\>\.[0123456789]*$/ $item =~ /^\>\=[0123456789]*$/ $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ $item =~ /^\>\=\.[0123456789]*$/ $item =~ /^\<[0123456789]*$/ $item =~ /^\<[0123456789]*\.[0123456789]*$/ $item =~ /^\<\.[0123456789]*$/ $item =~ /^\<\=[0123456789]*$/ $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ $item =~ /^\<\=\.[0123456789]*$/
Truth table0%0/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $item =~ /^\>[0123456789]*$/B= $item =~ /^\>[0123456789]*\.[0123456789]*$/C= $item =~ /^\>\.[0123456789]*$/D= $item =~ /^\>\=[0123456789]*$/E= $item =~ /^\>\=[0123456789]*\.[0123456789]*$/F= $item =~ /^\>\=\.[0123456789]*$/G= $item =~ /^\<[0123456789]*$/H= $item =~ /^\<[0123456789]*\.[0123456789]*$/I= $item =~ /^\<\.[0123456789]*$/J= $item =~ /^\<\=[0123456789]*$/K= $item =~ /^\<\=[0123456789]*\.[0123456789]*$/L= $item =~ /^\<\=\.[0123456789]*$/
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
993 ( $item !~ /^\>[0123456789]*$/ ) &&
994 ( $item !~ /^\>[0123456789]*\.[0123456789]*$/ ) &&
995 ( $item !~ /^\>\.[0123456789]*$/ ) &&
996 ( $item !~ /^\>\=[0123456789]*$/ ) &&
997 ( $item !~ /^\>\=[0123456789]*\.[0123456789]*$/ ) &&
998 ( $item !~ /^\>\=\.[0123456789]*$/ ) &&
999 ( $item !~ /^\<[0123456789]*$/ ) &&
1000 ( $item !~ /^\<[0123456789]*\.[0123456789]*$/ ) &&
1001 ( $item !~ /^\<\.[0123456789]*$/ ) &&
1002 ( $item !~ /^\<\=[0123456789]*$/ ) &&
1003 ( $item !~ /^\<\=[0123456789]*\.[0123456789]*$/ ) &&
1004 ( $item !~ /^\<\=\.[0123456789]*$/ )
1005 ){
1006 0 $self->{error}=2;
1007 0 $self->{errorString}='"'.$item.'"" is not a valid value for use in a PCT CPU search';
1008 0 $self->warn;
1009 0 return undef;
1010 }
1011  
1012 }
1013  
1014 0 $self->{pctcpu_search}=\@pctcpu_search_array;
1015 }
1016  
1017 0 return 1;
1018 }
1019  
1020 =head2 pctmemSearchGet
1021  
1022 Returns the current value for the PCT MEM search.
1023  
1024 The return is a array ref.
1025  
1026 my $pctmem_search=$cps->pctmemSearchGet;
1027  
1028 =cut
1029  
1030 0 ▶sub pctmemSearchGet{
Subroutine pctmemSearchGet: not called CC=1 SCAR=6.9
Pod documented
1031 0 my $self=$_[0];
1032 0 $self->errorblank;
1033  
1034 0 return $self->{pctmem_search};
1035 }
1036  
1037 =head2 pctmemSearchSetString
1038  
1039 Search for procs based on the memory usage.
1040  
1041 The following equalities are understood.
1042  
1043 <=
1044 <
1045 >
1046 >=
1047  
1048 The string may contain multiple values seperated by a comma. Checking will stop after the first hit.
1049  
1050 If the string is undef, all procs will be shown.
1051  
1052 #search for procs with less than 60% of the memory
1053 $cps->pctmemSearchSetString('<60');
1054 #shows procs with greater than 60% of the memory
1055 $cps->pctmemSearchSetString('>60');
1056  
1057 =cut
1058  
1059 0 ▶sub pctmemSearchSetString{
Subroutine pctmemSearchSetString: not called CC=15 SCAR=54.8
Pod documented
1060 0 my $self=$_[0];
1061 0 my $pctmem_search_string=$_[1];
1062 0 $self->errorblank;
1063  
1064 0 my @pctmem_search_array;
1065 0 ▶ if ( ! defined( $pctmem_search_string ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $pctmem_search_string) { } 0 0 0
1066 0 $self->{pctmem_search}=\@pctmem_search_array;
1067 }else{
1068 0 @pctmem_search_array=split(/\,/, $pctmem_search_string);
1069  
1070 0 foreach my $item ( @pctmem_search_array ){
1071 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/) 0 0 0
Condition0%0/33
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
MC/DC0%0/12
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>\=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
$item =~ /^\>[0123456789]*$/ $item =~ /^\>[0123456789]*\.[0123456789]*$/ $item =~ /^\>\.[0123456789]*$/ $item =~ /^\>\=[0123456789]*$/ $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ $item =~ /^\>\=\.[0123456789]*$/ $item =~ /^\<[0123456789]*$/ $item =~ /^\<[0123456789]*\.[0123456789]*$/ $item =~ /^\<\.[0123456789]*$/ $item =~ /^\<=[0123456789]*$/ $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ $item =~ /^\<\=\.[0123456789]*$/
Truth table0%0/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $item =~ /^\>[0123456789]*$/B= $item =~ /^\>[0123456789]*\.[0123456789]*$/C= $item =~ /^\>\.[0123456789]*$/D= $item =~ /^\>\=[0123456789]*$/E= $item =~ /^\>\=[0123456789]*\.[0123456789]*$/F= $item =~ /^\>\=\.[0123456789]*$/G= $item =~ /^\<[0123456789]*$/H= $item =~ /^\<[0123456789]*\.[0123456789]*$/I= $item =~ /^\<\.[0123456789]*$/J= $item =~ /^\<=[0123456789]*$/K= $item =~ /^\<\=[0123456789]*\.[0123456789]*$/L= $item =~ /^\<\=\.[0123456789]*$/
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
1072 ( $item !~ /^\>[0123456789]*$/ ) &&
1073 ( $item !~ /^\>[0123456789]*\.[0123456789]*$/ ) &&
1074 ( $item !~ /^\>\.[0123456789]*$/ ) &&
1075 ( $item !~ /^\>\=[0123456789]*$/ ) &&
1076 ( $item !~ /^\>\=[0123456789]*\.[0123456789]*$/ ) &&
1077 ( $item !~ /^\>\=\.[0123456789]*$/ ) &&
1078 ( $item !~ /^\<[0123456789]*$/ ) &&
1079 ( $item !~ /^\<[0123456789]*\.[0123456789]*$/ ) &&
1080 ( $item !~ /^\<\.[0123456789]*$/ ) &&
1081 ( $item !~ /^\<=[0123456789]*$/ ) &&
1082 ( $item !~ /^\<\=[0123456789]*\.[0123456789]*$/ ) &&
1083 ( $item !~ /^\<\=\.[0123456789]*$/ )
1084 ){
1085 0 $self->{error}=3;
1086 0 $self->{errorString}='"'.$item.'"" is not a valid value for use in a PCT MEM search';
1087 0 $self->warn;
1088 0 return undef;
1089 }
1090  
1091 }
1092  
1093 0 $self->{pctmem_search}=\@pctmem_search_array;
1094 }
1095  
1096 0 return 1;
1097 }
1098  
1099 =head2 processColorGet
1100  
1101 my $timeColors=$cps->processColorGet;
1102  
1103 =cut
1104  
1105 0 ▶sub processColorGet{
Subroutine processColorGet: not called CC=1 SCAR=6.9
Pod documented
1106 0 my $self=$_[0];
1107 0 $self->errorblank;
1108  
1109 0 return $self->{processColor};
1110 }
1111  
1112 =head2 procSearchGet
1113  
1114 This returns the search string value that will be used
1115 for matching the proc column.
1116  
1117 The return is undefined if one is not set.
1118  
1119 my $search_regex=$cps->procSearchGet;
1120 if ( defined( $search_regex ) ){
1121 print "search regex: ".$search_regex."\n";
1122 }else{
1123 print "No search regex.\n";
1124 }
1125  
1126 =cut
1127  
1128 0 ▶sub procSearchGet{
Subroutine procSearchGet: not called CC=1 SCAR=6.9
Pod documented
1129 0 my $self=$_[0];
1130 0 $self->errorblank;
1131  
1132 0 return $self->{proc_search};
1133 }
1134  
1135 =head2 procSearchSet
1136  
1137 This sets the proc column search regex to use.
1138  
1139 If set to undef(the default), then it will show all procs.
1140  
1141 #shows everything
1142 $cps->procSearchSet( undef );
1143  
1144 #search for only those matching musicpd
1145 $cps->procSeearchSet( 'musicpd' );
1146  
1147 #search for those that match /[Zz]whatever/
1148 $cps->procSearchSet( '[Zz]whatever' );
1149  
1150 =cut
1151  
1152 0 ▶sub procSearchSet{
Subroutine procSearchSet: not called CC=1 SCAR=6.9
Pod documented
1153 0 my $self=$_[0];
1154 0 my $proc_search=$_[1];
1155 0 $self->errorblank;
1156  
1157 0 $self->{proc_search}=$proc_search;
1158  
1159 0 return 1;
1160 }
1161  
1162 =head2 selfIgnoreGet
1163  
1164 =cut
1165  
1166 0 ▶sub selfIgnoreGet{
Subroutine selfIgnoreGet: not called CC=1 SCAR=6.9
Pod documented
1167 0 my $self=$_[0];
1168 0 $self->errorblank;
1169  
1170 0 return $self->{self_ignore};
1171 }
1172  
1173 =head2 selfIgnoreSet
1174  
1175 Wether or not to show the PID of this processes in the list.
1176  
1177 =head3 undef
1178  
1179 Resets it to the default, 2.
1180  
1181 =head3 0
1182  
1183 Always show self PID in the list.
1184  
1185 =head3 1
1186  
1187 Never show self PID in the list.
1188  
1189 =head3 2
1190  
1191 Don't show self PID if it is a search.
1192  
1193 This is the default.
1194  
1195 =cut
1196  
1197 0 ▶sub selfIgnoreSet{
Subroutine selfIgnoreSet: not called CC=2 SCAR=17.9
Pod documented
1198 0 my $self=$_[0];
1199 0 my $self_ignore=$_[1];
1200 0 $self->errorblank;
1201  
1202 0 ▶ if ( ! defined( $self_ignore ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self_ignore) 0 0 0
1203 0 $self_ignore='2';
1204 }
1205  
1206 0 $self->{self_ignore}=$self_ignore;
1207  
1208 0 return 1;
1209 }
1210  
1211 =head2 startString
1212  
1213 Generates a short time string based on the supplied unix time.
1214  
1215 =cut
1216  
1217 0 ▶sub startString{
Subroutine startString: not called CC=4 SCAR=30.0
Pod documented
1218 0 my $self=$_[0];
1219 0 my $startTime=$_[1];
1220 0 $self->errorblank;
1221  
1222 0 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($startTime);
1223 0 my ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime(time);
1224  
1225 #add the required stuff to make this sane
1226 0 $year += 1900;
1227 0 $cyear += 1900;
1228 0 $mon += 1;
1229 0 $cmon += 1;
1230  
1231 #find the most common one and return it
1232 0 ▶ if ( $year ne $cyear ){
Branch: 1 branch
BranchTrueFalseTotal
if ($year ne $cyear) 0 0 0
1233 0 return $year.sprintf('%02d', $mon).sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min);
1234 }
1235 0 ▶ if ( $mon ne $cmon ){
Branch: 1 branch
BranchTrueFalseTotal
if ($mon ne $cmon) 0 0 0
1236 0 return sprintf('%02d', $mon).sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min);
1237 }
1238 0 ▶ if ( $mday ne $cmday ){
Branch: 1 branch
BranchTrueFalseTotal
if ($mday ne $cmday) 0 0 0
1239 0 return sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min);
1240 }
1241  
1242 #just return this for anything less
1243 0 return sprintf('%02d', $hour).':'.sprintf('%02d', $min);
1244 }
1245  
1246 =head2 swappedOutSearchGet
1247  
1248 Returns the current value for the swapped out search.
1249  
1250 The return is a Perl boolean.
1251  
1252 my $swappedOut_search=$cps->swappedOutSearchGet;
1253 if ( $swappedOut_search ){
1254 print "only swapped out procs will be shown";
1255 }
1256  
1257 =cut
1258  
1259 0 ▶sub swappedOutSearchGet{
Subroutine swappedOutSearchGet: not called CC=1 SCAR=6.9
Pod documented
1260 0 my $self=$_[0];
1261 0 $self->errorblank;
1262  
1263 0 return $self->{swapped_out_search};
1264 }
1265  
1266 =head2 swappedOutSearchSet
1267  
1268 Sets the swapped out search value.
1269  
1270 The value taken is a Perl boolean.
1271  
1272 $cps->swappedOutSearchSet( 1 );
1273  
1274 =cut
1275  
1276 0 ▶sub swappedOutSearchSet{
Subroutine swappedOutSearchSet: not called CC=1 SCAR=6.9
Pod documented
1277 0 my $self=$_[0];
1278 0 my $swapped_out_search=$_[1];
1279 0 $self->errorblank;
1280  
1281 0 $self->{swapped_out_search}=$swapped_out_search;
1282  
1283 0 return 1;
1284 }
1285  
1286 =head2 timeColorsGet
1287  
1288 my $timeColors=$cps->timeColorsGet;
1289  
1290 =cut
1291  
1292 0 ▶sub timeColorsGet{
Subroutine timeColorsGet: not called CC=1 SCAR=6.9
Pod documented
1293 0 my $self=$_[0];
1294 0 $self->errorblank;
1295  
1296 0 return $self->{timeColors};
1297 }
1298  
1299 =head2 timeSearchGet
1300  
1301 Returns the current value for the time search.
1302  
1303 The return is a array ref.
1304  
1305 my $time_search=$cps->waitSearchGet;
1306  
1307 =cut
1308  
1309 0 ▶sub timeSearchGet{
Subroutine timeSearchGet: not called CC=1 SCAR=6.9
Pod documented
1310 0 my $self=$_[0];
1311 0 $self->errorblank;
1312  
1313 0 return $self->{time_search};
1314 }
1315  
1316 =head2 timeSearchSetString
1317  
1318 Search for procs based on the CPU time value.
1319  
1320 The following equalities are understood.
1321  
1322 <=
1323 <
1324 >
1325 >=
1326  
1327 The string may contain multiple values seperated by a comma. Checking will stop after the first hit.
1328  
1329 If the string is undef, all wait channels will be shown.
1330  
1331 #search for procs with less than 60 seconds of CPU time
1332 $cps->waitSearchSetString('<69');
1333 #shows procs with less than 60 seconds and greater 120 seconds
1334 $cps->waitSearchSetString('<60,>120');
1335  
1336 =cut
1337  
1338 0 ▶sub timeSearchSetString{
Subroutine timeSearchSetString: not called CC=15 SCAR=54.8
Pod documented
1339 0 my $self=$_[0];
1340 0 my $time_search_string=$_[1];
1341 0 $self->errorblank;
1342  
1343 0 my @time_search_array;
1344 0 ▶ if ( ! defined( $time_search_string ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $time_search_string) { } 0 0 0
1345 0 $self->{time_search}=\@time_search_array;
1346 }else{
1347 0 @time_search_array=split(/\,/, $time_search_string);
1348  
1349 0 foreach my $item ( @time_search_array ){
1350 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/) 0 0 0
Condition0%0/33
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/
l!l&&r!l&&!r
000
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/
l!l&&r!l&&!r
000
MC/DC0%0/12
$item =~ /^\>[0123456789]*$/ or $item =~ /^\>[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\.[0123456789]*$/ or $item =~ /^\>=[0123456789]*$/ or $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\>\=\.[0123456789]*$/ or $item =~ /^\<[0123456789]*$/ or $item =~ /^\<[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\.[0123456789]*$/ or $item =~ /^\<=[0123456789]*$/ or $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ or $item =~ /^\<\=\.[0123456789]*$/
$item =~ /^\>[0123456789]*$/ $item =~ /^\>[0123456789]*\.[0123456789]*$/ $item =~ /^\>\.[0123456789]*$/ $item =~ /^\>=[0123456789]*$/ $item =~ /^\>\=[0123456789]*\.[0123456789]*$/ $item =~ /^\>\=\.[0123456789]*$/ $item =~ /^\<[0123456789]*$/ $item =~ /^\<[0123456789]*\.[0123456789]*$/ $item =~ /^\<\.[0123456789]*$/ $item =~ /^\<=[0123456789]*$/ $item =~ /^\<\=[0123456789]*\.[0123456789]*$/ $item =~ /^\<\=\.[0123456789]*$/
Truth table0%0/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $item =~ /^\>[0123456789]*$/B= $item =~ /^\>[0123456789]*\.[0123456789]*$/C= $item =~ /^\>\.[0123456789]*$/D= $item =~ /^\>=[0123456789]*$/E= $item =~ /^\>\=[0123456789]*\.[0123456789]*$/F= $item =~ /^\>\=\.[0123456789]*$/G= $item =~ /^\<[0123456789]*$/H= $item =~ /^\<[0123456789]*\.[0123456789]*$/I= $item =~ /^\<\.[0123456789]*$/J= $item =~ /^\<=[0123456789]*$/K= $item =~ /^\<\=[0123456789]*\.[0123456789]*$/L= $item =~ /^\<\=\.[0123456789]*$/
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
1351 ( $item !~ /^\>[0123456789]*$/ ) &&
1352 ( $item !~ /^\>[0123456789]*\.[0123456789]*$/ ) &&
1353 ( $item !~ /^\>\.[0123456789]*$/ ) &&
1354 ( $item !~ /^\>=[0123456789]*$/ ) &&
1355 ( $item !~ /^\>\=[0123456789]*\.[0123456789]*$/ ) &&
1356 ( $item !~ /^\>\=\.[0123456789]*$/ ) &&
1357 ( $item !~ /^\<[0123456789]*$/ ) &&
1358 ( $item !~ /^\<[0123456789]*\.[0123456789]*$/ ) &&
1359 ( $item !~ /^\<\.[0123456789]*$/ ) &&
1360 ( $item !~ /^\<=[0123456789]*$/ ) &&
1361 ( $item !~ /^\<\=[0123456789]*\.[0123456789]*$/ ) &&
1362 ( $item !~ /^\<\=\.[0123456789]*$/ )
1363 ){
1364 0 $self->{error}=1;
1365 0 $self->{errorString}='"'.$item.'"" is not a valid value for use in a time search';
1366 0 $self->warn;
1367 0 return undef;
1368 }
1369  
1370 }
1371  
1372 0 $self->{time_search}=\@time_search_array;
1373 }
1374  
1375 0 return 1;
1376 }
1377  
1378 =head2 timeString
1379  
1380 Turns the raw run string into something usable.
1381  
1382 This returns a colorized item.
1383  
1384 my $time=$cps->timeString( $seconds );
1385  
1386 =cut
1387  
1388 0 ▶sub timeString{
Subroutine timeString: not called CC=7 SCAR=40.3
Pod documented
1389 0 my $self=$_[0];
1390 0 my $time=$_[1];
1391 0 $self->errorblank;
1392  
1393 0 my $colors=$self->timeColorsGet;
1394  
1395 0 my $hours=0;
1396 0 ▶ if ( $time >= 3600 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time >= 3600) 0 0 0
1397 0 $hours = $time / 3600;
1398 }
1399 0 my $loSeconds = $time % 3600;
1400 0 my $minutes=0;
1401 0 ▶ if ( $time >= 60 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($time >= 60) 0 0 0
1402 0 $minutes = $loSeconds / 60;
1403 }
1404 0 my $seconds = $loSeconds % 60;
1405  
1406 #nicely format it
1407 0 $hours=~s/\..*//;
1408 0 $minutes=~s/\..*//;
1409 0 $seconds=sprintf('%.f',$seconds);
1410  
1411 #this will be returned
1412 0 my $toReturn='';
1413  
1414 #process the hours bit
1415 0 ▶ if ( $hours == 0 ){
Branch: 2 branches
BranchTrueFalseTotal
if ($hours == 0) { } 0 0 0
elsif ($hours >= 10) { } 0 0 0
1416 #don't do anything if time is 0
1417 }elsif(
1418 $hours >= 10
1419 ){
1420 0 $toReturn=color($colors->[3]).$hours.':';
1421 }else{
1422 0 $toReturn=color($colors->[2]).$hours.':';
1423 }
1424  
1425 #process the minutes bit
1426 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($hours > 0 or $minutes > 0) 0 0 0
Condition0%0/3
$hours > 0 or $minutes > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$hours > 0 or $minutes > 0
$hours > 0 $minutes > 0
Truth table0%0/3
A or B
A= $hours > 0B= $minutes > 0
ABresult
1X1
011
000
1427 ( $hours > 0 ) ||
1428 ( $minutes > 0 )
1429 ){
1430 0 $toReturn=$toReturn.color( $colors->[1] ). $minutes.':';
1431 }
1432  
1433 0 $toReturn=$toReturn.color( $colors->[0] ).$seconds;
1434  
1435 0 return $toReturn;
1436 }
1437  
1438 =head1 userSearchGet
1439  
1440 This gets the user to be searched for and if it should be inverted or not.
1441  
1442 This returns an array reference of users to search for.
1443  
1444 An selection can be inverted via !.
1445  
1446 my $user_search=$cps->userSearchGet;
1447  
1448 =cut
1449  
1450 0 ▶sub userSearchGet{
Subroutine userSearchGet: not called CC=1 SCAR=6.9
Pod undocumented
1451 0 my $self=$_[0];
1452 0 $self->errorblank;
1453  
1454 0 return $self->{user_search};
1455 }
1456  
1457 =head1 userSearchSetString
1458  
1459 This takes a string to set the user search for.
1460  
1461 An selection can be inverted via !.
1462  
1463 The string may contain multiple users seperated by a comma.
1464  
1465 If the string is undef, all users will be shown.
1466  
1467 #search for user foo and bar
1468 $cps->userSearchSetString('foo,bar');
1469 #show users not matching foo
1470 $cps->userSearchSetString('!foo');
1471 #show all users, clearing any previous settings
1472 $cps->userSearchSetString;
1473  
1474 =cut
1475  
1476 0 ▶sub userSearchSetString{
Subroutine userSearchSetString: not called CC=2 SCAR=17.9
Pod undocumented
1477 0 my $self=$_[0];
1478 0 my $user_search_string=$_[1];
1479 0 $self->errorblank;
1480  
1481 0 my @user_search_array;
1482 0 ▶ if ( ! defined( $user_search_string ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $user_search_string) { } 0 0 0
1483 0 $self->{user_search}=\@user_search_array;
1484 }else{
1485 0 @user_search_array=split(/\,/, $user_search_string);
1486 0 $self->{user_search}=\@user_search_array;
1487 }
1488  
1489 0 return 1;
1490 }
1491  
1492 =head2 waitSearchGet
1493  
1494 Returns the current value for the wait search.
1495  
1496 The return is a array ref.
1497  
1498 my $wait_search=$cps->waitSearchGet;
1499  
1500 =cut
1501  
1502 0 ▶sub waitSearchGet{
Subroutine waitSearchGet: not called CC=1 SCAR=6.9
Pod documented
1503 0 my $self=$_[0];
1504 0 $self->errorblank;
1505  
1506 0 return $self->{wait_search};
1507 }
1508  
1509 =head2 waitSearchSetString
1510  
1511 This takes a string to set the wait channel search for.
1512  
1513 An selection can be inverted via !.
1514  
1515 The string may contain multiple users seperated by a comma.
1516  
1517 If the string is undef, all wait channels will be shown.
1518  
1519 #search for wait channel wait and sleep
1520 $cps->waitSearchSetString('wait,sleep');
1521 #shows wait channels not matching sbwait
1522 $cps->waitSearchSetString('!sbwait');
1523 #show all users, clearing any previous settings
1524 $cps->waitSearchSetString;
1525  
1526 =cut
1527  
1528 0 ▶sub waitSearchSetString{
Subroutine waitSearchSetString: not called CC=2 SCAR=17.9
Pod documented
1529 0 my $self=$_[0];
1530 0 my $wait_search_string=$_[1];
1531 0 $self->errorblank;
1532  
1533 0 my @wait_search_array;
1534 0 ▶ if ( ! defined( $wait_search_string ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $wait_search_string) { } 0 0 0
1535 0 $self->{wait_search}=\@wait_search_array;
1536 }else{
1537 0 @wait_search_array=split(/\,/, $wait_search_string);
1538 0 $self->{wait_search}=\@wait_search_array;
1539 }
1540  
1541 0 return 1;
1542 }
1543  
1544 =head2 zombieSearchGet
1545  
1546 Returns the current value for the zombie search.
1547  
1548 The return is a Perl boolean.
1549  
1550 my $zombie_search=$cps->zombieSearchGet;
1551 if ( $zombie_search ){
1552 print "only zombie procs will be shown";
1553 }
1554  
1555 =cut
1556  
1557 0 ▶sub zombieSearchGet{
Subroutine zombieSearchGet: not called CC=1 SCAR=6.9
Pod documented
1558 0 my $self=$_[0];
1559 0 $self->errorblank;
1560  
1561 0 return $self->{zombie_search};
1562 }
1563  
1564 =head2 zombieSearchSet
1565  
1566 Sets the zombie search value.
1567  
1568 The value taken is a Perl boolean.
1569  
1570 $cps->zombieSearchSet( 1 );
1571  
1572 =cut
1573  
1574 0 ▶sub zombieSearchSet{
Subroutine zombieSearchSet: not called CC=1 SCAR=6.9
Pod documented
1575 0 my $self=$_[0];
1576 0 my $zombie_search=$_[1];
1577 0 $self->errorblank;
1578  
1579 0 $self->{zombie_search}=$zombie_search;
1580  
1581 0 return 1;
1582 }
1583  
1584 =head1 COLORS
1585  
1586 These corresponds to L<Term::ANSIColor> colors.
1587  
1588 =head2 Time
1589  
1590 The color column is not a single color, but multiple depending on the amount of time.
1591  
1592 The default is as below.
1593  
1594 'GREEN', seconds
1595 'BRIGHT_GREEN', minutes
1596 'RED', hours
1597 'BRIGHT_RED', 10+ hours
1598  
1599 =head2 Columns
1600  
1601 The non-proc/time columns are colored in a rotating color sequence.
1602  
1603 The default is as below.
1604  
1605 BRIGHT_YELLOW
1606 BRIGHT_CYAN
1607 BRIGHT_MAGENTA
1608 BRIGHT_BLUE
1609  
1610 =head1 ERROR CODES/FLAGS
1611  
1612 =head2 1 / badTimeString
1613  
1614 The time search string contains errors.
1615  
1616 =head2 2 / badPctcpuString
1617  
1618 The PCT CPU search string contains errors.
1619  
1620 =head2 3 / badPctmemString
1621  
1622 The PCT MEM search string contains errors.
1623  
1624 =head1 AUTHOR
1625  
1626 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
1627  
1628 =head1 BUGS
1629  
1630 Please report any bugs or feature requests to C<bug-proc-processtable-colorizer at rt.cpan.org>, or through
1631 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Proc-ProcessTable-Colorizer>. I will be notified, and then you'll
1632 automatically be notified of progress on your bug as I make changes.
1633  
1634  
1635  
1636  
1637 =head1 SUPPORT
1638  
1639 You can find documentation for this module with the perldoc command.
1640  
1641 perldoc Proc::ProcessTable::Colorizer
1642  
1643  
1644 You can also look for information at:
1645  
1646 =over 4
1647  
1648 =item * RT: CPAN's request tracker (report bugs here)
1649  
1650 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Proc-ProcessTable-Colorizer>
1651  
1652 =item * AnnoCPAN: Annotated CPAN documentation
1653  
1654 L<http://annocpan.org/dist/Proc-ProcessTable-Colorizer>
1655  
1656 =item * CPAN Ratings
1657  
1658 L<http://cpanratings.perl.org/d/Proc-ProcessTable-Colorizer>
1659  
1660 =item * Search CPAN
1661  
1662 L<http://search.cpan.org/dist/Proc-ProcessTable-Colorizer/>
1663  
1664 =back
1665  
1666  
1667 =head1 ACKNOWLEDGEMENTS
1668  
1669  
1670 =head1 LICENSE AND COPYRIGHT
1671  
1672 Copyright 2017 Zane C. Bowers-Hadley.
1673  
1674 This program is distributed under the (Simplified) BSD License:
1675 L<http://www.opensource.org/licenses/BSD-2-Clause>
1676  
1677 Redistribution and use in source and binary forms, with or without
1678 modification, are permitted provided that the following conditions
1679 are met:
1680  
1681 * Redistributions of source code must retain the above copyright
1682 notice, this list of conditions and the following disclaimer.
1683  
1684 * Redistributions in binary form must reproduce the above copyright
1685 notice, this list of conditions and the following disclaimer in the
1686 documentation and/or other materials provided with the distribution.
1687  
1688 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1689 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1690 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1691 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1692 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1693 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1694 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1695 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1696 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1697 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1698 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1699  
1700  
1701 =cut
1702  
1703 1 1; # End of Proc::ProcessTable::Colorizer
↑ Summary