line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlGuard::Agent::Monitors::DBI; |
2
|
1
|
|
|
1
|
|
1211
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
777
|
use DBI; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use PerlGuard::Agent::Monitors::DBI::Tracer; |
5
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'PerlGuard::Agent::Monitors'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has tracer => ( is => 'rw' ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub start_monitoring { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#my $handle; |
15
|
|
|
|
|
|
|
#open ($handle,'>>','/tmp/dbi') or die("Cant open /tmp/dbi"); |
16
|
|
|
|
|
|
|
#print $handle "\n * \n * \n * \n * \n"; |
17
|
|
|
|
|
|
|
#use Data::Dumper; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $tracer = PerlGuard::Agent::Monitors::DBI::Tracer->new( |
20
|
|
|
|
|
|
|
sub { |
21
|
|
|
|
|
|
|
my %args = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
unless(blessed($self->agent)) { |
24
|
|
|
|
|
|
|
#warn "Agent was not a blessed object in DBI monitor"; |
25
|
|
|
|
|
|
|
#print $handle Dumper \%args; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$self->agent->add_database_transaction({ |
31
|
|
|
|
|
|
|
start_time => $args{start}, |
32
|
|
|
|
|
|
|
finish_time => $args{finish}, |
33
|
|
|
|
|
|
|
query => $args{sql}, |
34
|
|
|
|
|
|
|
rows_returned => $args{rows} |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->tracer($tracer); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub stop_monitoring { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->tracer(undef); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |