| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Proc::ProcessTable::ncps; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
65826
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
6
|
1
|
|
|
1
|
|
516
|
use Proc::ProcessTable::Match; |
|
|
1
|
|
|
|
|
881
|
|
|
|
1
|
|
|
|
|
31
|
|
|
7
|
1
|
|
|
1
|
|
459
|
use Proc::ProcessTable; |
|
|
1
|
|
|
|
|
5104
|
|
|
|
1
|
|
|
|
|
51
|
|
|
8
|
1
|
|
|
1
|
|
836
|
use Text::ANSITable; |
|
|
1
|
|
|
|
|
104684
|
|
|
|
1
|
|
|
|
|
42
|
|
|
9
|
1
|
|
|
1
|
|
707
|
use Term::ANSIColor; |
|
|
1
|
|
|
|
|
8429
|
|
|
|
1
|
|
|
|
|
92
|
|
|
10
|
1
|
|
|
1
|
|
522
|
use Statistics::Basic qw(:all); |
|
|
1
|
|
|
|
|
15765
|
|
|
|
1
|
|
|
|
|
15
|
|
|
11
|
1
|
|
|
1
|
|
19648
|
use List::Util qw( min max sum ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
107
|
|
|
12
|
1
|
|
|
1
|
|
564
|
use Proc::ProcessTable::InfoString; |
|
|
1
|
|
|
|
|
905
|
|
|
|
1
|
|
|
|
|
3758
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Proc::ProcessTable::ncps - New Colorized(optional) PS, a enhanced version of PS with advanced searching capabilities |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.1.0 |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Proc::ProcessTable::ncps; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $args={ |
|
32
|
|
|
|
|
|
|
cmajor_faults=>0, |
|
33
|
|
|
|
|
|
|
cminor_faults=>0, |
|
34
|
|
|
|
|
|
|
major_faults=>1, |
|
35
|
|
|
|
|
|
|
minor_faults=>0, |
|
36
|
|
|
|
|
|
|
numthr=>0, |
|
37
|
|
|
|
|
|
|
tty=>0, |
|
38
|
|
|
|
|
|
|
jid=>0, |
|
39
|
|
|
|
|
|
|
stats=>1, |
|
40
|
|
|
|
|
|
|
match=>{ |
|
41
|
|
|
|
|
|
|
checks=>\@filters, |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $ncps = Proc::ProcessTable::ncps->new( \%args ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
print $ncps->run |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The info column is provided by L. That |
|
50
|
|
|
|
|
|
|
POD has the information on what they all mean. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 new |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This initiates the object. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head3 args hash ref |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head4 match |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is a hash to pash to L. If not specified, |
|
63
|
|
|
|
|
|
|
this it will not be used all processes will be displayed. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head4 cmajor_faults |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Boolean for if the children major faults column should be shown. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Default: 0 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head4 cminor_faults |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Boolean for if the children minor faults column should be shown. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Default: 0 |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head4 major_faults |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Boolean for if the major faults column should be shown. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Default: 0 |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head4 minor_faults |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Boolean for if the minor faults column should be shown. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Default: 0 |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head4 jid |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Boolean for if the JIDs column should be shown. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Default: 0 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head4 stats |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Boolean for if stats for PctCPU, PctMem, VSZ, RSS |
|
98
|
|
|
|
|
|
|
and time should be shown at the end. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Default: 0 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head4 tty |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Boolean for if the TTY column should be shown. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Default: 0 |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub new { |
|
111
|
0
|
|
|
0
|
1
|
|
my %args; |
|
112
|
0
|
0
|
|
|
|
|
if (defined($_[1])) { |
|
113
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $self = { |
|
118
|
|
|
|
|
|
|
invert=>0, |
|
119
|
|
|
|
|
|
|
match=>undef, |
|
120
|
|
|
|
|
|
|
minor_faults=>0, |
|
121
|
|
|
|
|
|
|
major_faults=>0, |
|
122
|
|
|
|
|
|
|
cminor_faults=>0, |
|
123
|
|
|
|
|
|
|
cmajor_faults=>0, |
|
124
|
|
|
|
|
|
|
colors=>[ |
|
125
|
|
|
|
|
|
|
'BRIGHT_YELLOW', |
|
126
|
|
|
|
|
|
|
'BRIGHT_CYAN', |
|
127
|
|
|
|
|
|
|
'BRIGHT_MAGENTA', |
|
128
|
|
|
|
|
|
|
'BRIGHT_BLUE' |
|
129
|
|
|
|
|
|
|
], |
|
130
|
|
|
|
|
|
|
timeColors=>[ |
|
131
|
|
|
|
|
|
|
'GREEN', |
|
132
|
|
|
|
|
|
|
'BRIGHT_GREEN', |
|
133
|
|
|
|
|
|
|
'RED', |
|
134
|
|
|
|
|
|
|
'BRIGHT_RED' |
|
135
|
|
|
|
|
|
|
], |
|
136
|
|
|
|
|
|
|
vszColors=>[ |
|
137
|
|
|
|
|
|
|
'GREEN', |
|
138
|
|
|
|
|
|
|
'YELLOW', |
|
139
|
|
|
|
|
|
|
'RED', |
|
140
|
|
|
|
|
|
|
'BRIGHT_BLUE' |
|
141
|
|
|
|
|
|
|
], |
|
142
|
|
|
|
|
|
|
rssColors=>[ |
|
143
|
|
|
|
|
|
|
'BRIGHT_GREEN', |
|
144
|
|
|
|
|
|
|
'BRIGHT_YELLOW', |
|
145
|
|
|
|
|
|
|
'BRIGHT_RED', |
|
146
|
|
|
|
|
|
|
'BRIGHT_BLUE' |
|
147
|
|
|
|
|
|
|
], |
|
148
|
|
|
|
|
|
|
processColor=>'BRIGHT_RED', |
|
149
|
|
|
|
|
|
|
nextColor=>0, |
|
150
|
|
|
|
|
|
|
stats=>0, |
|
151
|
|
|
|
|
|
|
jid=>0, |
|
152
|
|
|
|
|
|
|
tty=>0, |
|
153
|
|
|
|
|
|
|
numthr=>0, |
|
154
|
|
|
|
|
|
|
}; |
|
155
|
0
|
|
|
|
|
|
bless $self; |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
|
|
0
|
|
|
|
|
|
158
|
|
|
|
|
|
|
defined( $args{match} ) && |
|
159
|
|
|
|
|
|
|
defined( $args{match}{checks} ) && |
|
160
|
|
|
|
|
|
|
defined( $args{match}{checks}[0] ) |
|
161
|
|
|
|
|
|
|
){ |
|
162
|
0
|
|
|
|
|
|
$self->{match}=Proc::ProcessTable::Match->new( $args{match} ); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my @bool_feed=( |
|
166
|
|
|
|
|
|
|
'major_faults', 'minor_faults', 'cmajor_faults', |
|
167
|
|
|
|
|
|
|
'cminor_faults', 'numthr', 'tty', 'jid', 'stats' |
|
168
|
|
|
|
|
|
|
); |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
foreach my $feed ( @bool_feed ){ |
|
171
|
0
|
|
|
|
|
|
$self->{$feed}=$args{$feed}; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $self; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 run |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This runs it. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The return value is a string. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
print $ncps->run |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub run{ |
|
188
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
my $ppt = Proc::ProcessTable->new( 'cache_ttys' => 1 ); |
|
191
|
0
|
|
|
|
|
|
my $pt = $ppt->table; |
|
192
|
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
my $procs; |
|
194
|
0
|
0
|
|
|
|
|
if ( defined( $self->{match} ) ){ |
|
195
|
0
|
|
|
|
|
|
$procs=[]; |
|
196
|
0
|
|
|
|
|
|
foreach my $proc ( @{ $pt } ){ |
|
|
0
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
eval{ |
|
198
|
0
|
0
|
|
|
|
|
if ( $self->{match}->match( $proc ) ){ |
|
199
|
0
|
|
|
|
|
|
push( @{ $procs }, $proc ); |
|
|
0
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
}; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
}else{ |
|
204
|
0
|
|
|
|
|
|
$procs=$pt; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# figures out if this systems reports nice or not |
|
208
|
0
|
|
|
|
|
|
my $have_nice=0; |
|
209
|
0
|
0
|
0
|
|
|
|
if ( |
|
210
|
|
|
|
|
|
|
defined( $procs->[0] ) && |
|
211
|
|
|
|
|
|
|
defined($procs->[0]->{nice} ) |
|
212
|
|
|
|
|
|
|
){ |
|
213
|
0
|
|
|
|
|
|
$have_nice=1; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# figures out if this systems reports priority or not |
|
217
|
0
|
|
|
|
|
|
my $have_pri=0; |
|
218
|
0
|
0
|
0
|
|
|
|
if ( |
|
219
|
|
|
|
|
|
|
defined( $procs->[0] ) && |
|
220
|
|
|
|
|
|
|
defined($procs->[0]->{priority} ) |
|
221
|
|
|
|
|
|
|
){ |
|
222
|
0
|
|
|
|
|
|
$have_pri=1; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
my $physmem; |
|
226
|
0
|
0
|
|
|
|
|
if ( $^O =~ /bsd/ ){ |
|
227
|
0
|
|
|
|
|
|
$physmem=`/sbin/sysctl -a hw.physmem`; |
|
228
|
0
|
|
|
|
|
|
chomp( $physmem ); |
|
229
|
0
|
|
|
|
|
|
$physmem=~s/^.*\: //; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
my $tb = Text::ANSITable->new; |
|
233
|
0
|
|
|
|
|
|
$tb->border_style('Default::none_ascii'); |
|
234
|
0
|
|
|
|
|
|
$tb->color_theme('Default::no_color'); |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# |
|
237
|
|
|
|
|
|
|
# assemble the headers |
|
238
|
|
|
|
|
|
|
# |
|
239
|
0
|
|
|
|
|
|
my @headers; |
|
240
|
0
|
|
|
|
|
|
my $header_int=0; |
|
241
|
0
|
|
|
|
|
|
my $padding=0; |
|
242
|
0
|
|
|
|
|
|
push( @headers, 'User' ); |
|
243
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 0); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
push( @headers, 'PID' ); |
|
245
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 1); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
push( @headers, 'CPU' ); |
|
247
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 0); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
push( @headers, 'MEM' ); |
|
249
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 1); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
push( @headers, 'VSZ' ); |
|
251
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 0); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
push( @headers, 'RSS' ); |
|
253
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => 1); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
push( @headers, 'Info' ); |
|
255
|
|
|
|
|
|
|
# add nice if needed |
|
256
|
0
|
0
|
|
|
|
|
if ( $have_nice ){ |
|
257
|
0
|
|
|
|
|
|
push( @headers, 'Nic' ); |
|
258
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
# add priority if needed |
|
262
|
0
|
0
|
|
|
|
|
if ( $have_pri ){ |
|
263
|
0
|
|
|
|
|
|
push( @headers, 'Pri' ); |
|
264
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
# add major faults if needed |
|
268
|
0
|
0
|
|
|
|
|
if ( $self->{major_faults} ){ |
|
269
|
0
|
|
|
|
|
|
push( @headers, 'MajF' ); |
|
270
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
# add minor faults if needed |
|
274
|
0
|
0
|
|
|
|
|
if ( $self->{minor_faults} ){ |
|
275
|
0
|
|
|
|
|
|
push( @headers, 'minF' ); |
|
276
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
277
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
# add children major faults if needed |
|
280
|
0
|
0
|
|
|
|
|
if ( $self->{cmajor_faults} ){ |
|
281
|
0
|
|
|
|
|
|
push( @headers, 'cMajF' ); |
|
282
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
# add children minor faults if needed |
|
286
|
0
|
0
|
|
|
|
|
if ( $self->{cminor_faults} ){ |
|
287
|
0
|
|
|
|
|
|
push( @headers, 'cminF' ); |
|
288
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
# add children minor faults if needed |
|
292
|
0
|
0
|
|
|
|
|
if ( $self->{numthr} ){ |
|
293
|
0
|
|
|
|
|
|
push( @headers, 'Thr' ); |
|
294
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
} |
|
297
|
|
|
|
|
|
|
# add children minor faults if needed |
|
298
|
0
|
0
|
|
|
|
|
if ( $self->{tty} ){ |
|
299
|
0
|
|
|
|
|
|
push( @headers, 'TTY' ); |
|
300
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
# add jail ID if needed |
|
304
|
0
|
0
|
|
|
|
|
if ( $self->{jid} ){ |
|
305
|
0
|
|
|
|
|
|
push( @headers, 'JID' ); |
|
306
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
} |
|
309
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
|
push( @headers, 'Start' ); |
|
312
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
313
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
push( @headers, 'Time' ); |
|
315
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding ); $header_int++; |
|
|
0
|
|
|
|
|
|
|
|
317
|
0
|
|
|
|
|
|
push( @headers, 'Command' ); |
|
318
|
0
|
0
|
|
|
|
|
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
$tb->set_column_style($header_int, pad => $padding, formats=>[[wrap => {ansi=>1, mb=>1}]]); |
|
320
|
|
|
|
|
|
|
|
|
321
|
0
|
|
|
|
|
|
$tb->columns( \@headers ); |
|
322
|
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
my @stats_rss; |
|
324
|
|
|
|
|
|
|
my @stats_vsz; |
|
325
|
0
|
|
|
|
|
|
my @stats_time; |
|
326
|
0
|
|
|
|
|
|
my @stats_pctcpu; |
|
327
|
0
|
|
|
|
|
|
my @stats_pctmem; |
|
328
|
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
my @td; |
|
330
|
0
|
|
|
|
|
|
foreach my $proc ( @{ $procs } ) { |
|
|
0
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
my @new_line; |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
# |
|
334
|
|
|
|
|
|
|
# handle username column |
|
335
|
|
|
|
|
|
|
# |
|
336
|
0
|
|
|
|
|
|
my $user=getpwuid($proc->{uid}); |
|
337
|
0
|
0
|
|
|
|
|
if ( ! defined( $user ) ) { |
|
338
|
0
|
|
|
|
|
|
$user=$proc->{uid}; |
|
339
|
|
|
|
|
|
|
} |
|
340
|
0
|
|
|
|
|
|
$user=color($self->nextColor).$user.color('reset'); |
|
341
|
0
|
|
|
|
|
|
push( @new_line, $user ); |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
# |
|
344
|
|
|
|
|
|
|
# handles the PID |
|
345
|
|
|
|
|
|
|
# |
|
346
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{pid}.color('reset') ); |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# |
|
349
|
|
|
|
|
|
|
# handles the %CPU |
|
350
|
|
|
|
|
|
|
# |
|
351
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{pctcpu}.color('reset') ); |
|
352
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_pctcpu, $proc->{pctcpu} ); } |
|
|
0
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
# |
|
355
|
|
|
|
|
|
|
# handles the %MEM |
|
356
|
|
|
|
|
|
|
# |
|
357
|
0
|
0
|
|
|
|
|
if ( $^O =~ /bsd/ ) { |
|
358
|
0
|
|
|
|
|
|
my $mem=(($proc->{rssize} * 1024 * 4 ) / $physmem) * 100; |
|
359
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).sprintf('%.2f', $mem).color('reset') ); |
|
360
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_pctmem, $mem ); } |
|
|
0
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
} else { |
|
362
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).sprintf('%.2f', $proc->{pctmem}).color('reset') ); |
|
363
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_pctmem, $proc->{pctmem} ); } |
|
|
0
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
# |
|
367
|
|
|
|
|
|
|
# handles VSZ |
|
368
|
|
|
|
|
|
|
# |
|
369
|
0
|
|
|
|
|
|
push( @new_line, $self->memString( $proc->{size}, 'vsz') ); |
|
370
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_vsz, $proc->{size} ); } |
|
|
0
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
# |
|
373
|
|
|
|
|
|
|
# handles the rss |
|
374
|
|
|
|
|
|
|
# |
|
375
|
0
|
|
|
|
|
|
push( @new_line, $self->memString( $proc->{rss}, 'rss') ); |
|
376
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_rss, $proc->{rss} ); } |
|
|
0
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
# |
|
379
|
|
|
|
|
|
|
# handles the info |
|
380
|
|
|
|
|
|
|
# |
|
381
|
0
|
|
|
|
|
|
my $is = Proc::ProcessTable::InfoString->new({ |
|
382
|
|
|
|
|
|
|
flags_color=>$self->nextColor, |
|
383
|
|
|
|
|
|
|
wchan_color=>$self->nextColor, |
|
384
|
|
|
|
|
|
|
}); |
|
385
|
0
|
|
|
|
|
|
push( @new_line, $is->info( $proc ) ); |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# |
|
388
|
|
|
|
|
|
|
# handle the nice column |
|
389
|
|
|
|
|
|
|
# |
|
390
|
0
|
0
|
|
|
|
|
if ( $have_nice ) { |
|
391
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{nice}.color('reset') ); |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
# |
|
395
|
|
|
|
|
|
|
# handle the priority column |
|
396
|
|
|
|
|
|
|
# |
|
397
|
0
|
0
|
|
|
|
|
if ( $have_pri ) { |
|
398
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{priority}.color('reset') ); |
|
399
|
|
|
|
|
|
|
} |
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# |
|
402
|
|
|
|
|
|
|
# major faults |
|
403
|
|
|
|
|
|
|
# |
|
404
|
0
|
0
|
|
|
|
|
if ( $self->{major_faults} ) { |
|
405
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{majflt}.color('reset') ); |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# |
|
409
|
|
|
|
|
|
|
# major faults |
|
410
|
|
|
|
|
|
|
# |
|
411
|
0
|
0
|
|
|
|
|
if ( $self->{minor_faults} ) { |
|
412
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{minflt}.color('reset') ); |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# |
|
416
|
|
|
|
|
|
|
# children major faults |
|
417
|
|
|
|
|
|
|
# |
|
418
|
0
|
0
|
|
|
|
|
if ( $self->{cmajor_faults} ) { |
|
419
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{cmajflt}.color('reset') ); |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
# |
|
423
|
|
|
|
|
|
|
# children major faults |
|
424
|
|
|
|
|
|
|
# |
|
425
|
0
|
0
|
|
|
|
|
if ( $self->{cminor_faults} ) { |
|
426
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{cminflt}.color('reset') ); |
|
427
|
|
|
|
|
|
|
} |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
# |
|
430
|
|
|
|
|
|
|
# number of threads |
|
431
|
|
|
|
|
|
|
# |
|
432
|
0
|
0
|
|
|
|
|
if ( $self->{numthr} ) { |
|
433
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{numthr}.color('reset') ); |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
# |
|
437
|
|
|
|
|
|
|
# number of threads |
|
438
|
|
|
|
|
|
|
# |
|
439
|
0
|
0
|
|
|
|
|
if ( $self->{tty} ) { |
|
440
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{ttydev}.color('reset') ); |
|
441
|
|
|
|
|
|
|
} |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
# |
|
444
|
|
|
|
|
|
|
# jail ID |
|
445
|
|
|
|
|
|
|
# |
|
446
|
0
|
0
|
|
|
|
|
if ( $self->{jid} ) { |
|
447
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$proc->{jid}.color('reset') ); |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
# |
|
451
|
|
|
|
|
|
|
# handles the start column |
|
452
|
|
|
|
|
|
|
# |
|
453
|
0
|
|
|
|
|
|
push( @new_line, color($self->nextColor).$self->startString( $proc->{start} ).color('reset') ); |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# |
|
456
|
|
|
|
|
|
|
# handles the time column |
|
457
|
|
|
|
|
|
|
# |
|
458
|
0
|
|
|
|
|
|
push( @new_line, $self->timeString( $proc->{time} ) ); |
|
459
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ push( @stats_time, $proc->{time} ); } |
|
|
0
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
# |
|
462
|
|
|
|
|
|
|
# handle the command |
|
463
|
|
|
|
|
|
|
# |
|
464
|
0
|
|
|
|
|
|
my $command=color($self->{processColor}); |
|
465
|
0
|
0
|
|
|
|
|
if ( $proc->{cmndline} =~ /^$/ ) { |
|
466
|
0
|
|
|
|
|
|
$command=$command.'['.$proc->{fname}.']'; |
|
467
|
|
|
|
|
|
|
} else { |
|
468
|
0
|
|
|
|
|
|
$command=$command.$proc->{cmndline}; |
|
469
|
|
|
|
|
|
|
} |
|
470
|
0
|
|
|
|
|
|
push( @new_line, $command.color('reset') ); |
|
471
|
|
|
|
|
|
|
|
|
472
|
0
|
|
|
|
|
|
push( @td, \@new_line ); |
|
473
|
0
|
|
|
|
|
|
$self->{nextColor}=0; |
|
474
|
|
|
|
|
|
|
} |
|
475
|
|
|
|
|
|
|
|
|
476
|
0
|
|
|
|
|
|
$tb->add_rows( \@td ); |
|
477
|
|
|
|
|
|
|
|
|
478
|
0
|
|
|
|
|
|
my $stats=''; |
|
479
|
0
|
0
|
|
|
|
|
if ( $self->{stats} ){ |
|
480
|
0
|
|
|
|
|
|
my $stb = Text::ANSITable->new; |
|
481
|
0
|
|
|
|
|
|
$stb->border_style('Default::none_ascii'); |
|
482
|
0
|
|
|
|
|
|
$stb->color_theme('Default::no_color'); |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
# |
|
485
|
|
|
|
|
|
|
# assemble the headers |
|
486
|
|
|
|
|
|
|
# |
|
487
|
0
|
|
|
|
|
|
my @stats_headers; |
|
488
|
0
|
|
|
|
|
|
push( @stats_headers, ' ' ); |
|
489
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 0); |
|
490
|
0
|
|
|
|
|
|
push( @stats_headers, 'Min' ); |
|
491
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 1); |
|
492
|
0
|
|
|
|
|
|
push( @stats_headers, 'Avg' ); |
|
493
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 0); |
|
494
|
0
|
|
|
|
|
|
push( @stats_headers, 'Med' ); |
|
495
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 1); |
|
496
|
0
|
|
|
|
|
|
push( @stats_headers, 'Max' ); |
|
497
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 0); |
|
498
|
0
|
|
|
|
|
|
push( @stats_headers, 'StdDev' ); |
|
499
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 1); |
|
500
|
0
|
|
|
|
|
|
push( @stats_headers, 'Sum' ); |
|
501
|
0
|
|
|
|
|
|
$stb->set_column_style($header_int, pad => 0); |
|
502
|
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
$stb->columns( \@stats_headers ); |
|
504
|
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
|
my @std; |
|
506
|
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
my $stats_avg=avg(@stats_pctcpu); |
|
508
|
0
|
|
|
|
|
|
$stats_avg=~s/\,//g; |
|
509
|
0
|
|
|
|
|
|
my $stats_median=median(@stats_pctcpu); |
|
510
|
0
|
|
|
|
|
|
$stats_median=~s/\,//g; |
|
511
|
0
|
|
|
|
|
|
my $stats_stddev=stddev(@stats_pctcpu); |
|
512
|
0
|
|
|
|
|
|
$stats_stddev=~s/\,//g; |
|
513
|
0
|
|
|
|
|
|
push( @std, [ |
|
514
|
|
|
|
|
|
|
'CPU%', |
|
515
|
|
|
|
|
|
|
sprintf('%.2f', min( @stats_pctcpu )), |
|
516
|
|
|
|
|
|
|
$stats_avg, |
|
517
|
|
|
|
|
|
|
$stats_median, |
|
518
|
|
|
|
|
|
|
sprintf('%.2f', max( @stats_pctcpu )), |
|
519
|
|
|
|
|
|
|
$stats_stddev, |
|
520
|
|
|
|
|
|
|
sprintf('%.2f', sum( @stats_pctcpu )), |
|
521
|
|
|
|
|
|
|
]); |
|
522
|
|
|
|
|
|
|
|
|
523
|
0
|
|
|
|
|
|
$stats_avg=avg(@stats_pctmem); |
|
524
|
0
|
|
|
|
|
|
$stats_avg=~s/\,//g; |
|
525
|
0
|
|
|
|
|
|
$stats_median=median(@stats_pctmem); |
|
526
|
0
|
|
|
|
|
|
$stats_median=~s/\,//g; |
|
527
|
0
|
|
|
|
|
|
$stats_stddev=stddev(@stats_pctmem); |
|
528
|
0
|
|
|
|
|
|
$stats_stddev=~s/\,//g; |
|
529
|
0
|
|
|
|
|
|
push( @std, [ |
|
530
|
|
|
|
|
|
|
'Mem%', |
|
531
|
|
|
|
|
|
|
sprintf('%.2f', min( @stats_pctmem )), |
|
532
|
|
|
|
|
|
|
$stats_avg, |
|
533
|
|
|
|
|
|
|
$stats_median, |
|
534
|
|
|
|
|
|
|
sprintf('%.2f', max( @stats_pctmem )), |
|
535
|
|
|
|
|
|
|
$stats_stddev, |
|
536
|
|
|
|
|
|
|
sprintf('%.2f', sum( @stats_pctmem )), |
|
537
|
|
|
|
|
|
|
]); |
|
538
|
|
|
|
|
|
|
|
|
539
|
0
|
|
|
|
|
|
$stats_avg=avg(@stats_vsz); |
|
540
|
0
|
|
|
|
|
|
$stats_avg=~s/\,//g; |
|
541
|
0
|
|
|
|
|
|
$stats_median=median(@stats_vsz); |
|
542
|
0
|
|
|
|
|
|
$stats_median=~s/\,//g; |
|
543
|
0
|
|
|
|
|
|
$stats_stddev=stddev(@stats_vsz); |
|
544
|
0
|
|
|
|
|
|
$stats_stddev=~s/\,//g; |
|
545
|
0
|
|
|
|
|
|
push( @std, [ |
|
546
|
|
|
|
|
|
|
'VSZ', |
|
547
|
|
|
|
|
|
|
$self->memString( min( @stats_vsz), 'vsz'), |
|
548
|
|
|
|
|
|
|
$self->memString( $stats_avg, 'vsz'), |
|
549
|
|
|
|
|
|
|
$self->memString( $stats_median, 'vsz'), |
|
550
|
|
|
|
|
|
|
$self->memString( max( @stats_vsz ), 'vsz'), |
|
551
|
|
|
|
|
|
|
$self->memString( $stats_stddev, 'vsz'), |
|
552
|
|
|
|
|
|
|
$self->memString( sum( @stats_vsz), 'vsz'), |
|
553
|
|
|
|
|
|
|
]); |
|
554
|
|
|
|
|
|
|
|
|
555
|
0
|
|
|
|
|
|
$stats_avg=avg(@stats_rss); |
|
556
|
0
|
|
|
|
|
|
$stats_avg=~s/\,//g; |
|
557
|
0
|
|
|
|
|
|
$stats_median=median(@stats_rss); |
|
558
|
0
|
|
|
|
|
|
$stats_median=~s/\,//g; |
|
559
|
0
|
|
|
|
|
|
$stats_stddev=stddev(@stats_rss); |
|
560
|
0
|
|
|
|
|
|
$stats_stddev=~s/\,//g; |
|
561
|
0
|
|
|
|
|
|
push( @std, [ |
|
562
|
|
|
|
|
|
|
'RSS', |
|
563
|
|
|
|
|
|
|
$self->memString( min( @stats_rss ), 'rss'), |
|
564
|
|
|
|
|
|
|
$self->memString( $stats_avg, 'rss'), |
|
565
|
|
|
|
|
|
|
$self->memString( $stats_median, 'rss'), |
|
566
|
|
|
|
|
|
|
$self->memString( max( @stats_rss ), 'rss'), |
|
567
|
|
|
|
|
|
|
$self->memString( $stats_stddev, 'rss'), |
|
568
|
|
|
|
|
|
|
$self->memString( sum( @stats_rss ), 'rss'), |
|
569
|
|
|
|
|
|
|
]); |
|
570
|
|
|
|
|
|
|
|
|
571
|
0
|
|
|
|
|
|
$stats_avg=avg(@stats_time); |
|
572
|
0
|
|
|
|
|
|
$stats_avg=~s/\,//g; |
|
573
|
0
|
|
|
|
|
|
$stats_median=median(@stats_time); |
|
574
|
0
|
|
|
|
|
|
$stats_median=~s/\,//g; |
|
575
|
0
|
|
|
|
|
|
$stats_stddev=stddev(@stats_time); |
|
576
|
0
|
|
|
|
|
|
$stats_stddev=~s/\,//g; |
|
577
|
0
|
|
|
|
|
|
push( @std, [ |
|
578
|
|
|
|
|
|
|
'Time', |
|
579
|
|
|
|
|
|
|
$self->timeString( min( @stats_time ) ), |
|
580
|
|
|
|
|
|
|
$self->timeString( $stats_avg ), |
|
581
|
|
|
|
|
|
|
$self->timeString( $stats_median ), |
|
582
|
|
|
|
|
|
|
$self->timeString( max( @stats_time ) ),, |
|
583
|
|
|
|
|
|
|
$self->timeString( $stats_stddev ), |
|
584
|
|
|
|
|
|
|
$self->timeString( sum( @stats_time ) ), |
|
585
|
|
|
|
|
|
|
]); |
|
586
|
|
|
|
|
|
|
|
|
587
|
0
|
|
|
|
|
|
$stb->add_rows( \@std ); |
|
588
|
|
|
|
|
|
|
|
|
589
|
0
|
|
|
|
|
|
$stats="\n".$stb->draw; |
|
590
|
|
|
|
|
|
|
} |
|
591
|
|
|
|
|
|
|
|
|
592
|
0
|
|
|
|
|
|
return $tb->draw.$stats; |
|
593
|
|
|
|
|
|
|
} |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=head2 startString |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
Generates a short time string based on the supplied unix time. |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=cut |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
sub startString{ |
|
602
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
603
|
0
|
|
|
|
|
|
my $startTime=$_[1]; |
|
604
|
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($startTime); |
|
606
|
0
|
|
|
|
|
|
my ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime(time); |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
#add the required stuff to make this sane |
|
609
|
0
|
|
|
|
|
|
$year += 1900; |
|
610
|
0
|
|
|
|
|
|
$cyear += 1900; |
|
611
|
0
|
|
|
|
|
|
$mon += 1; |
|
612
|
0
|
|
|
|
|
|
$cmon += 1; |
|
613
|
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
#find the most common one and return it |
|
615
|
0
|
0
|
|
|
|
|
if ( $year ne $cyear ){ |
|
616
|
0
|
|
|
|
|
|
return $year.sprintf('%02d', $mon).sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min); |
|
617
|
|
|
|
|
|
|
} |
|
618
|
0
|
0
|
|
|
|
|
if ( $mon ne $cmon ){ |
|
619
|
0
|
|
|
|
|
|
return sprintf('%02d', $mon).sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min); |
|
620
|
|
|
|
|
|
|
} |
|
621
|
0
|
0
|
|
|
|
|
if ( $mday ne $cmday ){ |
|
622
|
0
|
|
|
|
|
|
return sprintf('%02d', $mday).'-'.sprintf('%02d', $hour).':'.sprintf('%02d', $min); |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
#just return this for anything less |
|
626
|
0
|
|
|
|
|
|
return sprintf('%02d', $hour).':'.sprintf('%02d', $min); |
|
627
|
|
|
|
|
|
|
} |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
=head2 timeString |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
Turns the raw run string into something usable. |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
=cut |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
sub timeString{ |
|
636
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
637
|
0
|
|
|
|
|
|
my $time=$_[1]; |
|
638
|
|
|
|
|
|
|
|
|
639
|
0
|
0
|
|
|
|
|
if ( $^O =~ /^linux$/ ){ |
|
640
|
0
|
|
|
|
|
|
$time=$time/1000000; |
|
641
|
|
|
|
|
|
|
} |
|
642
|
|
|
|
|
|
|
|
|
643
|
0
|
|
|
|
|
|
my $hours=0; |
|
644
|
0
|
0
|
|
|
|
|
if ( $time >= 3600 ){ |
|
645
|
0
|
|
|
|
|
|
$hours = $time / 3600; |
|
646
|
|
|
|
|
|
|
} |
|
647
|
0
|
|
|
|
|
|
my $loSeconds = $time % 3600; |
|
648
|
0
|
|
|
|
|
|
my $minutes=0; |
|
649
|
0
|
0
|
|
|
|
|
if ( $time >= 60 ){ |
|
650
|
0
|
|
|
|
|
|
$minutes = $loSeconds / 60; |
|
651
|
|
|
|
|
|
|
} |
|
652
|
0
|
|
|
|
|
|
my $seconds = $loSeconds % 60; |
|
653
|
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
#nicely format it |
|
655
|
0
|
|
|
|
|
|
$hours=~s/\..*//; |
|
656
|
0
|
|
|
|
|
|
$minutes=~s/\..*//; |
|
657
|
0
|
|
|
|
|
|
$seconds=sprintf('%.f',$seconds); |
|
658
|
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
#this will be returned |
|
660
|
0
|
|
|
|
|
|
my $toReturn=''; |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
#process the hours bit |
|
663
|
0
|
0
|
|
|
|
|
if ( $hours == 0 ){ |
|
|
|
0
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
#don't do anything if time is 0 |
|
665
|
|
|
|
|
|
|
}elsif( |
|
666
|
|
|
|
|
|
|
$hours >= 10 |
|
667
|
|
|
|
|
|
|
){ |
|
668
|
0
|
|
|
|
|
|
$toReturn=color($self->{timeColors}->[3]).$hours.':'; |
|
669
|
|
|
|
|
|
|
}else{ |
|
670
|
0
|
|
|
|
|
|
$toReturn=color($self->{timeColors}->[2]).$hours.':'; |
|
671
|
|
|
|
|
|
|
} |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
#process the minutes bit |
|
674
|
0
|
0
|
0
|
|
|
|
if ( |
|
675
|
|
|
|
|
|
|
( $hours > 0 ) || |
|
676
|
|
|
|
|
|
|
( $minutes > 0 ) |
|
677
|
|
|
|
|
|
|
){ |
|
678
|
0
|
|
|
|
|
|
$toReturn=$toReturn.color( $self->{timeColors}->[1] ). $minutes.':'; |
|
679
|
|
|
|
|
|
|
} |
|
680
|
|
|
|
|
|
|
|
|
681
|
0
|
|
|
|
|
|
$toReturn=$toReturn.color( $self->{timeColors}->[0] ).$seconds.color('reset'); |
|
682
|
|
|
|
|
|
|
|
|
683
|
0
|
|
|
|
|
|
return $toReturn; |
|
684
|
|
|
|
|
|
|
} |
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=head2 memString |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
Turns the raw run string into something usable. |
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=cut |
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
sub memString{ |
|
693
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
694
|
0
|
|
|
|
|
|
my $mem=$_[1]; |
|
695
|
0
|
|
|
|
|
|
my $type=$_[2]; |
|
696
|
|
|
|
|
|
|
|
|
697
|
0
|
|
|
|
|
|
my $toReturn=''; |
|
698
|
|
|
|
|
|
|
|
|
699
|
0
|
0
|
0
|
|
|
|
if ( $mem < '10000' ){ |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
700
|
0
|
|
|
|
|
|
$toReturn=color( $self->{$type.'Colors'}[0] ).$mem; |
|
701
|
|
|
|
|
|
|
}elsif( |
|
702
|
|
|
|
|
|
|
( $mem >= '10000' ) && |
|
703
|
|
|
|
|
|
|
( $mem < '1000000' ) |
|
704
|
|
|
|
|
|
|
){ |
|
705
|
0
|
|
|
|
|
|
$mem=$mem/1000; |
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
$toReturn=color( $self->{$type.'Colors'}[0] ).$mem. |
|
708
|
0
|
|
|
|
|
|
color( $self->{$type.'Colors'}[3] ).'k'; |
|
709
|
|
|
|
|
|
|
}elsif( |
|
710
|
|
|
|
|
|
|
( $mem >= '1000000' ) && |
|
711
|
|
|
|
|
|
|
( $mem < '1000000000' ) |
|
712
|
|
|
|
|
|
|
){ |
|
713
|
0
|
|
|
|
|
|
$mem=($mem/1000)/1000; |
|
714
|
0
|
|
|
|
|
|
$mem=sprintf('%.3f', $mem); |
|
715
|
0
|
|
|
|
|
|
my @mem_split=split(/\./, $mem); |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
$toReturn=color( $self->{$type.'Colors'}[1] ).$mem_split[0].'.'.color( $self->{$type.'Colors'}[0] ).$mem_split[1]. |
|
718
|
0
|
|
|
|
|
|
color( $self->{$type.'Colors'}[3] ).'M'; |
|
719
|
|
|
|
|
|
|
}elsif( $mem >= '1000000000' ){ |
|
720
|
0
|
|
|
|
|
|
$mem=(($mem/1000)/1000)/1000; |
|
721
|
0
|
|
|
|
|
|
$mem=sprintf('%.3f', $mem); |
|
722
|
0
|
|
|
|
|
|
my @mem_split=split(/\./, $mem); |
|
723
|
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
$toReturn=color( $self->{$type.'Colors'}[2] ).$mem_split[0].'.'.color( $self->{$type.'Colors'}[1] ).$mem_split[1]. |
|
725
|
0
|
|
|
|
|
|
color( $self->{$type.'Colors'}[3] ).'G'; |
|
726
|
|
|
|
|
|
|
} |
|
727
|
|
|
|
|
|
|
|
|
728
|
0
|
|
|
|
|
|
return $toReturn.color('reset'); |
|
729
|
|
|
|
|
|
|
} |
|
730
|
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=head2 nextColor |
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
Returns the next color. |
|
735
|
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=cut |
|
737
|
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
sub nextColor{ |
|
739
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
740
|
|
|
|
|
|
|
|
|
741
|
0
|
|
|
|
|
|
my $color; |
|
742
|
|
|
|
|
|
|
|
|
743
|
0
|
0
|
|
|
|
|
if ( defined( $self->{colors}[ $self->{nextColor} ] ) ) { |
|
744
|
0
|
|
|
|
|
|
$color=$self->{colors}[ $self->{nextColor} ]; |
|
745
|
0
|
|
|
|
|
|
$self->{nextColor}++; |
|
746
|
|
|
|
|
|
|
} else { |
|
747
|
0
|
|
|
|
|
|
$self->{nextColor}=0; |
|
748
|
0
|
|
|
|
|
|
$color=$self->{colors}[ $self->{nextColor} ]; |
|
749
|
0
|
|
|
|
|
|
$self->{nextColor}++; |
|
750
|
|
|
|
|
|
|
} |
|
751
|
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
return $color; |
|
753
|
|
|
|
|
|
|
} |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=head1 AUTHOR |
|
757
|
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
759
|
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=head1 BUGS |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
763
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
764
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=head1 SUPPORT |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
perldoc Proc::ProcessTable::ncps |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
You can also look for information at: |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
=over 4 |
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
781
|
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
L |
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
785
|
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
L |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
789
|
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
L |
|
791
|
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=item * Search CPAN |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
L |
|
795
|
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
=item * Repository |
|
797
|
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
L |
|
799
|
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
=back |
|
801
|
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
804
|
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
807
|
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Zane C. Bowers-Hadley. |
|
809
|
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
This is free software, licensed under: |
|
811
|
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
813
|
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=cut |
|
816
|
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
1; # End of Proc::ProcessTable::ncps |