line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Tomcat::Connector::Scoreboard; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use overload ( '""' => \&pretty_print ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
459
|
use Net::Tomcat::Connector::Scoreboard::Entry; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %STATES = ( |
11
|
|
|
|
|
|
|
R => 'ready', |
12
|
|
|
|
|
|
|
P => 'parse', |
13
|
|
|
|
|
|
|
S => 'service', |
14
|
|
|
|
|
|
|
F => 'finish', |
15
|
|
|
|
|
|
|
K => 'keepalive' |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
384
|
foreach my $state ( keys %STATES ) {{ |
19
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
20
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::threads_' . $STATES{ $state } } = sub { |
21
|
0
|
|
|
0
|
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
return grep { $_->{stage} eq $state } @{ $self->{__threads} } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
}} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
0
|
|
|
0
|
1
|
|
my ( $class, @args ) = @_; |
28
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
29
|
0
|
|
|
|
|
|
$self->{__timestamp} = time; |
30
|
0
|
|
|
|
|
|
my @h = @{ shift @args }; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
for ( @args ) { |
33
|
0
|
|
|
|
|
|
my %a; |
34
|
0
|
|
|
|
|
|
@a{ @h } = @{ $_ }; |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
push @{ $self->{__threads} }, Net::Tomcat::Connector::Scoreboard::Entry->new( %a ); |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
sub threads { return @{ $_[0]->{__threads } } } |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
1
|
|
sub thread_count { return scalar @{ $_[0]->{__threads} } } |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub threads_for_client { |
46
|
0
|
|
|
0
|
1
|
|
my ( $self, $client ) = @_; |
47
|
0
|
|
|
|
|
|
return grep { $_->{client} eq $client } @{ $self->{__threads} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub threads_for_vhost { |
51
|
0
|
|
|
0
|
1
|
|
my ( $self, $vhost ) = @_; |
52
|
0
|
|
|
|
|
|
return grep { $_->{vhost} eq $vhost } @{ $self->{__threads} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
|
|
sub __timestamp { return $_[0]->{__timestamp} } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub pretty_print { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
print <
|
60
|
|
|
|
|
|
|
+----------+----------+----------+----------+--------------------+--------------------+----------------------------------------+ |
61
|
|
|
|
|
|
|
| Stage | Time | B Sent | B Recv | Client | VHost | Request | |
62
|
|
|
|
|
|
|
+----------+----------+----------+----------+--------------------+--------------------+----------------------------------------+ |
63
|
|
|
|
|
|
|
PP |
64
|
0
|
|
|
|
|
|
map { |
65
|
0
|
|
|
|
|
|
printf( "|%9s |%9s |%9s |%9s |%19s |%19s |%39s |\n", |
66
|
|
|
|
|
|
|
$_->stage, |
67
|
|
|
|
|
|
|
$_->time, |
68
|
|
|
|
|
|
|
$_->bytes_sent, |
69
|
|
|
|
|
|
|
$_->bytes_received, |
70
|
|
|
|
|
|
|
$_->client, |
71
|
|
|
|
|
|
|
$_->vhost, |
72
|
|
|
|
|
|
|
$_->request |
73
|
|
|
|
|
|
|
) |
74
|
|
|
|
|
|
|
} $self->threads; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
print "+----------+----------+----------+----------+--------------------+--------------------+----------------------------------------+\n"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |